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

Uploaded Python 3Windows ARM64

c2pa_python-0.36.0-py3-none-win_amd64.whl (90.0 MB view details)

Uploaded Python 3Windows x86-64

c2pa_python-0.36.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.36.0-py3-none-manylinux_2_28_aarch64.whl (14.7 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

c2pa_python-0.36.0-py3-none-macosx_11_0_arm64.whl (14.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

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

Uploaded Python 3macOS 10.9+ x86-64

c2pa_python-0.36.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.36.0.tar.gz.

File metadata

  • Download URL: c2pa_python-0.36.0.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.36.0.tar.gz
Algorithm Hash digest
SHA256 39fc2202fa5bdfef3eeee30d5ee4b9b0f2060974b01d7814eef79b21fd761284
MD5 53507e031ca63edd2eb6f241ef1e2c40
BLAKE2b-256 77e898cd17ec067226df9fee06a5173a940d44ede0f65a3a077feedea56dc3b0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: c2pa_python-0.36.0-py3-none-win_arm64.whl
  • Upload date:
  • Size: 87.5 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.36.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 eb7a2d2060ca35d0cb9c161ef50353fe4a0dc91d6e9f7ab4a7d45b19ff24f40c
MD5 b88c070279f572b59e11224d05daa85a
BLAKE2b-256 93a54b723ffd14fad15b247b5e6cc2ba2ca0d5a5c6193a79a2cb3a0e6f4be462

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: c2pa_python-0.36.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 90.0 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.36.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 8939fd8e94b444ecb7ba09108dabc4e5dc248db3aa945f8d5f0a2c3b4f6b5775
MD5 f848039c1eef466af85cef9489765ad5
BLAKE2b-256 1b19c06540198d0f70bc6339d17727b8c64da274c6c60d24b499864146f0f03d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.36.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f059696aab2c7bca1a200ec533458cf0f34ba76b19ddf88656fbeee627ac2b12
MD5 6f216dcfabddf6a6a5d88bc66b1ea5f6
BLAKE2b-256 06276f8c4717ff8838a85a8f6d35336f5ee908c39bba2e377345ed83a95828f9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.36.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d9b9b6680490f4cddf08d6f22d91d6e08c178f2a9d07222da6af0fbbba162e99
MD5 b8b3be0880090f9f4f82c4f760a3106d
BLAKE2b-256 242b6f1c44fef1d76fd1be54c8c7512b149371a6783e3a229418eeb7e13c4e6e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.36.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e45aa43b6bb477e45122572372232185a71012d4bde32250ddf64a1068e8c26f
MD5 d342725c29110efbbb2c8ee4ae20e347
BLAKE2b-256 8a83b6f5a12a6eb87ad97cfadaa5662203c028e1fee737bcd0a1973c9d568576

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.36.0-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e542466982ac737d96cc43d25204885a078eace1be63c358668791463d81c208
MD5 b8aa786c5530b8062c15adf025d70fe0
BLAKE2b-256 9ecbd5743596f073a10e4bac566ddf8b2c579a917605f66dac64d0d348ddb2e7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.36.0-py3-none-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 e14c87144064220a69c9c463110c164cb0344e4fdd3bfa6eeb9d1ed12cc5becb
MD5 8ee5535213367bba4861f72b5a33eae5
BLAKE2b-256 fe35bc337a6f6d830f3a1d6ad8046e2f3857c34b071bd0f3914ebcf62d289300

See more details on using hashes here.

Provenance

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