From f96249bfdfc7f1d1476f115431d6db9dc8fb3521 Mon Sep 17 00:00:00 2001 From: ffgan Date: Wed, 15 Oct 2025 21:09:29 +0800 Subject: [PATCH 1/7] build riscv64 wheel Co-authored by: nijincheng@iscas.ac.cn; --- .github/workflows/wheels.yml | 4 ++-- doc/source/requirements.txt | 2 +- pyproject.toml | 7 +++++-- requirements-test.txt | 2 +- requirements.txt | 2 +- setup.py | 16 ++++++++++++++-- 6 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index f29019f0..d9cad9ce 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -77,7 +77,7 @@ jobs: - uses: actions/checkout@v4 - name: Install cibuildwheel # Nb. keep cibuildwheel version pin consistent with job below - run: pipx install cibuildwheel==2.21.3 + run: pipx install cibuildwheel==3.1.4 - id: set-matrix # Once we have the windows build figured out, it can be added here # by updating the matrix to include windows builds as well. @@ -126,7 +126,7 @@ jobs: platforms: all - name: Build wheels - uses: pypa/cibuildwheel@v2.21.3 + uses: pypa/cibuildwheel@v3.1.4 with: only: ${{ matrix.only }} env: diff --git a/doc/source/requirements.txt b/doc/source/requirements.txt index 6b78694a..ffb2b6d3 100644 --- a/doc/source/requirements.txt +++ b/doc/source/requirements.txt @@ -1,4 +1,4 @@ -lxml>=3.8 +lxml==6.0.2 importlib_metadata;python_version < '3.8' packaging Sphinx>=3 diff --git a/pyproject.toml b/pyproject.toml index bb0c459e..b688cf57 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4", "pkgconfig>=1.5.1", "lxml>=3.8, !=4.7.0"] +requires = ["setuptools==80.9.0", "wheel", "setuptools_scm[toml]>=3.4", "pkgconfig>=1.5.1", "lxml==6.0.2"] [tool.mypy] files = ['src'] @@ -100,6 +100,7 @@ build-verbosity = 1 build-frontend = "build" skip = [ "pp*", # Skips PyPy builds (pp38-*, pp39-*, etc.) + "*musllinux_riscv64" ] test-command = "pytest -v --color=yes {package}/tests" before-test = "pip install -r requirements-test.txt" @@ -109,7 +110,7 @@ test-skip = "*-macosx_arm64" PYXMLSEC_STATIC_DEPS = "true" [tool.cibuildwheel.linux] -archs = ["x86_64", "aarch64"] +archs = ["x86_64", "aarch64", "riscv64"] environment-pass = [ "PYXMLSEC_LIBXML2_VERSION", "PYXMLSEC_LIBXSLT_VERSION", @@ -117,6 +118,8 @@ environment-pass = [ "GH_TOKEN" ] +[tool.setuptools_scm] + [tool.cibuildwheel.macos] archs = ["x86_64", "arm64"] before-all = "brew install perl" diff --git a/requirements-test.txt b/requirements-test.txt index 52a31f00..ad135d97 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -2,4 +2,4 @@ pytest==8.4.1 lxml-stubs==0.5.1 -ruff[format]==0.12.3 +ruff[format]==0.13.0 diff --git a/requirements.txt b/requirements.txt index 7aa6718b..8221c374 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -lxml==6.0.0 +lxml==6.0.2 diff --git a/setup.py b/setup.py index 014476ca..33805623 100644 --- a/setup.py +++ b/setup.py @@ -404,9 +404,8 @@ def prepare_static_build(self, build_platform): ldflags.append(env['LDFLAGS']) cross_compiling = False + import platform if build_platform == 'darwin': - import platform - arch = self.plat_name.rsplit('-', 1)[1] if arch != platform.machine() and arch in ('x86_64', 'arm64'): self.info(f'Cross-compiling for {arch}') @@ -423,6 +422,19 @@ def prepare_static_build(self, build_platform): self.info('Building OpenSSL') openssl_dir = next(self.build_libs_dir.glob('openssl-*')) openssl_config_cmd = [prefix_arg, 'no-shared', '-fPIC', '--libdir=lib'] + if platform.machine() == "riscv64": + # add `no-asm` flag for openssl while build for riscv64 + + # on openssl 3.5.2, When building for riscv64, ASM code is used by default. + # However, this version of the assembly code will report during the build: + + # 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) + + # 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. + # may be we can consider filing a related issue with OpenSSL later. + # However, for now, for convenience, we can simply disable ASM for riscv64. + # This will result in some performance degradation, but this is acceptable. + openssl_config_cmd.append('no-asm') if cross_compiling: openssl_config_cmd.insert(0, './Configure') openssl_config_cmd.append(cross_compiling.triplet) From a41297cfbcc102d1f5ebb7e15e894403acfd4416 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 15 Oct 2025 15:23:56 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- setup.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 33805623..6517fad7 100644 --- a/setup.py +++ b/setup.py @@ -405,6 +405,7 @@ def prepare_static_build(self, build_platform): cross_compiling = False import platform + if build_platform == 'darwin': arch = self.plat_name.rsplit('-', 1)[1] if arch != platform.machine() and arch in ('x86_64', 'arm64'): @@ -422,17 +423,17 @@ def prepare_static_build(self, build_platform): self.info('Building OpenSSL') openssl_dir = next(self.build_libs_dir.glob('openssl-*')) openssl_config_cmd = [prefix_arg, 'no-shared', '-fPIC', '--libdir=lib'] - if platform.machine() == "riscv64": + if platform.machine() == 'riscv64': # add `no-asm` flag for openssl while build for riscv64 - # on openssl 3.5.2, When building for riscv64, ASM code is used by default. + # on openssl 3.5.2, When building for riscv64, ASM code is used by default. # However, this version of the assembly code will report during the build: # 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) - + # 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. - # may be we can consider filing a related issue with OpenSSL later. - # However, for now, for convenience, we can simply disable ASM for riscv64. + # may be we can consider filing a related issue with OpenSSL later. + # However, for now, for convenience, we can simply disable ASM for riscv64. # This will result in some performance degradation, but this is acceptable. openssl_config_cmd.append('no-asm') if cross_compiling: From e5968449644c5d0a0d350fcc0a2a5f17f5831cc5 Mon Sep 17 00:00:00 2001 From: ffgan Date: Wed, 15 Oct 2025 23:39:29 +0800 Subject: [PATCH 3/7] fix line too long error Co-authored by: nijincheng@iscas.ac.cn; --- setup.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 6517fad7..ed679b0c 100644 --- a/setup.py +++ b/setup.py @@ -429,9 +429,14 @@ def prepare_static_build(self, build_platform): # on openssl 3.5.2, When building for riscv64, ASM code is used by default. # However, this version of the assembly code will report during the build: - # 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) - - # 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. + # 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) + + # 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. # may be we can consider filing a related issue with OpenSSL later. # However, for now, for convenience, we can simply disable ASM for riscv64. # This will result in some performance degradation, but this is acceptable. From 23276d887d635802f95b193fa3a3a804541043a0 Mon Sep 17 00:00:00 2001 From: ffgan Date: Thu, 16 Oct 2025 15:53:27 +0800 Subject: [PATCH 4/7] fix line too long error by add # noqa: E501 --- setup.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index ed679b0c..ac91d768 100644 --- a/setup.py +++ b/setup.py @@ -429,14 +429,9 @@ def prepare_static_build(self, build_platform): # on openssl 3.5.2, When building for riscv64, ASM code is used by default. # However, this version of the assembly code will report during the build: - # 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) - - # 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. + # 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 + + # 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 # may be we can consider filing a related issue with OpenSSL later. # However, for now, for convenience, we can simply disable ASM for riscv64. # This will result in some performance degradation, but this is acceptable. From 5add35eb44ee23cfb95c6d49e428c5c4c13d5107 Mon Sep 17 00:00:00 2001 From: ffgan Date: Thu, 16 Oct 2025 16:26:39 +0800 Subject: [PATCH 5/7] remove unused code Co-authored by: nijincheng@iscas.ac.cn; --- pyproject.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b688cf57..85243595 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -118,8 +118,6 @@ environment-pass = [ "GH_TOKEN" ] -[tool.setuptools_scm] - [tool.cibuildwheel.macos] archs = ["x86_64", "arm64"] before-all = "brew install perl" From 8b52d01bebe360011e0f52804483af770af93ae5 Mon Sep 17 00:00:00 2001 From: ffgan Date: Thu, 16 Oct 2025 16:31:38 +0800 Subject: [PATCH 6/7] remove unused code Co-authored by: nijincheng@iscas.ac.cn; --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index ac91d768..624169c4 100644 --- a/setup.py +++ b/setup.py @@ -404,7 +404,6 @@ def prepare_static_build(self, build_platform): ldflags.append(env['LDFLAGS']) cross_compiling = False - import platform if build_platform == 'darwin': arch = self.plat_name.rsplit('-', 1)[1] From 6d9a727aa0794deced219bf3eeb73f578749d644 Mon Sep 17 00:00:00 2001 From: ffgan Date: Thu, 16 Oct 2025 19:29:33 +0800 Subject: [PATCH 7/7] add comment to clarify musllinux_riscv64 skip in cibuildwheel configuration --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 85243595..2b2d2d04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,7 +100,7 @@ build-verbosity = 1 build-frontend = "build" skip = [ "pp*", # Skips PyPy builds (pp38-*, pp39-*, etc.) - "*musllinux_riscv64" + "*musllinux_riscv64" # maturin and ruff currently don’t support the musl + riscv64 target ] test-command = "pytest -v --color=yes {package}/tests" before-test = "pip install -r requirements-test.txt"