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.2.tar.gz (94.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.2-py3-none-win_arm64.whl (85.0 MB view details)

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

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

Uploaded Python 3macOS 10.9+ x86-64

c2pa_python-0.37.2-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.2.tar.gz.

File metadata

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

File hashes

Hashes for c2pa_python-0.37.2.tar.gz
Algorithm Hash digest
SHA256 a076f539612157cd0f4b448085581bfd93a92a93dcd1e6a49329973817aed4ab
MD5 175f4650e649d15dff1a06c8a1ab94b0
BLAKE2b-256 9a975f432ad0c570f6d408d42b21fa977ecc9157098b108b4a3ce54453a67b3b

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for c2pa_python-0.37.2-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 67b904cdc225fbd828bddb3202b00cd93920661b6646f21b7b30247abe1e25bd
MD5 add20e5f3fe2742f2d323a448ec3c746
BLAKE2b-256 2627d665c0875a48b45ba937e9c38a693969bcb7594d68c719a834d66cb37c10

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: c2pa_python-0.37.2-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/6.1.0 CPython/3.13.14

File hashes

Hashes for c2pa_python-0.37.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 6ed91c19ad5e70bcc30000a578a254cfcc334f19c6251744b05972f87f2901d5
MD5 dcbd27c1279161bba443fdecd05045c9
BLAKE2b-256 1c9929b9e62fece34eded4eab5d9b0779cf531393180995f35b37f167d3ef11d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.2-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0ccda18b76cf82908686eb899fb420272753f8a1c263ac98c858ea27d2ee92c5
MD5 99d0c2f16f5457b1683209819c76f401
BLAKE2b-256 c11721039eec70c5c8c2541c114a3c5e6496780a7234c72fc862ba2bf5f3e856

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.2-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f5cacd1902b22a625e3faca59f761879d29fc3d1bd08503898edc86c9cde48ad
MD5 9e59a4b66632dbd9b7e7e8e0dbe3ec37
BLAKE2b-256 f2b805249650fc9b2a3e77fea055a7673767e62a6b31ab58f928a7f2c404651a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ee2e044072875bc413deb24a1dceaae1dd666224c777605a2921f64a8eabe46
MD5 f1c95776911ab91febf9d0e2c3cd39b2
BLAKE2b-256 5d69e9809ef4bdb30e77fe789c9f98f6e12a5ccdffad76f2992c57e2447b76c2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.2-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e191a8d28823392d70c61beafc0fc9186cf6081f82575e1c8130fd3d5c119143
MD5 3b5fa1d320c614b4be1144aa9dbff17f
BLAKE2b-256 e6f98288785b70541fc50bb4102898c88c215ff11bd3a6a1d724e5b9999c0c85

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.2-py3-none-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 a312de48c997f499cea5d1c74fc8d1835a8e952758bb99c95bb1dd53e2eb1773
MD5 2792af35b7f758ffdca63b040c711300
BLAKE2b-256 0f1a5fb31c15b474e7ea8b7dfefa6fbff31994657e40668df9abedbadd784b76

See more details on using hashes here.

Provenance

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