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

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.5.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.5-py3-none-win_arm64.whl (83.9 MB view details)

Uploaded Python 3Windows ARM64

c2pa_python-0.37.5-py3-none-win_amd64.whl (86.4 MB view details)

Uploaded Python 3Windows x86-64

c2pa_python-0.37.5-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.5-py3-none-manylinux_2_28_aarch64.whl (14.0 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

c2pa_python-0.37.5-py3-none-macosx_10_9_x86_64.whl (14.1 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

c2pa_python-0.37.5-py3-none-macosx_10_9_universal2.whl (16.2 MB view details)

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

File details

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

File metadata

  • Download URL: c2pa_python-0.37.5.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.5.tar.gz
Algorithm Hash digest
SHA256 185cd00c18d8386a0c6c8c5af19434005406626545e6250e1273f4cc14389739
MD5 4c03fe6847a58ab7767e1a95441fbb53
BLAKE2b-256 f7ec416d05dc0cffc362f24cb33121aeddb621cfe5f06b239b0051aa25b28079

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.5.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.5-py3-none-win_arm64.whl.

File metadata

  • Download URL: c2pa_python-0.37.5-py3-none-win_arm64.whl
  • Upload date:
  • Size: 83.9 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.5-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 1ed2f1bd1d69e1ac243a9d769e5fa1047d5f9be3fed3206bb3c0a68c3c9e0bce
MD5 e25192e5fb35ce5f420400475d379775
BLAKE2b-256 396ff54775038b6a469951fe9899249ff3f8545421f64cc5e6a718af092f383d

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.5-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.5-py3-none-win_amd64.whl.

File metadata

  • Download URL: c2pa_python-0.37.5-py3-none-win_amd64.whl
  • Upload date:
  • Size: 86.4 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.5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c122680aa05ea12bbe061c69333c0137f4f2f8c7906ae06fec255db346d788b8
MD5 c42030ff85243cc2613da23b6b5ff63b
BLAKE2b-256 952f5c2ebd8baa36c4422f4827323a6a67c07ed57898f3500f689ab0d7b31435

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.5-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.5-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for c2pa_python-0.37.5-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 82bf2dcc5f184a40d7b65a5804b3e6251d52e6e65958cfbc0dc80321eac4bb33
MD5 049f926fe104ab13c9740c88aee9713e
BLAKE2b-256 5733e258809ad6ae1ee7c9af29117bd8addf87db9e0a0b53354ac668b2f2e4a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.5-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.5-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for c2pa_python-0.37.5-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8fc4ce81ae5449a65981ce10e33c91c33a85a10b3aed1124d580ad5ce15b1ea7
MD5 be1238c2b200a85966c79cef2ec11d36
BLAKE2b-256 a8f0f5291ba6f3bc778575af06d9a6630d841432b7cf8136ae57e8889b212d8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.5-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.5-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for c2pa_python-0.37.5-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 95e446663cd53d9292fd04afb84996c3be9a4aeea1ac076440d9a6c6477da921
MD5 2d610623681045c2e740c73eccaf9231
BLAKE2b-256 74501128ae57644c079c75dcfeeaf5b51e199246b17f745d42e9a929d224b199

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.5-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.5-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for c2pa_python-0.37.5-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 72a9b074f3fecf67fb1740003869fe17c2d664ab79e6fc0669d3a77dc01e6699
MD5 d478e866fb9a0e59cbe9e0d27fce24fc
BLAKE2b-256 f338bd924e7f829b156fcf967923d26918fd4cc3435860055ae8b1b46d97d982

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.5-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.5-py3-none-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for c2pa_python-0.37.5-py3-none-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 8f719bd53a08bb54a4e8b761825db426d153430199821a4fcac1c13efe26d309
MD5 3e68610ce61eb03011ef9edac48a3eca
BLAKE2b-256 e6f2344074f26373f3c596a98549b0a7755b1cf6036ed4a831ad74526ac33d80

See more details on using hashes here.

Provenance

The following attestation bundles were made for c2pa_python-0.37.5-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