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

Uploaded Python 3Windows ARM64

c2pa_python-0.35.2-py3-none-win_amd64.whl (89.6 MB view details)

Uploaded Python 3Windows x86-64

c2pa_python-0.35.2-py3-none-manylinux_2_28_x86_64.whl (15.4 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

c2pa_python-0.35.2-py3-none-manylinux_2_28_aarch64.whl (14.8 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

c2pa_python-0.35.2-py3-none-macosx_11_0_arm64.whl (14.5 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

c2pa_python-0.35.2-py3-none-macosx_10_9_x86_64.whl (14.9 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

c2pa_python-0.35.2-py3-none-macosx_10_9_universal2.whl (16.5 MB view details)

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

File details

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

File metadata

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

File hashes

Hashes for c2pa_python-0.35.2.tar.gz
Algorithm Hash digest
SHA256 3125817571fd189cc02cb1397e2fcd15001d7eadc6fe3bb5055a71fa637bf87f
MD5 1535e85aa02a337fdb113b035f2e2012
BLAKE2b-256 2e783db94cda01b0bfc990032b337675b2e1e909332102321dbc6e0b2c0e4744

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: c2pa_python-0.35.2-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

Hashes for c2pa_python-0.35.2-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 4be6c28f4ae26e29b74365c992ffe10d95a49145d04b346fcec2ac3818fec587
MD5 074842c9a9ecc164a430084553086c23
BLAKE2b-256 4a5830a1c5c66eacdb5a19c711b66b20a68bd0b0e735f05426185fe18f8477a0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: c2pa_python-0.35.2-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

Hashes for c2pa_python-0.35.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 4f55e0d82dbc6b5e00768a2302efabd18addabe1ad056d3bc1b90601d622a7f3
MD5 1c1f2e65244b9450d5ecc2ec692e9f20
BLAKE2b-256 7edbe3e1cd9a44395fd0aed1952f5466d704850bf0a10780cf5ddaf93e4b762d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.35.2-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 80d60dd8c1f7bb98763e4c7ebb35f758a84530ba2427a9806a3520ccd11be737
MD5 32371aa0e2a5e09cc503114715ec35b3
BLAKE2b-256 965a9c0d5b271d45698d135db387dc6afc71568fb5108f3dd2ccf8d900344560

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.35.2-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 83653562603950d47cbb3e6791971279e993acbb65ae0753cfec6d40b76f60bb
MD5 08ac5709b4dd5fdd27c7b51e3d442920
BLAKE2b-256 80cefc7707d82c0fb5f89848d699ac211f93d9b64dc5443936c0555b74b2042c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.35.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ae726378a71d68b0bf726fd5a1c7678fe7ebb6f26822cadf093421288a7ce4c8
MD5 9c4b7ba003abcae86b6d2417ec80de56
BLAKE2b-256 dd961375fdda2e022d06387d5d76fe397e724108ca6eb672a01f1c4b1e690f49

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.35.2-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d99208db6170afbc18beb84ef1771983e9205ed4192528d6ecb4635d4291cb2f
MD5 f88a4ca9aa70873643f8f406a6b1f3e0
BLAKE2b-256 b0e2be68e3547019fba93172572c6d2a9e535e4d359e529a058244f2017daade

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.35.2-py3-none-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 0a4881bd76df981989ba1cae9b53d6b60b2240b821a71b81027b4daa001f7157
MD5 4b0833f85ee7c022326f82346499df2d
BLAKE2b-256 9bd25a9ee6c59593f326dedbb13b0c1d470be66304f12c679f9e22950d45ebb2

See more details on using hashes here.

Provenance

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