|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Ludovic Henry <git@ludovic.dev> |
| 3 | +Date: Sat, 12 Sep 2026 11:16:12 +0200 |
| 4 | +Subject: [PATCH 1/2] add riscv64 to the platform-identifier tables |
| 5 | + |
| 6 | +Upstream-Status: To upstream [not yet submitted; python-wheels does not open issues/PRs on third-party repos] |
| 7 | + |
| 8 | +get_platform_identifier() (setup.py, used by bdist_wheel to pick the |
| 9 | +artifacts/ subfolder to copy into the wheel) and its runtime counterpart |
| 10 | +in src/c2pa/lib.py both fall through to the x86_64-unknown-linux-gnu |
| 11 | +branch on a native riscv64 host, since neither platform.machine() check |
| 12 | +recognises 'riscv64'. Add a riscv64gc-unknown-linux-gnu branch to each, |
| 13 | +plus the corresponding PLATFORM_EXTENSIONS/PLATFORM_FOLDERS entries and |
| 14 | +get_current_platform()'s linux_riscv64 case, matching the existing |
| 15 | +aarch64 handling. |
| 16 | + |
| 17 | +Signed-off-by: Ludovic Henry <git@ludovic.dev> |
| 18 | +--- |
| 19 | + setup.py | 6 ++++++ |
| 20 | + src/c2pa/lib.py | 3 +++ |
| 21 | + 2 files changed, 9 insertions(+) |
| 22 | + |
| 23 | +diff --git a/setup.py b/setup.py |
| 24 | +index ddf6e98..8c66a90 100644 |
| 25 | +--- a/setup.py |
| 26 | ++++ b/setup.py |
| 27 | +@@ -33,6 +33,7 @@ PLATFORM_EXTENSIONS = { |
| 28 | + 'apple-darwin': 'dylib', # universal |
| 29 | + 'linux_x86_64': 'so', |
| 30 | + 'linux_aarch64': 'so', |
| 31 | ++ 'linux_riscv64': 'so', |
| 32 | + } |
| 33 | + |
| 34 | + # Based on what c2pa-rs repo publishes |
| 35 | +@@ -44,6 +45,7 @@ PLATFORM_FOLDERS = { |
| 36 | + 'aarch64-pc-windows-msvc': 'dll', |
| 37 | + 'x86_64-unknown-linux-gnu': 'so', |
| 38 | + 'aarch64-unknown-linux-gnu': 'so', |
| 39 | ++ 'riscv64gc-unknown-linux-gnu': 'so', |
| 40 | + } |
| 41 | + |
| 42 | + # Directory structure |
| 43 | +@@ -86,6 +88,8 @@ def get_platform_identifier(target_arch=None) -> str: |
| 44 | + elif system == "linux": |
| 45 | + if target_arch == "aarch64" or platform.machine() == "aarch64": |
| 46 | + return "aarch64-unknown-linux-gnu" |
| 47 | ++ elif target_arch == "riscv64" or platform.machine() == "riscv64": |
| 48 | ++ return "riscv64gc-unknown-linux-gnu" |
| 49 | + else: |
| 50 | + return "x86_64-unknown-linux-gnu" |
| 51 | + else: |
| 52 | +@@ -115,6 +119,8 @@ def get_current_platform(): |
| 53 | + else: # Linux |
| 54 | + if platform.machine() == "aarch64": |
| 55 | + return "linux_aarch64" |
| 56 | ++ elif platform.machine() == "riscv64": |
| 57 | ++ return "linux_riscv64" |
| 58 | + return "linux_x86_64" |
| 59 | + |
| 60 | + def copy_platform_libraries(platform_name, clean_first=False): |
| 61 | +diff --git a/src/c2pa/lib.py b/src/c2pa/lib.py |
| 62 | +index be6353f..17ecbff 100644 |
| 63 | +--- a/src/c2pa/lib.py |
| 64 | ++++ b/src/c2pa/lib.py |
| 65 | +@@ -27,6 +27,7 @@ class CPUArchitecture(Enum): |
| 66 | + AARCH64 = "aarch64" |
| 67 | + X86_64 = "x86_64" |
| 68 | + ARM64 = "arm64" |
| 69 | ++ RISCV64 = "riscv64" |
| 70 | + |
| 71 | + |
| 72 | + def get_platform_identifier() -> str: |
| 73 | +@@ -61,6 +62,8 @@ def get_platform_identifier() -> str: |
| 74 | + elif system == "linux": |
| 75 | + if _get_architecture() in [CPUArchitecture.ARM64.value, CPUArchitecture.AARCH64.value]: |
| 76 | + return "aarch64-unknown-linux-gnu" |
| 77 | ++ elif _get_architecture() == CPUArchitecture.RISCV64.value: |
| 78 | ++ return "riscv64gc-unknown-linux-gnu" |
| 79 | + return "x86_64-unknown-linux-gnu" |
| 80 | + else: |
| 81 | + raise ValueError(f"Unsupported operating system: {system}") |
0 commit comments