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.6.tar.gz (113.0 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.6-py3-none-win_arm64.whl (83.4 MB view details)

Uploaded Python 3Windows ARM64

c2pa_python-0.37.6-py3-none-win_amd64.whl (85.9 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ ARM64

c2pa_python-0.37.6-py3-none-macosx_11_0_arm64.whl (13.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

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

Uploaded Python 3macOS 10.9+ x86-64

c2pa_python-0.37.6-py3-none-macosx_10_9_universal2.whl (16.1 MB view details)

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

File details

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

File metadata

  • Download URL: c2pa_python-0.37.6.tar.gz
  • Upload date:
  • Size: 113.0 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.6.tar.gz
Algorithm Hash digest
SHA256 c701f4065acdb1648c16082bb0a87cd04b3c000def220b81a3e2877dc5e3acc9
MD5 1b073e8f8dbfffb8377a18aecd617673
BLAKE2b-256 792a768b8824d590a8a919135df72106e1db72c8628e8c576f1e6a0df66dc640

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: c2pa_python-0.37.6-py3-none-win_arm64.whl
  • Upload date:
  • Size: 83.4 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.6-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 de38207eee4660fcb272acd5d5f06dbeb5ff38a7bc18b9634007bec26dbd3090
MD5 f8b6c67d2286ae43a08ae1b36932be8d
BLAKE2b-256 277b94ae52565260ab0f4455bd28c6d6edc784341fe8b4ae6eeb56d9fd34505d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: c2pa_python-0.37.6-py3-none-win_amd64.whl
  • Upload date:
  • Size: 85.9 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.6-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 1cb103460b9e33ef13ddfea5c390bb10ac33f4dae1183e89c5a2f08e0f7553a8
MD5 469d648030632bc25c4f5b60afa55940
BLAKE2b-256 84f8b5881aa906f2661ced5f1d54fc7371a1b830b5a63a28e57e8141891594d9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.6-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9bf86527fa58f49ca20b5bf31ab63e463f8a993786f2864924c232933789e673
MD5 c542c01617fceffb08ba55d10983f103
BLAKE2b-256 d3efe93afc27e0671d78070005619d12ad93ffc32caa5ec528521a29e424bd81

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.6-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6cf1607fa1204d5f7f2224aa1b6dcc8a5a6054db0fc5de6fa83e4fa200e7a1c4
MD5 5bc383338c380d675da71b2d5f5aba8a
BLAKE2b-256 2e62805ae4d4fd0055a4ace6ec33ca89cb30ac0ea34518049edd99075dbba4b6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.6-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 88617f1616e36d3176e6f8a57161932fcb7a7d3f9ec8d7b72f5240b76fde1f9c
MD5 28028639708dc89d73b9f04ccb613103
BLAKE2b-256 9795da01073014a55f9f617c105eeed43ee419506d9c0662e66c42a4c873f2eb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.6-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 35c39854ed27baf73d32991909e5abefdfe849c1555d2a0a6d5109a739557605
MD5 34171351c168297eca7083a9feea8772
BLAKE2b-256 72808eff954424e37cb51a97ab585900d2ce175c7c1d145f2feb2ffad2e926ca

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.37.6-py3-none-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 c97de862ba31643d75c52d69fd20367250011b7ccc965492ec6d36dc12139a0e
MD5 9381ecf643cd5734246727c57f23917d
BLAKE2b-256 4d68916cc7748091f7dfbc3e4ababea34a05c293bf638695d44e3f60ece19668

See more details on using hashes here.

Provenance

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