You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project provides a Python API for working with [C2PA](https://c2pa.org/) (Coalition for Content Provenance and Authenticity) manifests. It includes functionality for creating, signing, and verifying C2PA manifests, as well as working with assets and assertions.
3
+
The [c2pa-python](https://github.com/contentauth/c2pa-python) repository provides a Python library that can:
4
+
- Read and validate C2PA manifest data from media files in supported formats.
5
+
- Create and sign manifest data, and attach it to media files in supported formats.
4
6
5
-
## Features
7
+
Features:
6
8
7
9
- Create and sign C2PA manifests using various signing algorithms.
8
10
- Verify C2PA manifests and extract metadata.
9
11
- Add assertions and ingredients to assets.
10
12
- Examples and unit tests to demonstrate usage.
11
13
12
-
## Project Structure
14
+
## Prerequisites
13
15
14
-
```bash
15
-
.
16
-
├── .github/ # GitHub configuration files
17
-
├── artifacts/ # Platform-specific libraries for building (per subfolder)
├── requirements-dev.txt # Development dependencies
31
-
└── setup.py # Package setup script
32
-
```
16
+
This library requires Python version 3.10+.
33
17
34
18
## Package installation
35
19
36
-
The c2pa-python package is published to PyPI. You can install it from there by running:
20
+
Install the c2pa-python package from PyPI by running:
37
21
38
22
```bash
39
23
pip install c2pa-python
40
24
```
41
25
42
-
To use the module in your Python code, import like this:
26
+
To use the module in Python code, import it like this:
43
27
44
28
```python
45
29
import c2pa
46
30
```
47
31
48
32
## Examples
49
33
50
-
### Adding a "Do Not Train" Assertion
51
-
52
-
The `examples/training.py` script demonstrates how to add a "Do Not Train" assertion to an asset and verify it.
53
-
54
-
### Signing and Verifying Assets
55
-
56
-
The `examples/sign.py` script shows how to sign an asset with a C2PA manifest and verify it.
57
-
58
-
## Development Setup
59
-
60
-
1. Create and activate a virtual environment with native dependencies:
61
-
62
-
```bash
63
-
# Create virtual environment
64
-
python -m venv .venv
65
-
66
-
# Activate virtual environment
67
-
# On Windows:
68
-
.venv\Scripts\activate
69
-
# On macOS/Linux:
70
-
source .venv/bin/activate
71
-
72
-
# load project dependencies
73
-
pip install -r requirements.txt
74
-
pip install -r requirements-dev.txt
75
-
76
-
# download library artifacts for the current version you want, eg v0.55.0
77
-
python scripts/download_artifacts.py c2pa-v0.55.0
78
-
```
79
-
80
-
2. Install the package in development mode:
81
-
82
-
```bash
83
-
pip install -e .
84
-
```
85
-
86
-
This will:
87
-
88
-
- Copy the appropriate libraries for your platform from `artifacts/` to `src/c2pa/libs/`
89
-
- Install the package in development mode, allowing you to make changes to the Python code without reinstalling
90
-
91
-
## Building Wheels
92
-
93
-
To build wheels for all platforms that have libraries in the `artifacts/` directory:
94
-
95
-
```bash
96
-
python setup.py bdist_wheel
97
-
```
98
-
99
-
You can use `twine` to verify the wheels have correct metadata:
100
-
101
-
```bash
102
-
twine check dist/*
103
-
```
104
-
105
-
This will create platform-specific wheels in the `dist/` directory.
106
-
107
-
## Running Tests
108
-
109
-
Run the tests:
110
-
111
-
```bash
112
-
make test
113
-
```
114
-
115
-
Alternatively, install pytest (if not already installed):
116
-
117
-
```bash
118
-
pip install pytest
119
-
```
120
-
121
-
And run:
122
-
123
-
```bash
124
-
pytest
125
-
```
34
+
See the [`examples` directory](https://github.com/contentauth/c2pa-python/tree/main/examples) for some helpful examples:
35
+
-`examples/sign.py` shows how to sign and verify an asset with a C2PA manifest.
36
+
-`examples/training.py` demonstrates how to add a "Do Not Train" assertion to an asset and verify it.
126
37
127
38
## Contributing
128
39
129
-
Contributions are welcome! Please fork the repository and submit a pull request.
40
+
Contributions are welcome! For more information, see [Contributing to the project](https://github.com/contentauth/c2pa-python/blob/main/docs/project-contributions.md).
130
41
131
42
## License
132
43
133
-
This project is licensed under the Apache License 2.0 or the MIT License. See the LICENSE-MIT and LICENSE-APACHE files for details.
44
+
This project is licensed under the Apache License 2.0 and the MIT License. See the [LICENSE-MIT](https://github.com/contentauth/c2pa-python/blob/main/LICENSE-MIT) and [LICENSE-APACHE](https://github.com/contentauth/c2pa-python/blob/main/LICENSE-APACHE) files for details.
Copy file name to clipboardExpand all lines: docs/project-contributions.md
+68-44Lines changed: 68 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,35 +2,51 @@
2
2
3
3
The information in this page is primarily for those who wish to contribute to the c2pa-python library project itself, rather than those who simply wish to use it in an application. For general contribution guidelines, see [CONTRIBUTING.md](../CONTRIBUTING.md).
4
4
5
-
## Development
5
+
## Setup
6
6
7
-
It is best to [set up a virtual environment](https://virtualenv.pypa.io/en/latest/installation.html) for development and testing.
7
+
It is best to [set up a virtual environment](https://virtualenv.pypa.io/en/latest/installation.html) for development and testing:
8
8
9
-
To build from source on Linux, install `curl` and `rustup` then set up Python.
9
+
```bash
10
+
python -m venv .venv
11
+
```
12
+
13
+
Activate the virtual environment.
10
14
11
-
First update `apt` then (if needed) install `curl`:
15
+
- On Windows:
16
+
```bash
17
+
.venv\Scripts\activate
18
+
```
19
+
- On macOS/Linux:
20
+
```bash
21
+
source .venv/bin/activate
22
+
```
23
+
24
+
Load project dependencies:
12
25
13
26
```bash
14
-
apt update
15
-
apt install curl
27
+
pip install -r requirements.txt
28
+
pip install -r requirements-dev.txt
16
29
```
17
30
18
-
Install Rust:
31
+
Download library artifacts for the current version you want, (for example, as shown below for v0.55.0):
19
32
20
33
```bash
21
-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
22
-
source"$HOME/.cargo/env"
34
+
python scripts/download_artifacts.py c2pa-v0.55.0
23
35
```
24
36
25
-
Install Python, `pip`, and `venv`:
37
+
Install the package in development mode:
26
38
27
39
```bash
28
-
apt install python3
29
-
apt install pip
30
-
apt install python3.11-venv
31
-
python3 -m venv .venv
40
+
pip install -e .
32
41
```
33
42
43
+
This command:
44
+
45
+
- Copies the appropriate libraries for your platform from `artifacts/` to `src/c2pa/libs/`
46
+
- Installs the package in development mode, so you can make changes to the Python code without reinstalling.
47
+
48
+
## Building wheels
49
+
34
50
Build the wheel for your platform (from the root of the repository):
35
51
36
52
```bash
@@ -42,49 +58,58 @@ pip install -U pytest
42
58
python3 -m build --wheel
43
59
```
44
60
45
-
Note: To peek at the Python code (uniffi generated and non-generated), run `maturin develop` and look in the c2pa folder.
61
+
To testlocal wheels locally, enter this command:
46
62
47
-
## ManyLinux build
63
+
```bash
64
+
make test-local-wheel-build
65
+
```
48
66
49
-
Build using [manylinux](https://github.com/pypa/manylinux) by using a Docker image as follows:
67
+
To verify the builds, enter this command:
50
68
51
69
```bash
52
-
docker run -it quay.io/pypa/manylinux_2_28_aarch64 bash
53
-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
0 commit comments