Skip to main content

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.

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:

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.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.

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

c2pa_python-0.37.3.tar.gz (112.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

c2pa_python-0.37.3-py3-none-win_arm64.whl (85.0 MB view details)

Uploaded Python 3Windows ARM64

c2pa_python-0.37.3-py3-none-win_amd64.whl (87.5 MB view details)

Uploaded Python 3Windows x86-64

c2pa_python-0.37.3-py3-none-manylinux_2_28_x86_64.whl (14.7 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

c2pa_python-0.37.3-py3-none-manylinux_2_28_aarch64.whl (14.0 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

c2pa_python-0.37.3-py3-none-macosx_11_0_arm64.whl (13.8 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

c2pa_python-0.37.3-py3-none-macosx_10_9_x86_64.whl (14.2 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

c2pa_python-0.37.3-py3-none-macosx_10_9_universal2.whl (16.3 MB view details)

Uploaded Python 3macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file c2pa_python-0.37.3.tar.gz.

File metadata

  • Download URL: c2pa_python-0.37.3.tar.gz
  • Upload date:
  • Size: 112.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for c2pa_python-0.37.3.tar.gz
Algorithm Hash digest
SHA256 170b5b3fde68e17fe50787ff6cb09adcdf0bae740875d8303b4d75955a166a58
MD5 d413b382733fc5f9f1e8620e470ff79a
BLAKE2b-256 14a837366eefd5eeeadd71d973f3207ed9a20238d929acb3fd113f41ca144782

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.3.tar.gz:

Publisher: build.yml on contentauth/c2pa-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file c2pa_python-0.37.3-py3-none-win_arm64.whl.

File metadata

  • Download URL: c2pa_python-0.37.3-py3-none-win_arm64.whl
  • Upload date:
  • Size: 85.0 MB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for c2pa_python-0.37.3-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 fdb1ac71067091f445f81b4edf02420cbbd6288761ddce87ccecedabde68e0ff
MD5 0a4379f319f1af4f33e4d565c3d5f796
BLAKE2b-256 2243907db13a30781643f2f7ac857bd969a184be23704a93d4757a515fe536cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.3-py3-none-win_arm64.whl:

Publisher: build.yml on contentauth/c2pa-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file c2pa_python-0.37.3-py3-none-win_amd64.whl.

File metadata

  • Download URL: c2pa_python-0.37.3-py3-none-win_amd64.whl
  • Upload date:
  • Size: 87.5 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for c2pa_python-0.37.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 0fc0e8d3447d3499f3851d7cb6b7bb60cb0400c724a2e2267136cce00028cb49
MD5 e909ba06ce27ee521595726197ceb6fe
BLAKE2b-256 ea72991771fc37d24b437831e08b2813c38af903ead9827b085bdbdf5018a26f

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.3-py3-none-win_amd64.whl:

Publisher: build.yml on contentauth/c2pa-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file c2pa_python-0.37.3-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for c2pa_python-0.37.3-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b71887d0c178f9e804f1d8d7d381f1012dcfda403291171611a6d8ec59de1074
MD5 21ee61565ff11954c309768be9ce0c09
BLAKE2b-256 5cd3d4ce3ee175e39e492c72e3cf402c1d5c2b96651d4168dbc5adc5b5264ecf

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.3-py3-none-manylinux_2_28_x86_64.whl:

Publisher: build.yml on contentauth/c2pa-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file c2pa_python-0.37.3-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for c2pa_python-0.37.3-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c12f17c1a72f76f73408dd6f4c637d44e9f67987a4d3927bf53536276a19e5b8
MD5 a712399b511b8b51fe603b6e896b7fe9
BLAKE2b-256 e87c4284a8c0036c5ca21e837a7fec99ed9f0990138c801e14edf85ddcf56b3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.3-py3-none-manylinux_2_28_aarch64.whl:

Publisher: build.yml on contentauth/c2pa-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file c2pa_python-0.37.3-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for c2pa_python-0.37.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8faf08d5033ab0debd2f58d7fb941488c03050d66a9f9ef02e1b72fb5f7f4b06
MD5 d38394199d2da34f8473e5eb5054ad74
BLAKE2b-256 acc0fee18595d8234b383795557da02840689acbf43c01d165068f17e08851f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.3-py3-none-macosx_11_0_arm64.whl:

Publisher: build.yml on contentauth/c2pa-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file c2pa_python-0.37.3-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for c2pa_python-0.37.3-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b494526749b7f8221ad3e45cc1e3d5541658c6cabdbb58e3307c767668f5c21d
MD5 0f34010a7abc683764de8cd323974ce5
BLAKE2b-256 9354ed444f0737b5cd3dd01af423590d1c79c9ece150bddc0489ca7e5e84e96b

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.3-py3-none-macosx_10_9_x86_64.whl:

Publisher: build.yml on contentauth/c2pa-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file c2pa_python-0.37.3-py3-none-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for c2pa_python-0.37.3-py3-none-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 9498037ea3aa3037dfc1537189964671a2cbb92b6b6bbb68e16b4e4d1f6b7ed6
MD5 34da69b783bbcbc9f58357d183eaf84e
BLAKE2b-256 9b0944a02a1e33336f859468461bab3a72e232140bf9bdb62816940a2f8f1c4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.3-py3-none-macosx_10_9_universal2.whl:

Publisher: build.yml on contentauth/c2pa-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page