Python binding for c2pa-rs library
See the codeThe c2pa-python repository provides a Python library that can:
Features:
For the best experience, read the docs on the CAI Open Source SDK documentation website.
If you want to view the documentation in GitHub, see:
Context and SettingsThis library requires Python version 3.10+.
Install the c2pa-python package from PyPI by running:
pip install c2pa-python
To use the module in Python code, import the module like this:
import c2pa
The make targets honor an active virtualenv. Create a virtual environment ./.venv and activate it before running them so commands use the project interpreter rather than the global Python interpreter:
make create-venv && source .venv/bin/activate
By default the build downloads a prebuilt native library from a c2pa-rs release. To test the Python bindings against a local, unreleased c2pa-rs checkout, you can instead build the native library from source.
Prerequisites:
cargo on your PATH).Point C2PA_RS_PATH at your c2pa-rs checkout and run the build-from-source target:
export C2PA_RS_PATH=/path/to/c2pa-rs
make build-from-source C2PA_RS_PATH=$C2PA_RS_PATH
This does a clean build of the c2pa-c-ffi crate (with the file_io feature, which the Python wrapper requires), stages the resulting library under both artifacts/ and src/c2pa/libs/, and installs the package in editable mode, replacing any prebuilt artifacts from make download-native-artifacts. By default, the build uses the release profile; to build the debug profile instead, pass EXTRA_BUILD_ARGS="--debug":
make build-from-source C2PA_RS_PATH=$C2PA_RS_PATH EXTRA_BUILD_ARGS="--debug"
On macOS this produces a universal (arm64+x86_64) library by default, which requires both Rust targets:
rustup target add aarch64-apple-darwin x86_64-apple-darwin
To build a single-architecture library instead, set C2PA_LIBS_PLATFORM to a specific platform (for example aarch64-apple-darwin).
See the examples directory for some helpful examples:
examples/read.py shows how to read and verify an asset with a C2PA manifest.examples/sign.py shows how to sign and verify an asset with a C2PA manifest.examples/training.py demonstrates how to add a "Do Not Train" assertion to an asset and verify it.Documentation is published at github.io/c2pa-python/api/c2pa.
To build documentation locally, refer to this section in Contributing to the project.
Contributions are welcome! For more information, see Contributing to the project.
This project is licensed under the Apache License 2.0 and the MIT License. See the LICENSE-MIT and LICENSE-APACHE files for details.
201 followers · starred Jun 2025
15 followers · starred Dec 2024
19 followers · starred Jan 2025
Python binding for c2pa-rs library
See the codeThe c2pa-python repository provides a Python library that can:
Features:
For the best experience, read the docs on the CAI Open Source SDK documentation website.
If you want to view the documentation in GitHub, see:
Context and SettingsThis library requires Python version 3.10+.
Install the c2pa-python package from PyPI by running:
pip install c2pa-python
To use the module in Python code, import the module like this:
import c2pa
The make targets honor an active virtualenv. Create a virtual environment ./.venv and activate it before running them so commands use the project interpreter rather than the global Python interpreter:
make create-venv && source .venv/bin/activate
By default the build downloads a prebuilt native library from a c2pa-rs release. To test the Python bindings against a local, unreleased c2pa-rs checkout, you can instead build the native library from source.
Prerequisites:
cargo on your PATH).Point C2PA_RS_PATH at your c2pa-rs checkout and run the build-from-source target:
export C2PA_RS_PATH=/path/to/c2pa-rs
make build-from-source C2PA_RS_PATH=$C2PA_RS_PATH
This does a clean build of the c2pa-c-ffi crate (with the file_io feature, which the Python wrapper requires), stages the resulting library under both artifacts/ and src/c2pa/libs/, and installs the package in editable mode, replacing any prebuilt artifacts from make download-native-artifacts. By default, the build uses the release profile; to build the debug profile instead, pass EXTRA_BUILD_ARGS="--debug":
make build-from-source C2PA_RS_PATH=$C2PA_RS_PATH EXTRA_BUILD_ARGS="--debug"
On macOS this produces a universal (arm64+x86_64) library by default, which requires both Rust targets:
rustup target add aarch64-apple-darwin x86_64-apple-darwin
To build a single-architecture library instead, set C2PA_LIBS_PLATFORM to a specific platform (for example aarch64-apple-darwin).
See the examples directory for some helpful examples:
examples/read.py shows how to read and verify an asset with a C2PA manifest.examples/sign.py shows how to sign and verify an asset with a C2PA manifest.examples/training.py demonstrates how to add a "Do Not Train" assertion to an asset and verify it.Documentation is published at github.io/c2pa-python/api/c2pa.
To build documentation locally, refer to this section in Contributing to the project.
Contributions are welcome! For more information, see Contributing to the project.
This project is licensed under the Apache License 2.0 and the MIT License. See the LICENSE-MIT and LICENSE-APACHE files for details.
201 followers · starred Jun 2025
15 followers · starred Dec 2024
19 followers · starred Jan 2025