Skip to content

Commit e53f873

Browse files
authored
Merge pull request #6 from contentauth/linux_c2pa_fix
Multi-platform publish with import name change to c2pa
2 parents 5723a25 + b2373b3 commit e53f873

File tree

8 files changed

+163
-87
lines changed

8 files changed

+163
-87
lines changed

.github/workflows/build.yml

Lines changed: 130 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,139 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request:
7+
tags:
8+
- "*"
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
813

914
jobs:
10-
build-nightly-only:
11-
name: Build nightly only
15+
linux:
1216
runs-on: ubuntu-latest
13-
container: quay.io/pypa/manylinux2014_x86_64
17+
strategy:
18+
matrix:
19+
target: [x86_64, aarch64]
20+
steps:
21+
- uses: actions/checkout@v3
22+
- uses: actions/setup-python@v4
23+
with:
24+
python-version: "3.10"
25+
cache: "pip"
26+
- run: pip install -r requirements.txt
27+
- name: Setup QEMU
28+
uses: docker/setup-qemu-action@v1
29+
if: ${{ matrix.target == 'aarch64' }}
30+
- name: Build wheels
31+
uses: PyO3/maturin-action@v1
32+
with:
33+
target: ${{ matrix.target }}
34+
maturin-version: "1.2.0"
35+
args: --release --out dist --find-interpreter
36+
sccache: "true"
37+
manylinux: ${{ matrix.target == 'aarch64' && 'manylinux_2_28' || 'auto' }}
38+
before-script-linux: "pip install uniffi-bindgen==0.24.1"
39+
- name: Upload wheels
40+
uses: actions/upload-artifact@v3
41+
with:
42+
name: wheels
43+
path: dist
44+
45+
windows:
46+
runs-on: windows-latest
47+
strategy:
48+
matrix:
49+
target: [x64, x86]
1450
steps:
15-
- uses: actions/checkout@v1
16-
- name: Install nightly rust
17-
run: curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
18-
# Insert steps here to install you other dependencies. Note that you're running inside of cent os 7, not ubuntu
19-
- name: Installing custom dependency
20-
run: echo "Installing custom dependency"
21-
- name: Build
22-
run: |
23-
source $HOME/.cargo/env
24-
for PYBIN in /opt/python/cp3[6789]*/bin; do
25-
"${PYBIN}/pip" install maturin
26-
"${PYBIN}/maturin" build -m nightly-only/Cargo.toml -i "${PYBIN}/python" --release --manylinux 2014
27-
done
28-
# Auditwheel isn't generally necessary. This is only shown as refernce for cases where you link
29-
# external libraries, in which case you have to set manylinux to off and then use auditwheel repair
30-
- name: Auditwheel repair
31-
run: |
32-
for wheel in nightly-only/target/wheels/*.whl; do
33-
auditwheel repair "${wheel}"
34-
done
35-
36-
37-
# This is similar to the above, except we're only using the lowest supported python version to build a single
38-
# abi3 wheel
39-
build-nightly-only-abi3:
40-
name: Build nightly only abi3
51+
- uses: actions/checkout@v3
52+
- uses: actions/setup-python@v4
53+
with:
54+
python-version: '3.10'
55+
architecture: ${{ matrix.target }}
56+
cache: "pip"
57+
- run: pip install -r requirements.txt
58+
- name: Build wheels
59+
uses: PyO3/maturin-action@v1
60+
with:
61+
target: ${{ matrix.target }}
62+
args: --release --out dist --find-interpreter
63+
sccache: 'true'
64+
- name: Upload wheels
65+
uses: actions/upload-artifact@v3
66+
with:
67+
name: wheels
68+
path: dist
69+
70+
macos_x86:
71+
runs-on: macos-latest
72+
steps:
73+
- uses: actions/checkout@v3
74+
- uses: actions/setup-python@v4
75+
with:
76+
python-version: '3.10'
77+
cache: "pip"
78+
- run: pip install -r requirements.txt
79+
- name: Build wheels
80+
uses: PyO3/maturin-action@v1
81+
with:
82+
target: x86_64
83+
args: --release --out dist --find-interpreter
84+
sccache: 'true'
85+
- name: Upload wheels
86+
uses: actions/upload-artifact@v3
87+
with:
88+
name: wheels
89+
path: dist
90+
91+
macos_aarch64:
92+
runs-on: macos-latest-large
93+
steps:
94+
- uses: actions/checkout@v3
95+
- uses: actions/setup-python@v4
96+
with:
97+
python-version: '3.10'
98+
cache: "pip"
99+
- run: pip install -r requirements.txt
100+
- name: Build wheels
101+
uses: PyO3/maturin-action@v1
102+
with:
103+
target: aarch64
104+
args: --release --out dist --find-interpreter
105+
sccache: 'true'
106+
- name: Upload wheels
107+
uses: actions/upload-artifact@v3
108+
with:
109+
name: wheels
110+
path: dist
111+
112+
sdist:
113+
runs-on: ubuntu-latest
114+
steps:
115+
- uses: actions/checkout@v3
116+
- name: Build sdist
117+
uses: PyO3/maturin-action@v1
118+
with:
119+
command: sdist
120+
args: --out dist
121+
- name: Upload sdist
122+
uses: actions/upload-artifact@v3
123+
with:
124+
name: wheels
125+
path: dist
126+
127+
release:
128+
name: Release
41129
runs-on: ubuntu-latest
42-
container: quay.io/pypa/manylinux2014_x86_64
130+
if: "startsWith(github.ref, 'refs/tags/')"
131+
needs: [linux, windows, macos_x86, macos_aarch64, sdist]
43132
steps:
44-
- uses: actions/checkout@v1
45-
- name: Install nightly rust
46-
run: curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
47-
- name: Install maturin
48-
run: /opt/python/cp36-cp36m/bin/pip install maturin
49-
- name: Build with maturin
50-
run: |
51-
source $HOME/.cargo/env
52-
/opt/python/cp36-cp36m/bin/maturin build -m nightly-only-abi3/Cargo.toml -i /opt/python/cp36-cp36m/bin/python --release --manylinux 2014
53-
- name: Auditwheel repair
54-
run: auditwheel repair nightly-only-abi3/target/wheels/*.whl
133+
- uses: actions/download-artifact@v3
134+
with:
135+
name: wheels
136+
- name: Publish to PyPI
137+
uses: PyO3/maturin-action@v1
138+
env:
139+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
140+
with:
141+
command: upload
142+
args: --non-interactive --skip-existing *

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
[package]
22
name = "c2pa-python"
3-
version = "0.3.2"
3+
version = "0.4.0"
44
edition = "2021"
55
authors = ["Gavin Peacock <[email protected]"]
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88
[lib]
9-
name = "c2pa_python"
9+
name = "c2pa"
1010
crate-type = ["cdylib"]
1111

1212
[dependencies]
13-
c2pa-c = { git = "https://github.com/contentauth/c2pa-c.git", branch = "main"}
13+
c2pa-c = { git = "https://github.com/contentauth/c2pa-c.git", branch = "main" }
1414
serde = { version = "1.0", features = ["derive"] }
1515
serde_derive = "1.0"
1616
serde_json = "1.0"
17-
thiserror = "1.0.49"
17+
thiserror = "1.0.49"
1818
uniffi = "0.24.1"
1919

2020
[build-dependencies]

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ see the development section for info on how to build from source.
2525
Import the C2PA module as follows:
2626
2727
```py
28-
import c2pa_python as c2pa
28+
import c2pa
2929
```
3030

3131
### Read and validate C2PA data in a file
@@ -139,6 +139,25 @@ pip install -U pytest
139139
python3 -m build --wheel
140140
```
141141

142+
### ManyLinux build
143+
```
144+
docker run -it quay.io/pypa/manylinux_2_28_aarch64 bash
145+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
146+
source "$HOME/.cargo/env"
147+
export PATH=/opt/python/cp312-cp312/bin:$PATH
148+
pip install maturin
149+
pip install venv
150+
pip install build
151+
pip install -U pytest
152+
153+
cd home
154+
git clone https://github.com/contentauth/c2pa-python.git
155+
cd c2pa-python
156+
python3 -m build --wheel
157+
auditwheel repair target/wheels/c2pa_python-0.4.0-py3-none-linux_aarch64.whl
158+
159+
```
160+
142161
### Testing
143162

144163
We use [PyTest](https://docs.pytest.org/) for testing.

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[build-system]
2-
requires = ["maturin>=1.2,<2.0"]
2+
requires = ["maturin>=1.2,<2.0","uniffi_bindgen>=0.24,<0.25"]
33
build-backend = "maturin"
44

55
[project]
66
name = "c2pa-python"
7+
dependencies = ["cffi"]
78
requires-python = ">=3.7"
89
description = "Python bindings for the C2PA Content Authenticity Initiative (CAI) library"
910
readme = { file = "README.md", content-type = "text/markdown" }
@@ -13,7 +14,7 @@ classifiers = [
1314
"Development Status :: 3 - Alpha",
1415
"Programming Language :: Rust",
1516
"Programming Language :: Python :: Implementation :: CPython",
16-
"Programming Language :: Python :: Implementation :: PyPy",
17+
"Programming Language :: Python :: Implementation :: PyPy"
1718
]
1819
authors = [
1920
{name = "Gavin Peacock", email = "[email protected]"}

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
maturin==1.2.0
2+
uniffi-bindgen==0.24.1

tests/example.py

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

tests/test_c2pa.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# specific language governing permissions and limitations under
1212
# each license.
1313

14-
import c2pa_python as c2pa
14+
import c2pa
1515
import pytest
1616
import json
1717
import tempfile
@@ -24,10 +24,10 @@ def getitem(d, key):
2424
return reduce(operator.getitem, key, d)
2525

2626
def test_version():
27-
assert c2pa.version() == "0.3.2"
27+
assert c2pa.version() == "0.4.0"
2828

2929
def test_sdk_version():
30-
assert c2pa.sdk_version() == "0.28.3"
30+
assert c2pa.sdk_version() == "0.28.4"
3131

3232

3333
def test_verify_from_file():

tests/training.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import json
1616
import os
1717
import sys
18-
import c2pa_python as c2pa;
18+
import c2pa
1919

2020
# set up paths to the files we we are using
2121
PROJECT_PATH = os.getcwd()

0 commit comments

Comments
 (0)