Python bindings for the C2PA Content Authenticity Initiative (CAI) library
Project description
C2PA Python library
The c2pa-python repository provides a Python library that can:
- Read and validate C2PA manifest data from media files in supported formats.
- Create and sign manifest data, and attach it to media files in supported formats.
Features:
- Create and sign C2PA manifests using various signing algorithms.
- Verify C2PA manifests and extract metadata.
- Add assertions and ingredients to assets.
- Examples and unit tests to demonstrate usage.
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:
- Using the Python library
- Supported formats
- Configuring the SDK using
ContextandSettings - Using Builder intents to ensure spec-compliant manifests
- Using working stores and archvies
- Selectively constructing manifests by filtering actions and ingredients
- Diagram of public classes in the Python library and their relationships
- Release notes
Prerequisites
This library requires Python version 3.10+.
Package installation
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
Building from local c2pa-rs sources
Using a virtual environment with local builds
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
Build steps
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:
- A local clone of c2pa-rs.
- The Rust toolchain (
cargoon yourPATH).
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. The release profile is used by default; 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"
Note on targets for macOS
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).
Examples
See the examples directory for some helpful examples:
examples/read.pyshows how to read and verify an asset with a C2PA manifest.examples/sign.pyshows how to sign and verify an asset with a C2PA manifest.examples/training.pydemonstrates how to add a "Do Not Train" assertion to an asset and verify it.
API reference documentation
Documentation is published at github.io/c2pa-python/api/c2pa.
To build documentation locally, refer to this section in Contributing to the project.
Contributing
Contributions are welcome! For more information, see Contributing to the project.
License
This project is licensed under the Apache License 2.0 and the MIT License. See the LICENSE-MIT and LICENSE-APACHE files for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file c2pa_python-0.34.0.tar.gz.
File metadata
- Download URL: c2pa_python-0.34.0.tar.gz
- Upload date:
- Size: 82.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54445f4ba08832a5856f02188bf62779d44ee5ad0e62312e9f772f5bf244420f
|
|
| MD5 |
169aecdbe54d29c64b05b0f69995547f
|
|
| BLAKE2b-256 |
41446ef4c0a391faa5fb935284fc016d48f24db6930ba3b1735d90a0a64db1eb
|
Provenance
The following attestation bundles were made for c2pa_python-0.34.0.tar.gz:
Publisher:
build.yml on contentauth/c2pa-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
c2pa_python-0.34.0.tar.gz -
Subject digest:
54445f4ba08832a5856f02188bf62779d44ee5ad0e62312e9f772f5bf244420f - Sigstore transparency entry: 1803643611
- Sigstore integration time:
-
Permalink:
contentauth/c2pa-python@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Branch / Tag:
refs/tags/v0.34.0 - Owner: https://github.com/contentauth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Trigger Event:
push
-
Statement type:
File details
Details for the file c2pa_python-0.34.0-py3-none-win_arm64.whl.
File metadata
- Download URL: c2pa_python-0.34.0-py3-none-win_arm64.whl
- Upload date:
- Size: 87.1 MB
- Tags: Python 3, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6927c789b50316232fa94dbc1dc2c812aa247a49d97f47fde9bbe9f69f203806
|
|
| MD5 |
69d23faec484640d188dd74291993a36
|
|
| BLAKE2b-256 |
ea4a298008a78633b1de5947f4b1dc55704637805790b240b718eacf64e390ac
|
Provenance
The following attestation bundles were made for c2pa_python-0.34.0-py3-none-win_arm64.whl:
Publisher:
build.yml on contentauth/c2pa-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
c2pa_python-0.34.0-py3-none-win_arm64.whl -
Subject digest:
6927c789b50316232fa94dbc1dc2c812aa247a49d97f47fde9bbe9f69f203806 - Sigstore transparency entry: 1803644223
- Sigstore integration time:
-
Permalink:
contentauth/c2pa-python@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Branch / Tag:
refs/tags/v0.34.0 - Owner: https://github.com/contentauth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Trigger Event:
push
-
Statement type:
File details
Details for the file c2pa_python-0.34.0-py3-none-win_amd64.whl.
File metadata
- Download URL: c2pa_python-0.34.0-py3-none-win_amd64.whl
- Upload date:
- Size: 89.6 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
868b5a33d39151902d84065102da2d565e9f3b06ba99c8904fc2753a5c4aaf6b
|
|
| MD5 |
34dac3e98d283aaf2ba73aa5435466a6
|
|
| BLAKE2b-256 |
f6c8228fa5edd8c71805dd921bff8a80bfde67aad986f24cd6cd3242f9980f00
|
Provenance
The following attestation bundles were made for c2pa_python-0.34.0-py3-none-win_amd64.whl:
Publisher:
build.yml on contentauth/c2pa-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
c2pa_python-0.34.0-py3-none-win_amd64.whl -
Subject digest:
868b5a33d39151902d84065102da2d565e9f3b06ba99c8904fc2753a5c4aaf6b - Sigstore transparency entry: 1803644028
- Sigstore integration time:
-
Permalink:
contentauth/c2pa-python@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Branch / Tag:
refs/tags/v0.34.0 - Owner: https://github.com/contentauth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Trigger Event:
push
-
Statement type:
File details
Details for the file c2pa_python-0.34.0-py3-none-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: c2pa_python-0.34.0-py3-none-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 15.4 MB
- Tags: Python 3, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c0f9416a6759b45627a6de9cc2767fc2a871e17bf9dcdf0b2880b8d8c1e7f34
|
|
| MD5 |
e3ca158fbd6129842e6dbf6a80114452
|
|
| BLAKE2b-256 |
ecc45949d072bf56087bf07ef0e47f8a32f18fc67f66ab2a92846870266316ca
|
Provenance
The following attestation bundles were made for c2pa_python-0.34.0-py3-none-manylinux_2_28_x86_64.whl:
Publisher:
build.yml on contentauth/c2pa-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
c2pa_python-0.34.0-py3-none-manylinux_2_28_x86_64.whl -
Subject digest:
5c0f9416a6759b45627a6de9cc2767fc2a871e17bf9dcdf0b2880b8d8c1e7f34 - Sigstore transparency entry: 1803644301
- Sigstore integration time:
-
Permalink:
contentauth/c2pa-python@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Branch / Tag:
refs/tags/v0.34.0 - Owner: https://github.com/contentauth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Trigger Event:
push
-
Statement type:
File details
Details for the file c2pa_python-0.34.0-py3-none-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: c2pa_python-0.34.0-py3-none-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 14.8 MB
- Tags: Python 3, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51eaf3f8a15bd6c4a80f493f7ca003ff8dca4e98a231fb809149a304f78b7519
|
|
| MD5 |
816e1f8a6d8e1c31630b00fd995b657e
|
|
| BLAKE2b-256 |
d9afe79e2ce1ee1f469687644a24306a0e592d42f1299e69244325f40dada80f
|
Provenance
The following attestation bundles were made for c2pa_python-0.34.0-py3-none-manylinux_2_28_aarch64.whl:
Publisher:
build.yml on contentauth/c2pa-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
c2pa_python-0.34.0-py3-none-manylinux_2_28_aarch64.whl -
Subject digest:
51eaf3f8a15bd6c4a80f493f7ca003ff8dca4e98a231fb809149a304f78b7519 - Sigstore transparency entry: 1803643763
- Sigstore integration time:
-
Permalink:
contentauth/c2pa-python@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Branch / Tag:
refs/tags/v0.34.0 - Owner: https://github.com/contentauth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Trigger Event:
push
-
Statement type:
File details
Details for the file c2pa_python-0.34.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: c2pa_python-0.34.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 14.5 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
241571ad18badb5a7a6e2e25ded2c5ac64a4d5ecd7ac432044fb02b25bacb4cd
|
|
| MD5 |
32bd4b12c483dfd3144a30e7f8174d3c
|
|
| BLAKE2b-256 |
eb77eb80f3f195bea7817ec8884783dfef6b9218d2527f1a0af15c5d396e8a5e
|
Provenance
The following attestation bundles were made for c2pa_python-0.34.0-py3-none-macosx_11_0_arm64.whl:
Publisher:
build.yml on contentauth/c2pa-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
c2pa_python-0.34.0-py3-none-macosx_11_0_arm64.whl -
Subject digest:
241571ad18badb5a7a6e2e25ded2c5ac64a4d5ecd7ac432044fb02b25bacb4cd - Sigstore transparency entry: 1803643898
- Sigstore integration time:
-
Permalink:
contentauth/c2pa-python@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Branch / Tag:
refs/tags/v0.34.0 - Owner: https://github.com/contentauth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Trigger Event:
push
-
Statement type:
File details
Details for the file c2pa_python-0.34.0-py3-none-macosx_10_9_x86_64.whl.
File metadata
- Download URL: c2pa_python-0.34.0-py3-none-macosx_10_9_x86_64.whl
- Upload date:
- Size: 14.9 MB
- Tags: Python 3, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fc67731752b8c56329c114c3c30747648f8d97327523c84cec4ccfb5a907215
|
|
| MD5 |
d2e08902dca35e3ba28e52c071e7867b
|
|
| BLAKE2b-256 |
8a80811fc97e635dbe6578091e86fbe31dd5cd5e55de1141642e815b71446613
|
Provenance
The following attestation bundles were made for c2pa_python-0.34.0-py3-none-macosx_10_9_x86_64.whl:
Publisher:
build.yml on contentauth/c2pa-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
c2pa_python-0.34.0-py3-none-macosx_10_9_x86_64.whl -
Subject digest:
7fc67731752b8c56329c114c3c30747648f8d97327523c84cec4ccfb5a907215 - Sigstore transparency entry: 1803644108
- Sigstore integration time:
-
Permalink:
contentauth/c2pa-python@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Branch / Tag:
refs/tags/v0.34.0 - Owner: https://github.com/contentauth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Trigger Event:
push
-
Statement type:
File details
Details for the file c2pa_python-0.34.0-py3-none-macosx_10_9_universal2.whl.
File metadata
- Download URL: c2pa_python-0.34.0-py3-none-macosx_10_9_universal2.whl
- Upload date:
- Size: 16.5 MB
- Tags: Python 3, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b8c2277f618c6a222f23317d5a07f1457062eb50aaf5769b07fa732855c52be
|
|
| MD5 |
8c173390975dcbf952325dc8cdb8e31a
|
|
| BLAKE2b-256 |
4aa58fb158639c2ffddd2359f3b68cc4ecfaaf0f9ace9b08001df7437b6fcba1
|
Provenance
The following attestation bundles were made for c2pa_python-0.34.0-py3-none-macosx_10_9_universal2.whl:
Publisher:
build.yml on contentauth/c2pa-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
c2pa_python-0.34.0-py3-none-macosx_10_9_universal2.whl -
Subject digest:
6b8c2277f618c6a222f23317d5a07f1457062eb50aaf5769b07fa732855c52be - Sigstore transparency entry: 1803644165
- Sigstore integration time:
-
Permalink:
contentauth/c2pa-python@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Branch / Tag:
refs/tags/v0.34.0 - Owner: https://github.com/contentauth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@12f3ee9de2301e7f510edaff7f29087d9d36580b -
Trigger Event:
push
-
Statement type: