Skip to content

Commit d9cafc4

Browse files
authored
Merge pull request #119 from contentauth/fix-readme
docs: Move project contributors info into the correct file.
2 parents eed6f9b + e41ad2e commit d9cafc4

File tree

2 files changed

+82
-147
lines changed

2 files changed

+82
-147
lines changed

README.md

Lines changed: 14 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,44 @@
1-
# Python API for C2PA
1+
# C2PA Python library
22

3-
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.
46

5-
## Features
7+
Features:
68

79
- Create and sign C2PA manifests using various signing algorithms.
810
- Verify C2PA manifests and extract metadata.
911
- Add assertions and ingredients to assets.
1012
- Examples and unit tests to demonstrate usage.
1113

12-
## Project Structure
14+
## Prerequisites
1315

14-
```bash
15-
.
16-
├── .github/ # GitHub configuration files
17-
├── artifacts/ # Platform-specific libraries for building (per subfolder)
18-
│ └── your_target_platform/ # Platform-specific artifacts
19-
├── docs/ # Project documentation
20-
├── examples/ # Example scripts demonstrating usage
21-
├── scripts/ # Utility scripts (eg. artifacts download)
22-
├── src/ # Source code
23-
│ └── c2pa/ # Main package directory
24-
│ └── libs/ # Platform-specific libraries
25-
├── tests/ # Unit tests and benchmarks
26-
├── .gitignore # Git ignore rules
27-
├── Makefile # Build and development commands
28-
├── pyproject.toml # Python project configuration
29-
├── requirements.txt # Python dependencies
30-
├── requirements-dev.txt # Development dependencies
31-
└── setup.py # Package setup script
32-
```
16+
This library requires Python version 3.10+.
3317

3418
## Package installation
3519

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:
3721

3822
```bash
3923
pip install c2pa-python
4024
```
4125

42-
To use the module in your Python code, import like this:
26+
To use the module in Python code, import it like this:
4327

4428
```python
4529
import c2pa
4630
```
4731

4832
## Examples
4933

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.
12637

12738
## Contributing
12839

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).
13041

13142
## License
13243

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.

docs/project-contributions.md

Lines changed: 68 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,51 @@
22

33
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).
44

5-
## Development
5+
## Setup
66

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:
88

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.
1014

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:
1225

1326
```bash
14-
apt update
15-
apt install curl
27+
pip install -r requirements.txt
28+
pip install -r requirements-dev.txt
1629
```
1730

18-
Install Rust:
31+
Download library artifacts for the current version you want, (for example, as shown below for v0.55.0):
1932

2033
```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
2335
```
2436

25-
Install Python, `pip`, and `venv`:
37+
Install the package in development mode:
2638

2739
```bash
28-
apt install python3
29-
apt install pip
30-
apt install python3.11-venv
31-
python3 -m venv .venv
40+
pip install -e .
3241
```
3342

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+
3450
Build the wheel for your platform (from the root of the repository):
3551

3652
```bash
@@ -42,49 +58,58 @@ pip install -U pytest
4258
python3 -m build --wheel
4359
```
4460

45-
Note: To peek at the Python code (uniffi generated and non-generated), run `maturin develop` and look in the c2pa folder.
61+
To test local wheels locally, enter this command:
4662

47-
## ManyLinux build
63+
```bash
64+
make test-local-wheel-build
65+
```
4866

49-
Build using [manylinux](https://github.com/pypa/manylinux) by using a Docker image as follows:
67+
To verify the builds, enter this command:
5068

5169
```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
54-
source "$HOME/.cargo/env"
55-
export PATH=/opt/python/cp312-cp312/bin:$PATH
56-
pip install maturin
57-
pip install venv
58-
pip install build
59-
pip install -U pytest
70+
make verify-wheel-build
71+
```
6072

61-
cd home
62-
git clone https://github.com/contentauth/c2pa-python.git
63-
cd c2pa-python
64-
python3 -m build --wheel
65-
auditwheel repair target/wheels/c2pa_python-0.4.0-py3-none-linux_aarch64.whl
73+
## Project structure
74+
75+
```bash
76+
.
77+
├── .github/ # GitHub configuration files
78+
├── artifacts/ # Platform-specific libraries for building (per subfolder)
79+
│ └── your_target_platform/ # Platform-specific artifacts
80+
├── docs/ # Project documentation
81+
├── examples/ # Example scripts demonstrating usage
82+
├── scripts/ # Utility scripts (eg. artifacts download)
83+
├── src/ # Source code
84+
│ └── c2pa/ # Main package directory
85+
│ └── libs/ # Platform-specific libraries
86+
├── tests/ # Unit tests and benchmarks
87+
├── .gitignore # Git ignore rules
88+
├── Makefile # Build and development commands
89+
├── pyproject.toml # Python project configuration
90+
├── requirements.txt # Python dependencies
91+
├── requirements-dev.txt # Development dependencies
92+
└── setup.py # Package setup script
6693
```
6794

6895
## Testing
6996

70-
We use [PyTest](https://docs.pytest.org/) and [unittest](https://docs.python.org/3/library/unittest.html) for testing.
97+
The project uses [PyTest](https://docs.pytest.org/) and [unittest](https://docs.python.org/3/library/unittest.html) for testing.
7198

7299
Run tests by following these steps:
73100

74101
1. Activate the virtual environment: `source .venv/bin/activate`
75102
2. (optional) Install dependencies: `pip install -r requirements.txt`
76-
3. Setup the virtual environment with local changes: `maturin develop`
77-
4. Run the tests: `pytest`
78-
5. Deactivate the virtual environment: `deactivate`
79-
80-
For example:
81-
82-
```bash
83-
source .venv/bin/activate
84-
maturin develop
85-
python3 tests/training.py
86-
deactivate
87-
```
103+
4. Run the tests:
104+
```bash
105+
make test
106+
```
107+
5. Alternatively, install `pytest` (if not already installed) and run it:
108+
```bash
109+
pip install pytest
110+
pytest
111+
```
112+
**Warning**: Using `pytest` can lead to issues if you often switch between virtual environments.
88113

89114
### Testing during bindings development
90115

@@ -102,4 +127,3 @@ To rebuild and test, enter these commands:
102127
make build-python
103128
make test
104129
```
105-

0 commit comments

Comments
 (0)