Skip to content

Commit c171ed6

Browse files
committed
feat: Rewrite this repo to use pre-built c2pa_rs libraries and no direct Rust compilation
1 parent c94a985 commit c171ed6

31 files changed

+2248
-1332
lines changed

.gitignore

Lines changed: 99 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,110 @@
1-
# Generated by Cargo
2-
# will have compiled files and executables
3-
debug/
4-
target/
5-
.idea
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
/artifacts
7+
68

9+
# C extensions
10+
*.so
11+
*.dll
12+
*.dylib
13+
14+
# Virtual environment
15+
env/
716
venv/
17+
ENV/
818
.venv/
19+
.ENV/
920

10-
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
11-
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
12-
Cargo.lock
21+
# Distribution / packaging
22+
.Python
23+
build/
24+
develop-eggs/
25+
dist/
26+
downloads/
27+
eggs/
28+
.eggs/
29+
lib/
30+
lib64/
31+
parts/
32+
sdist/
33+
var/
34+
wheels/
35+
*.egg-info/
36+
.installed.cfg
37+
*.egg
1338

14-
# These are backup files generated by rustfmt
15-
**/*.rs.bk
39+
# PyInstaller
40+
# Usually these files are written by a Python script from a template
41+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
42+
*.manifest
43+
*.spec
1644

17-
# MSVC Windows builds of rustc generate these, which store debugging information
18-
*.pdb
45+
# Installer logs
46+
pip-log.txt
47+
pip-delete-this-directory.txt
1948

20-
# Python caches
21-
__pycache__/
49+
# Unit test / coverage reports
50+
htmlcov/
51+
.tox/
52+
.nox/
53+
.coverage
54+
*.cover
55+
*.py,cover
56+
.hypothesis/
2257
.pytest_cache/
23-
dist
58+
nosetests.xml
59+
coverage.xml
60+
*.coveragerc
61+
62+
63+
# pyenv
64+
.python-version
2465

25-
c2pa/c2pa/
2666

27-
# Mac OS X files
67+
# Environments
68+
.env
69+
.env.*
70+
*.env
71+
72+
# IDEs and editors
73+
.idea/
74+
.vscode/
75+
*.swp
76+
*.swo
77+
*.sublime-project
78+
*.sublime-workspace
79+
80+
# macOS
2881
.DS_Store
82+
.AppleDouble
83+
.LSOverride
84+
85+
# Linux
86+
*~
87+
88+
# Windows
89+
Thumbs.db
90+
ehthumbs.db
91+
Desktop.ini
92+
$RECYCLE.BIN/
93+
94+
# Temporary files
95+
*.tmp
96+
*.temp
97+
*.log
98+
*.bak
99+
*.old
100+
*.orig
101+
*.rej
102+
*.sublime-workspace
103+
104+
# C2PA-specific
105+
target/
106+
*.pem
107+
*.key
108+
*.dylib
109+
*.dll
110+
*.so

.vscode/settings.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

Cargo.toml

Lines changed: 0 additions & 22 deletions
This file was deleted.

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include src/c2pa/libs/*.dylib
2+
include src/c2pa/libs/*.dll
3+
include src/c2pa/libs/*.so

README.md

Lines changed: 68 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,98 @@
1-
# C2PA Python library
1+
# Python API for C2PA
22

3-
The [c2pa-python](https://github.com/contentauth/c2pa-python) repository implements Python bindings for the Content Authenticity Initiative (CAI) SDK.
4-
It enables you to read and validate C2PA manifest data from and add signed manifests to media files in supported formats.
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.
54

6-
**NOTE**: Starting with version 0.5.0, this package has a completely different API from version 0.4.0. See [Release notes](docs/release-notes.md) for more information.
5+
## Features
76

8-
**WARNING**: This is an prerelease version of this library. There may be bugs and unimplemented features, and the API is subject to change.
7+
- Create and sign C2PA manifests using various signing algorithms.
8+
- Verify C2PA manifests and extract metadata.
9+
- Add assertions and ingredients to assets.
10+
- Examples and unit tests to demonstrate usage.
911

10-
<div style={{display: 'none'}}>
12+
## Project Structure
1113

12-
Additional documentation:
13-
- [Using the Python library](docs/usage.md)
14-
- [Release notes](docs/release-notes.md)
15-
- [Contributing to the project](docs/project-contributions.md)
14+
```bash
15+
python_api/
16+
├── examples/ # Example scripts demonstrating usage
17+
├── src/ # Source code for the C2PA Python API
18+
│ └── c2pa/ # Main package directory
19+
│ └── libs/ # Platform-specific libraries
20+
├── tests/ # Unit tests and benchmarks
21+
├── artifacts/ # Platform-specific libraries for building
22+
│ ├── win_amd64/ # Windows x64 libraries
23+
│ ├── win_arm64/ # Windows ARM64 libraries
24+
│ ├── macosx_x86_64/ # macOS x64 libraries
25+
│ ├── macosx_arm64/ # macOS ARM64 libraries
26+
│ ├── linux_x86_64/ # Linux x64 libraries
27+
│ └── linux_aarch64/ # Linux ARM64 libraries
28+
├── requirements.txt # Python dependencies
29+
└── README.md # Project documentation
30+
```
31+
32+
## Development Setup
1633

17-
</div>
34+
1. Create and activate a virtual environment:
35+
```bash
36+
# Create virtual environment
37+
python -m venv .venv
38+
39+
# Activate virtual environment
40+
# On Windows:
41+
.venv\Scripts\activate
42+
# On macOS/Linux:
43+
source .venv/bin/activate
1844

19-
## Installation
45+
# load project dependencies
46+
pip install -r requirements.txt
2047

21-
Install from PyPI by entering this command:
48+
# download library artifacts for the current version you want
49+
python scripts/download_artifacts.py c2pa-v0.49.5
50+
```
2251

52+
53+
2. Install the package in development mode:
2354
```bash
24-
pip install -U c2pa-python
55+
pip install -e .
2556
```
2657

27-
This is a platform wheel built with Rust that works on Windows, macOS, and most Linux distributions (using [manylinux](https://github.com/pypa/manylinux)). If you need to run on another platform, see [Project contributions - Development](docs/project-contributions.md#development) for information on how to build from source.
58+
This will:
59+
- Copy the appropriate libraries for your platform from `artifacts/` to `src/c2pa/libs/`
60+
- Install the package in development mode, allowing you to make changes to the Python code without reinstalling
2861

29-
### Updating
62+
## Building Wheels
3063

31-
Determine what version you've got by entering this command:
64+
To build wheels for all platforms that have libraries in the `artifacts/` directory:
3265

3366
```bash
34-
pip list | grep c2pa-python
67+
python setup.py bdist_wheel
3568
```
3669

37-
If the version shown is lower than the most recent version, then update by [reinstalling](#installation).
70+
This will create platform-specific wheels in the `dist/` directory.
3871

39-
### Reinstalling
72+
## Running Tests
4073

41-
If you tried unsuccessfully to install this package before the [0.40 release](https://github.com/contentauth/c2pa-python/releases/tag/v0.4), then use this command to reinstall:
74+
Install pytest (if not already installed):
75+
```bash
76+
pip install pytest
77+
```
4278

79+
Run the tests:
4380
```bash
44-
pip install --upgrade --force-reinstall c2pa-python
81+
pytest
4582
```
4683

47-
## Supported formats
84+
## Examples
4885

49-
The Python library [supports the same media file formats](https://github.com/contentauth/c2pa-rs/blob/main/docs/supported-formats.md) as the Rust library.
86+
### Adding a "Do Not Train" Assertion
87+
The `examples/training.py` script demonstrates how to add a "Do Not Train" assertion to an asset and verify it.
5088

51-
## License
89+
### Signing and Verifying Assets
90+
The `examples/test.py` script shows how to sign an asset with a C2PA manifest and verify it.
5291

53-
This package is distributed under the terms of both the [MIT license](https://github.com/contentauth/c2pa-python/blob/main/LICENSE-MIT) and the [Apache License (Version 2.0)](https://github.com/contentauth/c2pa-python/blob/main/LICENSE-APACHE).
92+
## Contributing
5493

55-
Note that some components and dependent crates are licensed under different terms; please check the license terms for each crate and component for details.
94+
Contributions are welcome! Please fork the repository and submit a pull request.
5695

57-
### Contributions and feedback
96+
## License
5897

59-
We welcome contributions to this project. For information on contributing, providing feedback, and about ongoing work, see [Contributing](https://github.com/contentauth/c2pa-python/blob/main/CONTRIBUTING.md).
98+
This project is licensed under the Apache License 2.0 or the MIT License. See the LICENSE-MIT and LICENSE-APACHE files for details.

README_saved.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# C2PA Python library
2+
3+
The [c2pa-python](https://github.com/contentauth/c2pa-python) repository implements Python bindings for the Content Authenticity Initiative (CAI) SDK.
4+
It enables you to read and validate C2PA manifest data from and add signed manifests to media files in supported formats.
5+
6+
**NOTE**: Starting with version 0.5.0, this package has a completely different API from version 0.4.0. See [Release notes](docs/release-notes.md) for more information.
7+
8+
**WARNING**: This is an prerelease version of this library. There may be bugs and unimplemented features, and the API is subject to change.
9+
10+
<div style={{display: 'none'}}>
11+
12+
Additional documentation:
13+
- [Using the Python library](docs/usage.md)
14+
- [Release notes](docs/release-notes.md)
15+
- [Contributing to the project](docs/project-contributions.md)
16+
17+
</div>
18+
19+
## Installation
20+
21+
Install from PyPI by entering this command:
22+
23+
```bash
24+
pip install -U c2pa-python
25+
```
26+
27+
This is a platform wheel built with Rust that works on Windows, macOS, and most Linux distributions (using [manylinux](https://github.com/pypa/manylinux)). If you need to run on another platform, see [Project contributions - Development](docs/project-contributions.md#development) for information on how to build from source.
28+
29+
### Updating
30+
31+
Determine what version you've got by entering this command:
32+
33+
```bash
34+
pip list | grep c2pa-python
35+
```
36+
37+
If the version shown is lower than the most recent version, then update by [reinstalling](#installation).
38+
39+
### Reinstalling
40+
41+
If you tried unsuccessfully to install this package before the [0.40 release](https://github.com/contentauth/c2pa-python/releases/tag/v0.4), then use this command to reinstall:
42+
43+
```bash
44+
pip install --upgrade --force-reinstall c2pa-python
45+
```
46+
47+
## Supported formats
48+
49+
The Python library [supports the same media file formats](https://github.com/contentauth/c2pa-rs/blob/main/docs/supported-formats.md) as the Rust library.
50+
51+
## License
52+
53+
This package is distributed under the terms of both the [MIT license](https://github.com/contentauth/c2pa-python/blob/main/LICENSE-MIT) and the [Apache License (Version 2.0)](https://github.com/contentauth/c2pa-python/blob/main/LICENSE-APACHE).
54+
55+
Note that some components and dependent crates are licensed under different terms; please check the license terms for each crate and component for details.
56+
57+
### Contributions and feedback
58+
59+
We welcome contributions to this project. For information on contributing, providing feedback, and about ongoing work, see [Contributing](https://github.com/contentauth/c2pa-python/blob/main/CONTRIBUTING.md).

build.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)