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.0.tar.gz (84.5 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.0-py3-none-win_arm64.whl (87.1 MB view details)

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

c2pa_python-0.35.0-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.0-py3-none-manylinux_2_28_aarch64.whl (14.8 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

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

Uploaded Python 3macOS 10.9+ x86-64

c2pa_python-0.35.0-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.0.tar.gz.

File metadata

  • Download URL: c2pa_python-0.35.0.tar.gz
  • Upload date:
  • Size: 84.5 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.0.tar.gz
Algorithm Hash digest
SHA256 ca7642f79c05bc60aa6083337c0a49096f9fe4a30251b1b046a52581ce94b0bf
MD5 257a66dd0aade624d70dc5984044f06e
BLAKE2b-256 439224b370b65017454b939692ea75d6032ef30ac45fb81b0098632d38aed8f2

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: c2pa_python-0.35.0-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.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 2cd216dec738ea26d254eac56b6adbc8dc5b44b16f38e285a11279fa26ee5738
MD5 29b4f0365eddac56202ccefa061dfc7e
BLAKE2b-256 65b25cbab6c22c96fcc3e58bc09edbed8d53c0f58bfd007934faf56e4e8a71c3

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: c2pa_python-0.35.0-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.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 7c469de85befcb8cc63fdfc09a7976b5e615e5156b7e485008a984375fffc3df
MD5 bfd674f110cc68f946c773795c559d87
BLAKE2b-256 0337b2984d594bde198b7577c80e9cb5e91ddaf60f2c909e48a37fc73afb2c88

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.35.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cc7254a38e7672d2649456ca2e1f8c7673a5c22b5b3af6c72e986cf558d0e7c0
MD5 3592965d30ebf904f55bf21dbb46c4ea
BLAKE2b-256 6e40af0a37ebf956bfb8505715c0e23034a3e2d5c27cdf5f4db8fa08bc3c459c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.35.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b85abdc9cf5d45c7f17c28f833f4194e008454e563c78902299187a6533127be
MD5 f7b8d55b70d16dcd3ed09ade8b9fceb7
BLAKE2b-256 f6f2e2768aa02dbe9925ebba2b646cb530415f3ec9cabfbfa2d058f40f455e78

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.35.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d797c430bfd89e2ea8bf7903f3b62aa57ba31967975b50a47c3e01e7781f937e
MD5 23b121051be87333bcfb35234aa0b754
BLAKE2b-256 971fe0b326d9e9c35bbba7a756d63e7026b36133d5fec516aa4582e99ed62a97

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.35.0-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f4f6abb30ac03c404f8451280dbfe2b9d4cc725e372b32cb0ace786a09f7eefc
MD5 f7e3df5ac370118d824061a7c7c8f854
BLAKE2b-256 2cd6e9d3159b44b55fb4553401589f2d3252652fd338a965153ae834ae1be93c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.35.0-py3-none-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 63936b67745a7dc27bb125acc71cd55b14002e24dfabe3233267c032584c7ac3
MD5 033523a62b3d639952692f862f6490f4
BLAKE2b-256 5e1711071fa4e17f1c6123c4b3e7c325fc6a38ca0b51fa3c9434aa90d7544f79

See more details on using hashes here.

Provenance

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