Skip to content

Commit 21f5be7

Browse files
authored
feat: Add a runner for Linux ARM support (#121)
* fix: More docs, and readme for examples * fix: Wording * fix: Examples * fix: Examples * fix: Examples * fix: Add a note * fix: More editorial changes * fix: Update corrupted file (#120) * fix: Add a test * fix: Add a debug test for CAWG * fix: Fix corrupted file * fix: Cleaning up * fix: Fix non-threaded tests * fix: unrandomize test * fix: Improve test sensitivity * fix: Improve comment * fix: Add a runner * fix: ARM * fix: ARM * fix: ARM * fix: Comments * fix: ARM * fix: ARM * fix: ARM * fix: ARM * fix: ARM * fix: ARM * fix: ARM * fix: Remove logs * fix: Version bump
1 parent 2622fa9 commit 21f5be7

File tree

6 files changed

+34
-7
lines changed

6 files changed

+34
-7
lines changed

.github/workflows/build-wheel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
cd /io &&
6464
/opt/python/cp310-cp310/bin/pip install -r requirements.txt -r requirements-dev.txt &&
6565
/opt/python/cp310-cp310/bin/pip install toml &&
66-
C2PA_LIBS_PLATFORM=\"${{ inputs.architecture == 'aarch64' && 'aarch64-unknown-linux-gnu' || 'x86_64-unknown-linux-gnu' }}\" /opt/python/cp310-cp310/bin/python scripts/download_artifacts.py $C2PA_VERSION &&
66+
C2PA_LIBS_PLATFORM=\"${{ format('{0}', inputs.architecture == 'aarch64' && 'aarch64-unknown-linux-gnu' || 'x86_64-unknown-linux-gnu') }}\" /opt/python/cp310-cp310/bin/python scripts/download_artifacts.py $C2PA_VERSION &&
6767
for PYBIN in /opt/python/cp3{10,11}-*/bin; do
6868
\${PYBIN}/pip install --upgrade pip wheel &&
6969
\${PYBIN}/pip install toml &&

.github/workflows/build.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
strategy:
5252
fail-fast: false
5353
matrix:
54-
os: [ macos-latest, ubuntu-latest ]
54+
os: [ macos-latest, ubuntu-latest, ubuntu-24.04-arm ]
5555

5656
steps:
5757
- name: Checkout repository
@@ -178,6 +178,8 @@ jobs:
178178
include:
179179
- target: x86_64
180180
runs-on: ubuntu-24.04
181+
- target: aarch64
182+
runs-on: ubuntu-24.04-arm
181183
if: |
182184
github.event_name != 'pull_request' ||
183185
github.event.pull_request.author_association == 'COLLABORATOR' ||
@@ -194,6 +196,8 @@ jobs:
194196
include:
195197
- target: x86_64
196198
runs-on: ubuntu-24.04
199+
- target: aarch64
200+
runs-on: ubuntu-24.04-arm
197201
if: |
198202
github.event_name != 'pull_request' ||
199203
github.event.pull_request.author_association == 'COLLABORATOR' ||
@@ -444,6 +448,10 @@ jobs:
444448
pattern: wheels-*
445449
path: dist
446450
merge-multiple: true
451+
- name: List downloaded artifacts
452+
run: |
453+
echo "Downloaded Artifacts"
454+
ls -la dist/
447455
- name: Publish to TestPyPI
448456
uses: pypa/gh-action-pypi-publish@release/v1
449457
with:
@@ -453,4 +461,3 @@ jobs:
453461
verbose: true
454462
# Uncomment below for test runs, otherwise fails on existing packages being reuploaded
455463
skip-existing: true
456-

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "c2pa-python"
7-
version = "0.10.0"
7+
version = "0.11.0"
88
requires-python = ">=3.10"
99
description = "Python bindings for the C2PA Content Authenticity Initiative (CAI) library"
1010
readme = { file = "README.md", content-type = "text/markdown" }

scripts/download_artifacts.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,21 @@ def get_platform_identifier():
4646
Returns one of:
4747
- universal-apple-darwin (for Mac)
4848
- x86_64-pc-windows-msvc (for Windows 64-bit)
49-
- x86_64-unknown-linux-gnu (for Linux 64-bit)
49+
- x86_64-unknown-linux-gnu (for Linux x86_64)
50+
- aarch64-unknown-linux-gnu (for Linux ARM64)
5051
"""
5152
system = platform.system().lower()
53+
machine = platform.machine().lower()
5254

5355
if system == "darwin":
5456
return "universal-apple-darwin"
5557
elif system == "windows":
5658
return "x86_64-pc-windows-msvc"
5759
elif system == "linux":
58-
return "x86_64-unknown-linux-gnu"
60+
if machine in ["arm64", "aarch64"]:
61+
return "aarch64-unknown-linux-gnu"
62+
else:
63+
return "x86_64-unknown-linux-gnu"
5964
else:
6065
raise ValueError(f"Unsupported operating system: {system}")
6166

@@ -105,8 +110,12 @@ def copy_artifacts_to_root():
105110
print("Copying artifacts from scripts/artifacts to root...")
106111
if ROOT_ARTIFACTS_DIR.exists():
107112
shutil.rmtree(ROOT_ARTIFACTS_DIR)
113+
print(f"Copying from {SCRIPTS_ARTIFACTS_DIR} to {ROOT_ARTIFACTS_DIR}")
108114
shutil.copytree(SCRIPTS_ARTIFACTS_DIR, ROOT_ARTIFACTS_DIR)
109115
print("Done copying artifacts")
116+
print("\nFolder content of artifacts directory:")
117+
for item in sorted(ROOT_ARTIFACTS_DIR.iterdir()):
118+
print(f" {item.name}")
110119

111120
def main():
112121
if len(sys.argv) < 2:
@@ -126,6 +135,8 @@ def main():
126135
if env_platform:
127136
print(f"Using platform from environment variable C2PA_LIBS_PLATFORM: {env_platform}")
128137
platform_id = env_platform or get_platform_identifier()
138+
print("Looking up releases for platform id: ", platform_id)
139+
print("Environment variable set for lookup: ", env_platform)
129140
platform_source = "environment variable" if env_platform else "auto-detection"
130141
print(f"Target platform: {platform_id} (set through{platform_source})")
131142

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def get_version():
3030
'x86_64-apple-darwin': 'dylib',
3131
'x86_64-pc-windows-msvc': 'dll',
3232
'x86_64-unknown-linux-gnu': 'so',
33+
'aarch64-unknown-linux-gnu': 'so', # Add ARM Linux support
3334
}
3435

3536
# Directory structure
@@ -51,6 +52,7 @@ def get_platform_identifier(cpu_arch = None) -> str:
5152
- x86_64-apple-darwin (for Mac x86_64)
5253
- x86_64-pc-windows-msvc (for Windows 64-bit)
5354
- x86_64-unknown-linux-gnu (for Linux 64-bit)
55+
- aarch64-unknown-linux-gnu (for Linux ARM64)
5456
"""
5557
system = platform.system().lower()
5658

@@ -66,6 +68,8 @@ def get_platform_identifier(cpu_arch = None) -> str:
6668
elif system == "windows":
6769
return "x86_64-pc-windows-msvc"
6870
elif system == "linux":
71+
if platform.machine() == "aarch64":
72+
return "aarch64-unknown-linux-gnu"
6973
return "x86_64-unknown-linux-gnu"
7074
else:
7175
raise ValueError(f"Unsupported operating system: {system}")

src/c2pa/lib.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def get_platform_identifier(cpu_arch: Optional[CPUArchitecture] = None) -> str:
6262
elif system == "windows":
6363
return "x86_64-pc-windows-msvc"
6464
elif system == "linux":
65+
if _get_architecture() in ['arm64', 'aarch64']:
66+
return "aarch64-unknown-linux-gnu"
6567
return "x86_64-unknown-linux-gnu"
6668
else:
6769
raise ValueError(f"Unsupported operating system: {system}")
@@ -245,8 +247,11 @@ def dynamically_load_library(
245247
# If specific library name is provided, only load that one
246248
lib = _load_single_library(lib_name, possible_paths)
247249
if not lib:
250+
platform_id = get_platform_identifier()
251+
current_arch = _get_architecture()
248252
logger.error(f"Could not find {lib_name} in any of the search paths: {[str(p) for p in possible_paths]}")
249-
raise RuntimeError(f"Could not find {lib_name} in any of the search paths")
253+
logger.error(f"Platform: {platform_id}, Architecture: {current_arch}")
254+
raise RuntimeError(f"Could not find {lib_name} in any of the search paths (Platform: {platform_id}, Architecture: {current_arch})")
250255
return lib
251256

252257
# Default path (no library name provided in the environment)

0 commit comments

Comments
 (0)