Skip to content

Commit a5cc0fc

Browse files
committed
fix: SPlit mac wheels
1 parent 64d3819 commit a5cc0fc

File tree

3 files changed

+50
-7
lines changed

3 files changed

+50
-7
lines changed

scripts/download_artifacts.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def get_platform_identifier():
4444
"""Get the full platform identifier (arch-os) for the current system,
4545
matching the identifiers used by the Github publisher.
4646
Returns one of:
47-
- universal-apple-darwin (for Mac)
47+
- universal-apple-darwin (for Mac, when CPU arch is None)
48+
- aarch64-apple-darwin (for Mac ARM64)
49+
- x86_64-apple-darwin (for Mac Intel)
4850
- x86_64-pc-windows-msvc (for Windows 64-bit)
4951
- x86_64-unknown-linux-gnu (for Linux x86_64)
5052
- aarch64-unknown-linux-gnu (for Linux ARM64)
@@ -53,7 +55,15 @@ def get_platform_identifier():
5355
machine = platform.machine().lower()
5456

5557
if system == "darwin":
56-
return "universal-apple-darwin"
58+
# Identify the CPU architecture for macOS
59+
current_arch = detect_arch()
60+
if current_arch == "aarch64":
61+
return "aarch64-apple-darwin"
62+
elif current_arch == "x86_64":
63+
return "x86_64-apple-darwin"
64+
else:
65+
# Fallback to universal if architecture detection fails
66+
return "universal-apple-darwin"
5767
elif system == "windows":
5868
return "x86_64-pc-windows-msvc"
5969
elif system == "linux":
@@ -92,7 +102,7 @@ def download_and_extract_libs(url, platform_name):
92102
for member in zip_ref.namelist():
93103
print(f" Processing zip member: {member}")
94104
if member.startswith("lib/") and not member.endswith("/"):
95-
print(f" Processing lib file from downloadedzip: {member}")
105+
print(f" Processing lib file from downloaded zip: {member}")
96106
target_path = platform_dir / os.path.relpath(member, "lib")
97107
print(f" Moving file to target path: {target_path}")
98108
target_path.parent.mkdir(parents=True, exist_ok=True)

setup.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ def get_version():
3535
PACKAGE_LIBS_DIR = Path('src/c2pa/libs') # Where libraries will be copied for the wheel
3636

3737

38+
def detect_arch():
39+
"""Detect the CPU architecture and return the corresponding identifier."""
40+
machine = platform.machine().lower()
41+
42+
# Handle common architecture names
43+
if machine in ["x86_64", "amd64"]:
44+
return "x86_64"
45+
elif machine in ["arm64", "aarch64"]:
46+
return "aarch64"
47+
else:
48+
raise ValueError(f"Unsupported CPU architecture: {machine}")
49+
50+
3851
def get_platform_identifier() -> str:
3952
"""Get a platform identifier (arch-os) for the current system,
4053
matching downloaded identifiers used by the Github publisher.
@@ -44,15 +57,25 @@ def get_platform_identifier() -> str:
4457
cpu_arch: Optional CPU architecture for macOS. If not provided, returns universal build.
4558
4659
Returns one of:
47-
- universal-apple-darwin (for macOS)
60+
- universal-apple-darwin (for Mac, when CPU arch is None)
61+
- aarch64-apple-darwin (for Mac ARM64)
62+
- x86_64-apple-darwin (for Mac Intel)
4863
- x86_64-pc-windows-msvc (for Windows 64-bit)
4964
- x86_64-unknown-linux-gnu (for Linux 64-bit)
5065
- aarch64-unknown-linux-gnu (for Linux ARM64)
5166
"""
5267
system = platform.system().lower()
5368

5469
if system == "darwin":
55-
return "universal-apple-darwin"
70+
# Identify the CPU architecture for macOS
71+
current_arch = detect_arch()
72+
if current_arch == "aarch64":
73+
return "aarch64-apple-darwin"
74+
elif current_arch == "x86_64":
75+
return "x86_64-apple-darwin"
76+
else:
77+
# Fallback to universal if architecture detection fails
78+
return "universal-apple-darwin"
5679
elif system == "windows":
5780
return "x86_64-pc-windows-msvc"
5881
elif system == "linux":

src/c2pa/lib.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,25 @@ def get_platform_identifier() -> str:
3333
matching the downloaded identifiers used by the Github publisher.
3434
3535
Returns one of:
36-
- universal-apple-darwin (for Mac, ARM or Intel)
36+
- universal-apple-darwin (for Mac, when CPU arch is None)
37+
- aarch64-apple-darwin (for Mac ARM64)
38+
- x86_64-apple-darwin (for Mac Intel)
3739
- x86_64-pc-windows-msvc (for Windows 64-bit)
3840
- x86_64-unknown-linux-gnu (for Linux 64-bit)
3941
- aarch64-unknown-linux-gnu (for Linux ARM)
4042
"""
4143
system = platform.system().lower()
4244

4345
if system == "darwin":
44-
return "universal-apple-darwin"
46+
# Identify the CPU architecture for macOS
47+
current_arch = _get_architecture()
48+
if current_arch == CPUArchitecture.ARM64.value:
49+
return "aarch64-apple-darwin"
50+
elif current_arch == CPUArchitecture.X86_64.value:
51+
return "x86_64-apple-darwin"
52+
else:
53+
# Fallback to universal if architecture detection fails
54+
return "universal-apple-darwin"
4555
elif system == "windows":
4656
return "x86_64-pc-windows-msvc"
4757
elif system == "linux":

0 commit comments

Comments
 (0)