Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c3ad9a7
rename pkg
dienhoa May 27, 2025
63cccd0
using token
dienhoa May 27, 2025
d0444a6
Configure trusted publishing for TestPyPI
dienhoa May 27, 2025
6bce7b3
Add test-pypi-publish branch to workflow triggers
dienhoa May 27, 2025
95c8f2d
fix publishing
dienhoa May 27, 2025
17e856a
test publishing
dienhoa May 27, 2025
bacf4ee
Speed up CI: build only for Python 3.11 and fix wheel publishing
dienhoa May 27, 2025
a5c4476
Fix classifiers to match actual build targets (Python 3.11, Linux only)
dienhoa May 27, 2025
e46cb26
Bump version to 0.1.1 and add better wheel debugging
dienhoa May 27, 2025
c05b50c
Fix maturin action: remove invalid python-interpreter parameter
dienhoa May 27, 2025
392b317
pypi instead of testpypi
dienhoa May 27, 2025
96cdbf2
add env
dienhoa May 27, 2025
1a2c1df
build for 3.12
dienhoa May 27, 2025
3e8edb6
bump version
dienhoa May 27, 2025
3378835
force manylinux 2_34
dienhoa May 27, 2025
1b10e32
ci ubuntu 22.04
dienhoa May 27, 2025
7db5313
return None in case no jumbf instead of throw error
dienhoa Jun 8, 2025
848ea85
refactor
dienhoa Jun 8, 2025
9567166
add both .png and .jpeg in test
dienhoa Jun 8, 2025
b53bed0
move get mime and read c2pa from file to python
dienhoa Jun 9, 2025
3b9f5c1
setup trust outside read_2pa
dienhoa Jun 9, 2025
61078d7
save the full reader data instead of only the manifest
dienhoa Jun 9, 2025
fcab6f5
add check trust in test
dienhoa Jun 9, 2025
6353a34
add cert for benchmark fastc2pa
dienhoa Jun 9, 2025
1e7363e
add convert to gray
dienhoa Jun 9, 2025
0da15a7
add blog
dienhoa Jun 11, 2025
e97c88a
add license
dienhoa Jun 11, 2025
96a0f91
don't test perf on ci
dienhoa Jun 11, 2025
af8a1a8
update test on README
dienhoa Jun 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 55 additions & 11 deletions .github/workflows/cross_platform_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Cross-Platform Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
tags:
- 'v*.*.*' # Only trigger on tags like v1.0.0, v1.2.3
workflow_dispatch: # Allows manual triggering

# Add this section to control notification behavior
Expand All @@ -25,8 +25,8 @@ jobs:
strategy:
fail-fast: false # Continue with other jobs if one fails
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.11']
os: [ubuntu-22.04]
python-version: ['3.11', '3.12']

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -66,6 +66,12 @@ jobs:
echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV
echo "$PWD/.venv/bin" >> $GITHUB_PATH

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev pkg-config build-essential
shell: bash

- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -76,24 +82,24 @@ jobs:
- name: Build and install package with maturin
uses: PyO3/maturin-action@v1
with:
python-interpreter: ${{ steps.setup_python.outputs.python-path }}
target: ${{ matrix.os == 'macos-latest' && 'universal2-apple-darwin' || 'x86_64' }}
target: x86_64
command: develop
args: --release
sccache: 'true'

- name: Run tests
run: python run_tests.py
- name: Run API tests only
run: python run_tests.py --api-only
continue-on-error: true # Continue even if tests fail to get wheels

- name: Build wheel
uses: PyO3/maturin-action@v1
with:
python-interpreter: ${{ steps.setup_python.outputs.python-path }}
target: ${{ matrix.os == 'macos-latest' && 'universal2-apple-darwin' || 'x86_64' }}
target: x86_64
command: build
args: --release
sccache: 'true'
env:
OPENSSL_NO_VENDOR: 1

- name: Upload wheels
uses: actions/upload-artifact@v4
Expand All @@ -117,8 +123,46 @@ jobs:
run: find wheels -type f -name "*.whl" | sort
shell: bash

- name: Flatten wheel structure
run: |
mkdir -p dist
find wheels -name "*.whl" -exec cp {} dist/ \;
echo "Files in dist after flattening:"
ls -la dist/

- name: Upload combined wheels
uses: actions/upload-artifact@v4
with:
name: all-wheels
path: wheels/*/*.whl
path: dist/*.whl

publish_to_pypi:
name: Publish Python distributions to PyPI
needs: collect_wheels
runs-on: ubuntu-latest
environment: pypi
# Trigger on tags (releases) OR manual workflow dispatch
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing

steps:
- name: Download all wheels
uses: actions/download-artifact@v4
with:
name: all-wheels
path: dist/

- name: List downloaded files
run: |
echo "Files in dist/:"
ls -la dist/
echo "Checking for .whl files specifically:"
find dist -name "*.whl" -type f
echo "Wheel file details:"
find dist -name "*.whl" -type f -exec basename {} \;

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1


5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ wheels/
.env
.venv
venv/
ENV/
ENV/

# Cursor rules
.cursorrules
12 changes: 9 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
[package]
name = "fast_c2pa_reader"
name = "fast-c2pa-python"
version = "0.1.0"
edition = "2021"
authors = ["Sightengine <info@sightengine.com>"]
license = "MIT OR Apache-2.0"
description = "Fast Python library for reading C2PA metadata using PyO3 bindings to c2pa-rs"
keywords = ["c2pa", "metadata", "python", "bindings"]

[lib]
name = "fast_c2pa_reader"
name = "fast_c2pa_core"
crate-type = ["cdylib"]

[dependencies]
c2pa = { version = "0.49.5", features = ["file_io"] }
pyo3 = { version = "0.19.0", features = ["extension-module"] }
serde_json = "1.0"
log = "0.4"
image = "0.25.6"

# Optimize for performance in release builds
[profile.release]
Expand All @@ -19,4 +25,4 @@ lto = "fat" # Link-time optimization
codegen-units = 1 # Slower build, better optimization
panic = "abort" # Remove unwinding code
strip = true # Strip symbols from binary
debug = false # No debug info
debug = false # No debug info
196 changes: 196 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
MIT License

Copyright (c) 2025 Sightengine

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

================================================================================

This project incorporates the c2pa-rs library (https://github.com/contentauth/c2pa-rs)
Copyright (c) Content Authenticity Initiative contributors
which is dual-licensed under MIT and Apache 2.0 licenses.

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(which may include materials held in the "License Appendix").

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based upon (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and derivative works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control
systems, and issue tracking systems that are managed by, or on behalf
of, the Licensor for the purpose of discussing and improving the Work,
but excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to use, reproduce, modify, display, perform,
sublicense, and distribute the Work and such Derivative Works in
Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, trademark, patent,
attribution and other notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright notice regarding Your contributions.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Support. You may choose to offer, and charge a
fee for, warranty, support, indemnity or other liability obligations
and/or rights consistent with this License. However, in accepting such
obligations, You may act only on Your own behalf and on Your sole
responsibility, not on behalf of any other Contributor, and only if
You agree to indemnify, defend, and hold each Contributor harmless for
any liability incurred by, or claims asserted against, such Contributor
by reason of your accepting any such warranty or support.

END OF TERMS AND CONDITIONS
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
dev:
maturin develop

dev-release:
maturin develop --release

test: dev
python -m pytest tests/ -v

test-perf: dev-release
python -m pytest tests/test_performance.py -s -v

test-api: dev
python -m pytest tests/test_api.py -s -v

clean:
cargo clean
rm -rf target/
Loading