Skip to content

Commit 6eaab37

Browse files
committed
fix: Udpate libs loading
1 parent 385f4f6 commit 6eaab37

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

setup.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,25 @@ def get_version():
1717
PLATFORM_EXTENSIONS = {
1818
'win_amd64': 'dll',
1919
'win_arm64': 'dll',
20-
'macosx_x86_64': 'dylib',
21-
'apple-darwin': 'dylib', # we need to update the published keys
20+
'apple-darwin': 'dylib', # universal
2221
'linux_x86_64': 'so',
2322
'linux_aarch64': 'so',
2423
}
2524

2625
# Based on what c2pa-rs repo publishes
2726
PLATFORM_FOLDERS = {
2827
'universal-apple-darwin': 'dylib',
29-
'aarch64-apple-darwin': 'dylib',
30-
'x86_64-apple-darwin': 'dylib',
3128
'x86_64-pc-windows-msvc': 'dll',
3229
'x86_64-unknown-linux-gnu': 'so',
33-
'aarch64-unknown-linux-gnu': 'so', # Add ARM Linux support
30+
'aarch64-unknown-linux-gnu': 'so',
3431
}
3532

3633
# Directory structure
3734
ARTIFACTS_DIR = Path('artifacts') # Where downloaded libraries are stored
3835
PACKAGE_LIBS_DIR = Path('src/c2pa/libs') # Where libraries will be copied for the wheel
3936

4037

41-
def get_platform_identifier(cpu_arch = None) -> str:
38+
def get_platform_identifier() -> str:
4239
"""Get a platform identifier (arch-os) for the current system,
4340
matching downloaded identifiers used by the Github publisher.
4441
@@ -47,24 +44,15 @@ def get_platform_identifier(cpu_arch = None) -> str:
4744
cpu_arch: Optional CPU architecture for macOS. If not provided, returns universal build.
4845
4946
Returns one of:
50-
- universal-apple-darwin (for Mac, when cpu_arch is None, fallback)
51-
- aarch64-apple-darwin (for Mac ARM64)
52-
- x86_64-apple-darwin (for Mac x86_64)
47+
- universal-apple-darwin (for macOS)
5348
- x86_64-pc-windows-msvc (for Windows 64-bit)
5449
- x86_64-unknown-linux-gnu (for Linux 64-bit)
5550
- aarch64-unknown-linux-gnu (for Linux ARM64)
5651
"""
5752
system = platform.system().lower()
5853

5954
if system == "darwin":
60-
if cpu_arch is None:
61-
return "universal-apple-darwin"
62-
elif cpu_arch == "arm64":
63-
return "aarch64-apple-darwin"
64-
elif cpu_arch == "x86_64":
65-
return "x86_64-apple-darwin"
66-
else:
67-
raise ValueError(f"Unsupported CPU architecture for macOS: {cpu_arch}")
55+
return "universal-apple-darwin"
6856
elif system == "windows":
6957
return "x86_64-pc-windows-msvc"
7058
elif system == "linux":

src/c2pa/lib.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class CPUArchitecture(Enum):
2525
"""CPU architecture enum for platform-specific identifiers."""
2626
AARCH64 = "aarch64"
2727
X86_64 = "x86_64"
28+
ARM64 = "arm64"
2829

2930

3031
def get_platform_identifier() -> str:
@@ -44,7 +45,7 @@ def get_platform_identifier() -> str:
4445
elif system == "windows":
4546
return "x86_64-pc-windows-msvc"
4647
elif system == "linux":
47-
if _get_architecture() in ['arm64', 'aarch64']:
48+
if _get_architecture() in [CPUArchitecture.ARM64.value, CPUArchitecture.AARCH64.value]:
4849
return "aarch64-unknown-linux-gnu"
4950
return "x86_64-unknown-linux-gnu"
5051
else:
@@ -61,9 +62,9 @@ def _get_architecture() -> str:
6162
if sys.platform == "darwin":
6263
# On macOS, we need to check if we're running under Rosetta
6364
if platform.processor() == 'arm':
64-
return 'arm64'
65+
return CPUArchitecture.ARM64.value
6566
else:
66-
return 'x86_64'
67+
return CPUArchitecture.X86_64.value
6768
elif sys.platform == "linux":
6869
return platform.machine()
6970
elif sys.platform == "win32":
@@ -251,11 +252,7 @@ def dynamically_load_library(
251252
# Default path (no library name provided in the environment)
252253
c2pa_lib = _load_single_library(c2pa_lib_name, possible_paths)
253254
if not c2pa_lib:
254-
logger.error(
255-
f"Could not find {c2pa_lib_name} in any of the search paths: {
256-
[
257-
str(p) for p in possible_paths]}")
258-
raise RuntimeError(
259-
f"Could not find {c2pa_lib_name} in any of the search paths")
255+
logger.error(f"Could not find {c2pa_lib_name} in any of the search paths: {[str(p) for p in possible_paths]}")
256+
raise RuntimeError(f"Could not find {c2pa_lib_name} in any of the search paths")
260257

261258
return c2pa_lib

0 commit comments

Comments
 (0)