Skip to main content

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.

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.

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

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

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

Uploaded Python 3macOS 10.9+ x86-64

c2pa_python-0.37.1-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.1.tar.gz.

File metadata

  • Download URL: c2pa_python-0.37.1.tar.gz
  • Upload date:
  • Size: 87.4 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.1.tar.gz
Algorithm Hash digest
SHA256 c16f5ca7032b5d0f0dda64ac349ac2db5193c47558bdf572edc82d779745a5c8
MD5 ad402c8873cfb383fab31c854afe8b6b
BLAKE2b-256 23efd1b3f0648d3e467d9f9ebfbfcbfc04b1df3e67563ae1cafe55ade35af1e9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: c2pa_python-0.37.1-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.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 6cef40f808aee6cea919d4a29f4004e1f26735d08638b155853bf5f28394bf56
MD5 7aef511dbcdd7249251935dcdd8d5a6c
BLAKE2b-256 21f91815d87c27e24d8cab48264ea2ec7be74a3d6f41d663a898aa64a5da497e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: c2pa_python-0.37.1-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.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 63de1dde03e0f0df0dd18f814c9bc3b4b266f0eaa38418d212c5cb9d1abe1943
MD5 02972b4991c584d15e4f14c19d1b7acc
BLAKE2b-256 4bedb80bd851bc320ff007e8dae73a316da6fab50148ea59ac23a2f1c5a2c118

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.1-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ea64169c2670522483d7f00ed4780012489a3b72e119a70a05006f4f4fe1f819
MD5 bc02f7878a5eb81820cc3d3c3e22905d
BLAKE2b-256 d73da7641407f74761570ad80ee91b25a8ae4226bfc56176b5059a69c4eaa67f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.1-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3d337cf680370ee80a538e5e91fd347452dcecb8eabbf246f6da3526f6d25d48
MD5 f32eb39baa608141692ab3617137480e
BLAKE2b-256 dcfb99bb57170230cbebf5c22eefb741b9289a47cd3ad0de1d3682d12b0d9ed5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 66a9d32ca71839b271116a44990907b2b9f94198e49092d480c383fbf253943c
MD5 c7ac4cb2319ea98c23c47a3cbcb71c85
BLAKE2b-256 b878be90f0e47b0459d3c40a176a55e7ce25d0a05c7f7d2e22ef6dbb59b13dad

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.1-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ee37102318decc4079affacef0031ad25201b2bb447d64c646a35e4e656cdde8
MD5 13aec6e67bc5ff7903fee4763f95681d
BLAKE2b-256 d6a4f40dd7c59c9ecb23546dea6af9c60b016fd24929c525cd241b4445f3f59d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.1-py3-none-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 4c7a592de2df9051bf18bede96b1c1e601b12f3a9cb53c762f0f343894474456
MD5 031dcf0291de8f9944f9cae81551de5e
BLAKE2b-256 0370e1b7296e84324c1541ba4785c9a9273943a347337802922c811dab087d74

See more details on using hashes here.

Provenance

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