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

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

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

Uploaded Python 3macOS 10.9+ x86-64

c2pa_python-0.35.1-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.1.tar.gz.

File metadata

  • Download URL: c2pa_python-0.35.1.tar.gz
  • Upload date:
  • Size: 86.7 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.1.tar.gz
Algorithm Hash digest
SHA256 4d209810c25b921d002abca1dd2807cb9fc49b070c1839d80b3de1830e0a97b1
MD5 a27e10d20f4b3be3a1173399d3179a2a
BLAKE2b-256 748f2d253e6bfc693a11fb81fb1bc5a60fbe755be53cd680d37f05ac805aadc9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: c2pa_python-0.35.1-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.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 47fc05761ed8aee97d0ce811755c6d32bf428917437ec6690b4df3300d33f591
MD5 d29ed92a78f6f5e638cc029554e91b86
BLAKE2b-256 4376810ea55bcec87ffa8df2c1c2c208d03afb88bcab555407b729cd9255dde2

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: c2pa_python-0.35.1-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.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c3fd0e7d336782ca049a054a9fc5d7677420ecd78c5a754a3af4d20ede562ac4
MD5 5855927201aa7468ee7757ba3ac9f77c
BLAKE2b-256 82b515ca758e19f76e603581e4e134fc4d1b8aa62427e471915ef475902d054d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.35.1-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6c0d02175b8552906da820ca90b4b0e8375e84d806fe40273addb3192d296b49
MD5 be803193fd980aa07eabeb15887220bb
BLAKE2b-256 f34f111b6231d493bb1ad38e7a611a6655908b3fe5a03a3f67c0dd1569bc4f5d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.35.1-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5cafcae62739fcb959d08c32efedead8f9155630118c92f60130109129cf00eb
MD5 5d92055946410c70eb0a7e4a3e7b4fb4
BLAKE2b-256 e124189214e05944a9259054f657838e342a745bcc6763c8a868b065041169d4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.35.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d9fecaa1e1a071083a9aa70ae90540e6c72fb4fb9b7fdc7427d11f7737b1df95
MD5 d32dad95eb0e654576f4e7c2c26cdae4
BLAKE2b-256 10722eb482856b4f7442bd9ab7a2d02cc8ce9452d589fbaab734d8738eb7055f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.35.1-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3fc1ce371822c9d516dc3073845f0e746ecd31196141612ae074250eecf0ed50
MD5 dd85e8328b3a88446b8d94652e0f90a4
BLAKE2b-256 f998f7b9d3bcc4e6832a9cd8be2b9f3f7fb05f1324cc42bbdfc3a0c23a4e1231

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for c2pa_python-0.35.1-py3-none-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 65e06973c4b63ec145b8abfea9e0de8ab0f15419f98621b5208481134e9baedb
MD5 7d968231630f3b5aadd9127555fb6e56
BLAKE2b-256 8188a117c2ee0b999c1bc59ade6675473d8c7027410ecf1acb2968923edc46ab

See more details on using hashes here.

Provenance

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