Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/build-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
cd /io &&
/opt/python/cp310-cp310/bin/pip install -r requirements.txt -r requirements-dev.txt &&
/opt/python/cp310-cp310/bin/pip install toml &&
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 &&
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 &&
for PYBIN in /opt/python/cp3{10,11}-*/bin; do
\${PYBIN}/pip install --upgrade pip wheel &&
\${PYBIN}/pip install toml &&
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ macos-latest, ubuntu-latest ]
os: [ macos-latest, ubuntu-latest, ubuntu-24.04-arm ]

steps:
- name: Checkout repository
Expand Down Expand Up @@ -178,6 +178,8 @@ jobs:
include:
- target: x86_64
runs-on: ubuntu-24.04
- target: aarch64
runs-on: ubuntu-24.04-arm
if: |
github.event_name != 'pull_request' ||
github.event.pull_request.author_association == 'COLLABORATOR' ||
Expand All @@ -194,6 +196,8 @@ jobs:
include:
- target: x86_64
runs-on: ubuntu-24.04
- target: aarch64
runs-on: ubuntu-24.04-arm
if: |
github.event_name != 'pull_request' ||
github.event.pull_request.author_association == 'COLLABORATOR' ||
Expand Down Expand Up @@ -444,6 +448,10 @@ jobs:
pattern: wheels-*
path: dist
merge-multiple: true
- name: List downloaded artifacts
run: |
echo "Downloaded Artifacts"
ls -la dist/
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand All @@ -453,4 +461,3 @@ jobs:
verbose: true
# Uncomment below for test runs, otherwise fails on existing packages being reuploaded
skip-existing: true

15 changes: 13 additions & 2 deletions scripts/download_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,21 @@ def get_platform_identifier():
Returns one of:
- universal-apple-darwin (for Mac)
- x86_64-pc-windows-msvc (for Windows 64-bit)
- x86_64-unknown-linux-gnu (for Linux 64-bit)
- x86_64-unknown-linux-gnu (for Linux x86_64)
- aarch64-unknown-linux-gnu (for Linux ARM64)
"""
system = platform.system().lower()
machine = platform.machine().lower()

if system == "darwin":
return "universal-apple-darwin"
elif system == "windows":
return "x86_64-pc-windows-msvc"
elif system == "linux":
return "x86_64-unknown-linux-gnu"
if machine in ["arm64", "aarch64"]:
return "aarch64-unknown-linux-gnu"
else:
return "x86_64-unknown-linux-gnu"
else:
raise ValueError(f"Unsupported operating system: {system}")

Expand Down Expand Up @@ -105,8 +110,12 @@ def copy_artifacts_to_root():
print("Copying artifacts from scripts/artifacts to root...")
if ROOT_ARTIFACTS_DIR.exists():
shutil.rmtree(ROOT_ARTIFACTS_DIR)
print(f"Copying from {SCRIPTS_ARTIFACTS_DIR} to {ROOT_ARTIFACTS_DIR}")
shutil.copytree(SCRIPTS_ARTIFACTS_DIR, ROOT_ARTIFACTS_DIR)
print("Done copying artifacts")
print("\nFolder content of artifacts directory:")
for item in sorted(ROOT_ARTIFACTS_DIR.iterdir()):
print(f" {item.name}")

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

Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def get_version():
'x86_64-apple-darwin': 'dylib',
'x86_64-pc-windows-msvc': 'dll',
'x86_64-unknown-linux-gnu': 'so',
'aarch64-unknown-linux-gnu': 'so', # Add ARM Linux support
}

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

Expand All @@ -66,6 +68,8 @@ def get_platform_identifier(cpu_arch = None) -> str:
elif system == "windows":
return "x86_64-pc-windows-msvc"
elif system == "linux":
if platform.machine() == "aarch64":
return "aarch64-unknown-linux-gnu"
return "x86_64-unknown-linux-gnu"
else:
raise ValueError(f"Unsupported operating system: {system}")
Expand Down
7 changes: 6 additions & 1 deletion src/c2pa/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def get_platform_identifier(cpu_arch: Optional[CPUArchitecture] = None) -> str:
elif system == "windows":
return "x86_64-pc-windows-msvc"
elif system == "linux":
if _get_architecture() in ['arm64', 'aarch64']:
return "aarch64-unknown-linux-gnu"
return "x86_64-unknown-linux-gnu"
else:
raise ValueError(f"Unsupported operating system: {system}")
Expand Down Expand Up @@ -245,8 +247,11 @@ def dynamically_load_library(
# If specific library name is provided, only load that one
lib = _load_single_library(lib_name, possible_paths)
if not lib:
platform_id = get_platform_identifier()
current_arch = _get_architecture()
logger.error(f"Could not find {lib_name} in any of the search paths: {[str(p) for p in possible_paths]}")
raise RuntimeError(f"Could not find {lib_name} in any of the search paths")
logger.error(f"Platform: {platform_id}, Architecture: {current_arch}")
raise RuntimeError(f"Could not find {lib_name} in any of the search paths (Platform: {platform_id}, Architecture: {current_arch})")
return lib

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