Skip to content

Commit a241c56

Browse files
authored
build riscv64 wheel (#387)
1 parent e88d9ce commit a241c56

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed

.github/workflows/wheels.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
- uses: actions/checkout@v4
7878
- name: Install cibuildwheel
7979
# Nb. keep cibuildwheel version pin consistent with job below
80-
run: pipx install cibuildwheel==2.21.3
80+
run: pipx install cibuildwheel==3.1.4
8181
- id: set-matrix
8282
# Once we have the windows build figured out, it can be added here
8383
# by updating the matrix to include windows builds as well.
@@ -126,7 +126,7 @@ jobs:
126126
platforms: all
127127

128128
- name: Build wheels
129-
uses: pypa/cibuildwheel@v2.21.3
129+
uses: pypa/cibuildwheel@v3.1.4
130130
with:
131131
only: ${{ matrix.only }}
132132
env:

doc/source/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
lxml>=3.8
1+
lxml==6.0.2
22
importlib_metadata;python_version < '3.8'
33
packaging
44
Sphinx>=3

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4", "pkgconfig>=1.5.1", "lxml>=3.8, !=4.7.0"]
2+
requires = ["setuptools==80.9.0", "wheel", "setuptools_scm[toml]>=3.4", "pkgconfig>=1.5.1", "lxml==6.0.2"]
33

44
[tool.mypy]
55
files = ['src']
@@ -100,6 +100,7 @@ build-verbosity = 1
100100
build-frontend = "build"
101101
skip = [
102102
"pp*", # Skips PyPy builds (pp38-*, pp39-*, etc.)
103+
"*musllinux_riscv64" # maturin and ruff currently don’t support the musl + riscv64 target
103104
]
104105
test-command = "pytest -v --color=yes {package}/tests"
105106
before-test = "pip install -r requirements-test.txt"
@@ -109,7 +110,7 @@ test-skip = "*-macosx_arm64"
109110
PYXMLSEC_STATIC_DEPS = "true"
110111

111112
[tool.cibuildwheel.linux]
112-
archs = ["x86_64", "aarch64"]
113+
archs = ["x86_64", "aarch64", "riscv64"]
113114
environment-pass = [
114115
"PYXMLSEC_LIBXML2_VERSION",
115116
"PYXMLSEC_LIBXSLT_VERSION",

requirements-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
pytest==8.4.1
44
lxml-stubs==0.5.1
5-
ruff[format]==0.12.3
5+
ruff[format]==0.13.0

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lxml==6.0.0
1+
lxml==6.0.2

setup.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,8 @@ def prepare_static_build(self, build_platform):
404404
ldflags.append(env['LDFLAGS'])
405405

406406
cross_compiling = False
407-
if build_platform == 'darwin':
408-
import platform
409407

408+
if build_platform == 'darwin':
410409
arch = self.plat_name.rsplit('-', 1)[1]
411410
if arch != platform.machine() and arch in ('x86_64', 'arm64'):
412411
self.info(f'Cross-compiling for {arch}')
@@ -423,6 +422,19 @@ def prepare_static_build(self, build_platform):
423422
self.info('Building OpenSSL')
424423
openssl_dir = next(self.build_libs_dir.glob('openssl-*'))
425424
openssl_config_cmd = [prefix_arg, 'no-shared', '-fPIC', '--libdir=lib']
425+
if platform.machine() == 'riscv64':
426+
# add `no-asm` flag for openssl while build for riscv64
427+
428+
# on openssl 3.5.2, When building for riscv64, ASM code is used by default.
429+
# However, this version of the assembly code will report during the build:
430+
431+
# relocation truncated to fit: R_RISCV_JAL against symbol `AES_set_encrypt_key' defined in .text section in /project/build/tmp/prefix/lib/libcrypto.a(libcrypto-lib-aes-riscv64.o) # noqa: E501
432+
433+
# This [line] (https://github.com/openssl/openssl/blob/0893a62353583343eb712adef6debdfbe597c227/crypto/aes/asm/aes-riscv64.pl#L1069) of code cannot be completed normally because the jump address of the static link library used by xmlsec is too large. # noqa: E501
434+
# may be we can consider filing a related issue with OpenSSL later.
435+
# However, for now, for convenience, we can simply disable ASM for riscv64.
436+
# This will result in some performance degradation, but this is acceptable.
437+
openssl_config_cmd.append('no-asm')
426438
if cross_compiling:
427439
openssl_config_cmd.insert(0, './Configure')
428440
openssl_config_cmd.append(cross_compiling.triplet)

0 commit comments

Comments
 (0)