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

Uploaded Python 3Windows ARM64

c2pa_python-0.37.4-py3-none-win_amd64.whl (86.3 MB view details)

Uploaded Python 3Windows x86-64

c2pa_python-0.37.4-py3-none-manylinux_2_28_x86_64.whl (14.6 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

c2pa_python-0.37.4-py3-none-manylinux_2_28_aarch64.whl (14.0 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

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

Uploaded Python 3macOS 10.9+ x86-64

c2pa_python-0.37.4-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.4.tar.gz.

File metadata

  • Download URL: c2pa_python-0.37.4.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.4.tar.gz
Algorithm Hash digest
SHA256 6aebfe6f669077d0662dcd9ad3612c40baf888ae22d2f4866d383a9f7dd46aee
MD5 aa2b4accc645ec1e956e54ca06f9dfdc
BLAKE2b-256 456c0e28502553bc32dc98f38a5415e20fa444e15e19ee7d17c8992cc8b23a28

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: c2pa_python-0.37.4-py3-none-win_arm64.whl
  • Upload date:
  • Size: 84.0 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.4-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 e183af9a6d511352cc427bed22611ea1b9dd1dd13620ec5555fb6c12643e6779
MD5 4ea4764422ea54d1536ae5bc0b09fcb4
BLAKE2b-256 19b6f933ea182270f8285c66181a420a8fbcfa8a83ba590f265dd5dc864e3c26

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: c2pa_python-0.37.4-py3-none-win_amd64.whl
  • Upload date:
  • Size: 86.3 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.4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 4133e8e99059eeb8be0023fcb01aea17a588fe23911458813d6dc451d6eff712
MD5 64f9a2b3c62fbf5cff314a9e315fb95a
BLAKE2b-256 56ef575cfa3f60be714056fa1e6118375b92dbc252c3a63e0d37893a521f62e5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.4-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8e2b1b214ea4e885178e1bd6c330d2c4c0c0d3aaa9cdb3bc28f7e7a7144ee5c0
MD5 275ac22036612bde4576f44d14d82348
BLAKE2b-256 7972be5e4db496a4c52134970ffcd14bd557c7c25c6b9fa6f55166c08776a80f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.4-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 baa39c2befedcb1c45c0cb439a3b2b4f0c428ab3126e56c02b59a2e3700212f9
MD5 30e0062f9fc2643a57027a0db9782c39
BLAKE2b-256 73f24ba5294e9f32d97bb79ae8ea6ca0c9401c36e4e783fef3dcf1ebe6099830

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.4-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 243260fdd577549185175daaf9fdb4f30c8e940aaaf555b34c3579c6b4549c6c
MD5 748f359cb5edb2c59705dd4c38ed89d5
BLAKE2b-256 a7797f9c670d644eb1681cf304fc22d5b31ea26cf9b9bece37a2ca4b1c5cd624

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.4-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 839123d8854802848695ce24c7dd56661be56fbb815818de19f0d6a6d8d2bc16
MD5 4610047b8e270240c4545aff46c4eb57
BLAKE2b-256 d222199a897c0b526fec6c109c947db6c2010da70b782841e9a3f6c72af026de

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.4-py3-none-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 d2814c7d9c2759a7dec6404779aead36104fe807886ecf6c6cbd2af26c2ab3f0
MD5 aabaeac83c902d09cf8c0a6b6eb7c783
BLAKE2b-256 44b63b8041a3d163168489d1458e63c56cb7a782d36298520f8eac83b7da928c

See more details on using hashes here.

Provenance

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