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
13
-
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
-
```
14
+
## Prerequisites
33
15
34
16
## Package installation
35
17
36
-
The c2pa-python package is published to PyPI. You can install it from there by running:
18
+
Install the c2pa-python package from PyPI by running:
37
19
38
20
```bash
39
21
pip install c2pa-python
40
22
```
41
23
42
-
To use the module in your Python code, import like this:
24
+
To use the module in Python code, import it like this:
43
25
44
26
```python
45
27
import c2pa
46
28
```
47
29
48
30
## Examples
49
31
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:
32
+
### Signing and verifying assets
87
33
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
34
+
The `examples/sign.py` script shows how to sign and verify an asset with a C2PA manifest.
90
35
91
-
##Building Wheels
36
+
### Adding a "Do Not Train" assertion
92
37
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
-
```
38
+
The `examples/training.py` script demonstrates how to add a "Do Not Train" assertion to an asset and verify it.
120
39
121
-
And run:
122
40
123
-
```bash
124
-
pytest
125
-
```
126
41
127
42
## Contributing
128
43
129
-
Contributions are welcome! Please fork the repository and submit a pull request.
44
+
Contributions are welcome! For more information, see [Contributing to the project](https://github.com/contentauth/c2pa-python/blob/main/docs/project-contributions.md).
130
45
131
46
## License
132
47
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.
48
+
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
+80-32Lines changed: 80 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,46 @@
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
+
## Development 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
+
9
+
```bash
10
+
# Create virtual environment
11
+
python -m venv .venv
12
+
13
+
# Activate virtual environment
14
+
# On Windows:
15
+
.venv\Scripts\activate
16
+
# On macOS/Linux:
17
+
source .venv/bin/activate
18
+
```
19
+
20
+
Load project dependencies:
21
+
22
+
```bash
23
+
pip install -r requirements.txt
24
+
pip install -r requirements-dev.txt
25
+
```
26
+
27
+
Download library artifacts for the current version you want, eg v0.55.0:
28
+
29
+
```bash
30
+
python scripts/download_artifacts.py c2pa-v0.55.0
31
+
```
32
+
33
+
Install the package in development mode:
34
+
35
+
```bash
36
+
pip install -e .
37
+
```
38
+
39
+
This will:
40
+
41
+
- Copy the appropriate libraries for your platform from `artifacts/` to `src/c2pa/libs/`
42
+
- Install the package in development mode, allowing you to make changes to the Python code without reinstalling.
43
+
44
+
## Build from source
8
45
9
46
To build from source on Linux, install `curl` and `rustup` then set up Python.
10
47
@@ -42,49 +79,61 @@ pip install -U pytest
42
79
python3 -m build --wheel
43
80
```
44
81
45
-
Note: To peek at the Python code (uniffi generated and non-generated), run `maturin develop` and look in the c2pa folder.
82
+
## Building wheels
83
+
84
+
To build wheels for all platforms that have libraries in the `artifacts/` directory:
46
85
47
-
## ManyLinux build
86
+
```bash
87
+
python setup.py bdist_wheel
88
+
```
48
89
49
-
Build using [manylinux](https://github.com/pypa/manylinux) by using a Docker image as follows:
90
+
You can use `twine` to verify the wheels have correct metadata:
50
91
51
92
```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