|
19 | 19 | ARTIFACTS_DIR = Path('artifacts') # Where downloaded libraries are stored |
20 | 20 | PACKAGE_LIBS_DIR = Path('src/c2pa/libs') # Where libraries will be copied for the wheel |
21 | 21 |
|
| 22 | + |
| 23 | +def get_platform_identifier(cpu_arch = None) -> str: |
| 24 | + """Get a platform identifier (arch-os) for the current system, |
| 25 | + matching downloaded identifiers used by the Github publisher. |
| 26 | +
|
| 27 | + Args: |
| 28 | + Only used on macOS systems.: |
| 29 | + cpu_arch: Optional CPU architecture for macOS. If not provided, returns universal build. |
| 30 | +
|
| 31 | + Returns one of: |
| 32 | + - universal-apple-darwin (for Mac, when cpu_arch is None, fallback) |
| 33 | + - aarch64-apple-darwin (for Mac ARM64) |
| 34 | + - x86_64-apple-darwin (for Mac x86_64) |
| 35 | + - x86_64-pc-windows-msvc (for Windows 64-bit) |
| 36 | + - x86_64-unknown-linux-gnu (for Linux 64-bit) |
| 37 | + """ |
| 38 | + system = platform.system().lower() |
| 39 | + |
| 40 | + if system == "darwin": |
| 41 | + if cpu_arch is None: |
| 42 | + return "universal-apple-darwin" |
| 43 | + elif cpu_arch == "arm64": |
| 44 | + return "aarch64-apple-darwin" |
| 45 | + elif cpu_arch == "x86_64": |
| 46 | + return "x86_64-apple-darwin" |
| 47 | + else: |
| 48 | + raise ValueError(f"Unsupported CPU architecture for macOS: {cpu_arch}") |
| 49 | + elif system == "windows": |
| 50 | + return "x86_64-pc-windows-msvc" |
| 51 | + elif system == "linux": |
| 52 | + return "x86_64-unknown-linux-gnu" |
| 53 | + else: |
| 54 | + raise ValueError(f"Unsupported operating system: {system}") |
| 55 | + |
22 | 56 | def get_current_platform(): |
23 | 57 | """Determine the current platform name.""" |
24 | 58 | if sys.platform == "win32": |
@@ -93,7 +127,8 @@ def find_available_platforms(): |
93 | 127 |
|
94 | 128 | # For development installation |
95 | 129 | if 'develop' in sys.argv or 'install' in sys.argv: |
96 | | - current_platform = get_current_platform() |
| 130 | + current_platform = get_platform_identifier() |
| 131 | + print("Installing in development mode for platform ", current_platform) |
97 | 132 | copy_platform_libraries(current_platform) |
98 | 133 |
|
99 | 134 | # For wheel building |
|
0 commit comments