From cf4b943ae2892cc0a1d6f59e43fe7ec54c992ff7 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Sun, 15 Mar 2026 08:15:55 +0300 Subject: [PATCH 1/2] Refactor cibw_before_all.sh to make it usable for RTFD --- .readthedocs.yaml | 14 +--- scripts/cibw_before_all.sh | 132 ++++++++++++++++++++++++------------- 2 files changed, 89 insertions(+), 57 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 638a47f6..a61a1043 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,20 +8,10 @@ build: - libgmp-dev - build-essential - pkg-config + - curl jobs: pre_create_environment: - - | - PREFIX=$(pwd)/.local - ZZ_VERSION=0.9.0a4 - ZZ_DIR=zz-${ZZ_VERSION} - GITHUB_URL=https://github.com/diofant/zz/releases/download/ - ZZ_URL=${GITHUB_URL}v${ZZ_VERSION}/${ZZ_DIR}.tar.gz - wget ${ZZ_URL} - tar xzf ${ZZ_DIR}.tar.gz - cd ${ZZ_DIR} - ./configure -q --prefix=$PREFIX - make -s - make -s install + - sh scripts/cibw_before_all.sh --skip-gmp tools: python: "3" python: diff --git a/scripts/cibw_before_all.sh b/scripts/cibw_before_all.sh index 5f7ec6ba..bfb09327 100644 --- a/scripts/cibw_before_all.sh +++ b/scripts/cibw_before_all.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -e -x +set -o errexit PREFIX=${PREFIX:-"$(pwd)/.local"} CFLAGS= @@ -14,44 +14,98 @@ download () { sleep_ivl=$((${sleep_ivl}*2)) done } +genlib () { + # -- generate *.lib files from *.dll on M$ Windows -- + cd .local/bin/ + dll_file=$1 + 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/ + cd ../../ +} -GMP_VERSION=6.3.0 -GMP_DIR=gmp-${GMP_VERSION} -GMP_URL=https://ftp.gnu.org/gnu/gmp/${GMP_DIR}.tar.xz - -download ${GMP_URL} -tar --extract --file ${GMP_DIR}.tar.xz -cd ${GMP_DIR} +SKIP_GMP=no -for f in ../scripts/*.diff +while [ $# -gt 0 ] do - patch --strip 1 < $f + key="$1" + case $key in + -h|--help) + echo "scripts/cibw_before_all.sh [options]" + echo + echo "Build local installs of python-gmp's dependencies." + echo + echo "Supported options:" + echo " --help - show this help message" + echo " --skip-gmp - skip building GMP" + echo + exit + ;; + --skip-gmp) + # If you already have a local install of GMP you can pass --skip-gmp + # to skip building it. + SKIP_GMP=yes + shift + ;; + *) + 2>&1 echo "unrecognised argument:" $key + exit 1 + ;; + esac done -CONFIG_ARGS="--enable-shared --disable-static --with-pic --disable-alloca --prefix=$PREFIX" -if [ "$OSTYPE" = "cygwin" ] +set -o xtrace + +if [ $SKIP_GMP = "no" ] then - if [ "${RUNNER_ARCH}" = "ARM64" ] + GMP_VERSION=6.3.0 + GMP_DIR=gmp-${GMP_VERSION} + GMP_URL=https://ftp.gnu.org/gnu/gmp/${GMP_DIR}.tar.xz + + download ${GMP_URL} + tar --extract --file ${GMP_DIR}.tar.xz + cd ${GMP_DIR} + + for f in ../scripts/*.diff + do + patch --strip 1 < $f + done + + CONFIG_ARGS="--enable-shared --disable-static --with-pic --disable-alloca --prefix=$PREFIX" + if [ "$OSTYPE" = "cygwin" ] then - autoreconf -fi - CONFIG_ARGS="${CONFIG_ARGS} --disable-assembly" + 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 -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 + # 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 ${CONFIG_ARGS} + ./configure ${CONFIG_ARGS} -make --silent all install + make --silent all install -cd .. + cd .. + + if [ "$OSTYPE" = "cygwin" ] + then + genlib libgmp-10.dll + fi +fi ZZ_VERSION=0.9.0a4 ZZ_DIR=zz-${ZZ_VERSION} @@ -66,31 +120,19 @@ then autoreconf -if fi -./configure --enable-shared \ - --disable-static \ - --with-pic \ - --with-gmp=$PREFIX \ - --prefix=$PREFIX +CONFIG_ARGS="--enable-shared --disable-static --with-pic --prefix=$PREFIX" +if [ $SKIP_GMP = "no" ] +then + CONFIG_ARGS="${CONFIG_ARGS} --with-gmp=$PREFIX" +fi + +./configure ${CONFIG_ARGS} 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 + genlib libzz-0.dll fi - -cd ../.. From 9928ebf184ab59ac9a00b8f6f0a9af6207f22019 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Sun, 15 Mar 2026 08:18:20 +0300 Subject: [PATCH 2/2] Use libzz v0.9.0a5 --- scripts/cibw_before_all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cibw_before_all.sh b/scripts/cibw_before_all.sh index bfb09327..5c93b410 100644 --- a/scripts/cibw_before_all.sh +++ b/scripts/cibw_before_all.sh @@ -107,7 +107,7 @@ then fi fi -ZZ_VERSION=0.9.0a4 +ZZ_VERSION=0.9.0a5 ZZ_DIR=zz-${ZZ_VERSION} ZZ_URL=https://github.com/diofant/zz/releases/download/v${ZZ_VERSION}/${ZZ_DIR}.tar.gz