From a4007f93f27b89deaa08c783108265134c53d7ff Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 2 Dec 2025 08:38:42 +0300 Subject: [PATCH] Enable tests and build wheels for windows-11-arm * use MSVC on Windows * add CURL_OPTS --- .github/workflows/os.yml | 33 ++++++++++++--------- .github/workflows/wheels.yml | 15 ++++++++-- pyproject.toml | 5 ++-- scripts/cibw_before_all.sh | 56 +++++++++++++++++++++++++++++------- 4 files changed, 79 insertions(+), 30 deletions(-) diff --git a/.github/workflows/os.yml b/.github/workflows/os.yml index b6f06947..ea93c3d7 100644 --- a/.github/workflows/os.yml +++ b/.github/workflows/os.yml @@ -8,15 +8,23 @@ jobs: matrix: os: [ubuntu-24.04, ubuntu-24.04-arm, macos-15-intel, macos-15] shell: [bash] + msystem: [ucrt64] + menv: [ucrt-x86_64] include: - os: windows-2022 shell: 'msys2 {0}' + msystem: ucrt64 + menv: ucrt-x86_64 + - os: windows-11-arm + shell: 'msys2 {0}' + msystem: clangarm64 + menv: clang-aarch64 defaults: run: shell: ${{ matrix.shell }} env: PYTEST_ADDOPTS: --verbose --hypothesis-profile=default - CFLAGS: -Wall -Wpedantic -Werror -std=c17 -Wconversion +# CFLAGS: -Wall -Wpedantic -Werror -std=c17 -Wconversion MACOSX_DEPLOYMENT_TARGET: 10.15 # for 3.14 steps: - uses: actions/checkout@v6 @@ -28,13 +36,16 @@ jobs: - uses: msys2/setup-msys2@v2.29.0 with: install: >- - mingw-w64-ucrt-x86_64-pkg-config - mingw-w64-ucrt-x86_64-gcc + mingw-w64-${{ matrix.menv }}-binutils + mingw-w64-${{ matrix.menv }}-gcc + mingw-w64-${{ matrix.menv }}-pkg-config + mingw-w64-${{ matrix.menv }}-tools diffutils m4 make patch - msystem: ucrt64 + autotools + msystem: ${{ matrix.msystem }} path-type: inherit if: ${{ startsWith(matrix.os, 'windows') }} - name: Cache GNU GMP builds @@ -43,19 +54,15 @@ jobs: with: path: .local key: ${{ matrix.os }}-${{ hashFiles('scripts/*') }} - - run: bash scripts/cibw_before_all.sh + - run: sh scripts/cibw_before_all.sh if: steps.cache-gmp.outputs.cache-hit != 'true' - - run: python -m pip install --upgrade pip - run: | - # XXX: this is for M$ Windows, see msys2/setup-msys2#171 - PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:$(pwd)/.local/lib/pkgconfig - pip --verbose wheel . -Csetup-args=-Dbuildtype=debug + export PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig + pip --verbose wheel . -Csetup-args=-Dbuildtype=debug -Csetup-args=--vsenv + # https://mesonbuild.com/meson-python/how-to-guides/shared-libraries - run: | - # XXX: this is too, see - # https://mesonbuild.com/meson-python/how-to-guides/shared-libraries - PATH="$PATH:$(pwd)/.local/bin" pip install delvewheel - delvewheel repair *.whl + delvewheel repair *.whl --add-path .local/bin mv wheelhouse/*.whl . if: ${{ startsWith(matrix.os, 'windows') }} - run: | diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 0d9b3d17..7a751b1f 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -8,6 +8,12 @@ jobs: matrix: os: [ubuntu-24.04, ubuntu-24.04-arm, macos-15-intel, macos-15, windows-2022] + msystem: [ucrt64] + menv: [ucrt-x86_64] + include: + - os: windows-11-arm + msystem: clangarm64 + menv: clang-aarch64 steps: - uses: actions/checkout@v6 with: @@ -16,12 +22,15 @@ jobs: name: Setup msys2 with: install: >- - mingw-w64-ucrt-x86_64-gcc + mingw-w64-${{ matrix.menv }}-binutils + mingw-w64-${{ matrix.menv }}-gcc + mingw-w64-${{ matrix.menv }}-tools diffutils m4 make patch - msystem: ucrt64 + autotools + msystem: ${{ matrix.msystem }} if: ${{ startsWith(matrix.os, 'windows') }} # Install pkgconfig on Windows from choco rather than from msys and # avoid using the Strawberry one. @@ -30,7 +39,7 @@ jobs: # We have to set this here rather than in the cibuildwheel config # This is probably something to do with \ vs / in paths... - run: echo "PKG_CONFIG_PATH=${{ github.workspace }}/.local/lib/pkgconfig" >> $env:GITHUB_ENV - if: ${{ startsWith( matrix.os , 'windows' ) }} + if: ${{ startsWith(matrix.os, 'windows') }} - name: Build wheels uses: pypa/cibuildwheel@v3.3.0 - uses: actions/upload-artifact@v5 diff --git a/pyproject.toml b/pyproject.toml index 7c230c7d..41bd7f30 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,7 @@ line-length = 79 select = ["E", "F", "I", "PT", "W", "Q", "SIM"] [tool.cibuildwheel] -build-frontend = {name="build", args=["--verbose"]} +build-frontend = {name="build", args=["--verbose", "-Csetup-args=--vsenv"]} enable = "pypy cpython-prerelease cpython-freethreading graalpy" skip = """*-win32 gp311_242* *-manylinux_i686 *-musllinux_* \ *-manylinux_armv7l pp*aarch64* gp3*win*""" @@ -86,5 +86,4 @@ repair-wheel-command = """delvewheel repair -w {dest_dir} {wheel} \ --add-path .local/bin""" [tool.cibuildwheel.windows.environment] -PYTEST_ADDOPTS = "--verbose" -CFLAGS = "-Wall -Wpedantic -Werror -std=c17 -Wconversion" +CFLAGS = "" diff --git a/scripts/cibw_before_all.sh b/scripts/cibw_before_all.sh index 7e949d4a..6b64771f 100644 --- a/scripts/cibw_before_all.sh +++ b/scripts/cibw_before_all.sh @@ -7,8 +7,9 @@ GMP_DIR=gmp-${GMP_VERSION} GMP_URL=https://ftp.gnu.org/gnu/gmp/${GMP_DIR}.tar.xz PREFIX="$(pwd)/.local/" CFLAGS= +CURL_OPTS="--location --retry 3 --connect-timeout 30" -curl --retry 3 --silent --remote-name ${GMP_URL} +curl ${CURL_OPTS} --remote-name ${GMP_URL} tar --extract --file ${GMP_DIR}.tar.xz cd ${GMP_DIR} @@ -17,18 +18,26 @@ do patch --strip 1 < $f done +CONFIG_ARGS="--enable-shared --disable-static --with-pic --disable-alloca --prefix=$PREFIX" +if [ "$OSTYPE" = "cygwin" ] +then + if [ "${RUNNER_ARCH}" = "ARM64" ] + then + autoreconf -fi + CONFIG_ARGS="${CONFIG_ARGS} --disable-assembly" + else + CONFIG_ARGS="${CONFIG_ARGS} --enable-fat" + fi +else + CONFIG_ARGS="${CONFIG_ARGS} --enable-fat" +fi + # config.guess uses microarchitecture and configfsf.guess doesn't # We replace config.guess with configfsf.guess to avoid microarchitecture # specific code in common code. rm config.guess && mv configfsf.guess config.guess && chmod +x config.guess -./configure --enable-fat \ - --enable-shared \ - --disable-static \ - --with-pic \ - --disable-alloca \ - --prefix=$PREFIX \ - --quiet +./configure ${CONFIG_ARGS} make --silent all install @@ -38,15 +47,40 @@ ZZ_VERSION=0.6.1 ZZ_DIR=zz-${ZZ_VERSION} ZZ_URL=https://github.com/diofant/zz/releases/download/v${ZZ_VERSION}/${ZZ_DIR}.tar.gz -curl --location --retry 3 --silent --remote-name ${ZZ_URL} +curl ${CURL_OPTS} --remote-name ${ZZ_URL} tar --extract --file ${ZZ_DIR}.tar.gz cd ${ZZ_DIR} -./configure --quiet \ - --enable-shared \ +if [ "$OSTYPE" = "cygwin" ] && [ "${RUNNER_ARCH}" = "ARM64" ] +then + autoreconf -if +fi + +./configure --enable-shared \ --disable-static \ --with-pic \ --with-gmp=$PREFIX \ --prefix=$PREFIX make --silent all install + +cd ../ + +# -- generate *.lib files from *.dll on M$ Windows -- +if [ "$OSTYPE" = "cygwin" ] +then + cd .local/bin + for dll_file in libgmp-10.dll libzz-0.dll + do + lib_name=$(basename -s .dll ${dll_file}) + name=$(echo ${lib_name}|sed 's/^lib//;s/-[0-9]\+//') + + gendef ${dll_file} + dlltool -d ${lib_name}.def -l ${name}.lib + + cp ${name}.lib ../lib/ + cp ${dll_file} ../lib/ + done +fi + +cd ../..