From dfb4ebbcdbe5ddf09562b1afc409901b1fc4508c Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Thu, 7 Mar 2024 17:41:16 +0300 Subject: [PATCH] merge scripts/before_ci_build.sh and scripts/before_ci_build_windows.sh --- .github/workflows/build_wheels.yml | 4 +- scripts/before_ci_build.sh | 74 +++++++++++++++++++++++------- scripts/before_ci_build_windows.sh | 64 -------------------------- scripts/repair_ci_wheel.sh | 19 ++++---- 4 files changed, 68 insertions(+), 93 deletions(-) delete mode 100644 scripts/before_ci_build_windows.sh diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 09e18881..55708287 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -35,13 +35,13 @@ jobs: CIBW_BEFORE_BUILD: bash scripts/before_ci_build.sh CIBW_BEFORE_ALL_WINDOWS: > pip install delvewheel && - msys2 -c scripts/before_ci_build_windows.sh && + msys2 -c scripts/before_ci_build.sh && call mingw64/dll2lib.bat 64 "D:\a\_temp\msys64\ucrt64\bin\libgmp-10.dll" gmp && call mingw64/dll2lib.bat 64 "D:\a\_temp\msys64\ucrt64\bin\libmpfr-6.dll" mpfr && call mingw64/dll2lib.bat 64 "D:\a\_temp\msys64\ucrt64\bin\libmpc-3.dll" mpc && msys2 -c scripts/repair_ci_wheel_windows.sh CIBW_BEFORE_BUILD_WINDOWS: > - msys2 -c scripts/before_ci_build_windows.sh + msys2 -c scripts/before_ci_build.sh CIBW_TEST_EXTRAS: tests CIBW_TEST_COMMAND: > pytest {package}/test/ && diff --git a/scripts/before_ci_build.sh b/scripts/before_ci_build.sh index 1a580278..da5e1a4d 100644 --- a/scripts/before_ci_build.sh +++ b/scripts/before_ci_build.sh @@ -1,25 +1,65 @@ +#!/bin/sh + set -e -x GMP_VERSION=6.3.0 MPFR_VERSION=4.2.1 MPC_VERSION=1.3.1 -if [ ! -f finish_before_ci_build ]; then - if [[ "$OSTYPE" == "linux-gnu" || "$OSTYPE" == "linux-musl" || "$OSTYPE" == "darwin"* ]]; then - curl -s -O https://ftp.gnu.org/gnu/gmp/gmp-${GMP_VERSION}.tar.xz - tar -xf gmp-${GMP_VERSION}.tar.xz - cd gmp-${GMP_VERSION} - # 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 && make -j4 && make install && cd ../ - curl -s -O https://ftp.gnu.org/gnu/mpfr/mpfr-${MPFR_VERSION}.tar.gz - tar -xf mpfr-${MPFR_VERSION}.tar.gz - cd mpfr-${MPFR_VERSION} && ./configure && make -j4 && make install && cd ../ - curl -s -O https://ftp.gnu.org/gnu/mpc/mpc-${MPC_VERSION}.tar.gz - tar -xf mpc-${MPC_VERSION}.tar.gz - cd mpc-${MPC_VERSION} && ./configure && make -j4 && make install && cd ../ - fi + +if [ "$OSTYPE" == "msys" ] +then + PREFIX="/ucrt64" +else + PREFIX="/usr/local" +fi + +CWD=$(pwd) + +if [ ! -f finish_before_ci_build ] +then + # -- build GMP -- + curl -s -O https://ftp.gnu.org/gnu/gmp/gmp-${GMP_VERSION}.tar.xz + tar -xf gmp-${GMP_VERSION}.tar.xz + cd gmp-${GMP_VERSION} + # 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 + make -j6 + make install + cd ../ + + # -- build MPFR + curl -s -O https://ftp.gnu.org/gnu/mpfr/mpfr-${MPFR_VERSION}.tar.gz + tar -xf mpfr-${MPFR_VERSION}.tar.gz + cd mpfr-${MPFR_VERSION} + ./configure --enable-shared \ + --disable-static \ + --with-gmp-include=$CWD/gmp-${GMP_VERSION}/ \ + --with-gmp-lib=$CWD/gmp-${GMP_VERSION}/.libs/ + make -j6 + make install + cd ../ + # -- build MPC -- + curl -s -O https://ftp.gnu.org/gnu/mpc/mpc-${MPC_VERSION}.tar.gz + tar -xf mpc-${MPC_VERSION}.tar.gz + cd mpc-${MPC_VERSION} + ./configure --enable-shared \ + --disable-static \ + --with-gmp-include=$CWD/gmp-${GMP_VERSION}/ \ + --with-gmp-lib=$CWD/gmp-${GMP_VERSION}/.libs/ \ + --with-mpfr-include=$CWD/mpfr-${MPFR_VERSION}/src/ \ + --with-mpfr-lib=$CWD/mpfr-${MPFR_VERSION}/src/.libs/ + make -j6 + make install + cd ../ + + # -- copy headers -- + cp $PREFIX/include/{gmp,mpfr,mpc}.h gmpy2/ + touch finish_before_ci_build else (cd gmp-*[0-9] && make install) diff --git a/scripts/before_ci_build_windows.sh b/scripts/before_ci_build_windows.sh deleted file mode 100644 index cd1b1830..00000000 --- a/scripts/before_ci_build_windows.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/sh - -set -e -x - -GMP_VERSION=6.3.0 -MPFR_VERSION=4.2.1 -MPC_VERSION=1.3.1 - -# OSTYPE: msys -PREFIX=/ucrt64 - -CWD=$(pwd) - -if [ ! -f finish_before_ci_build ] -then - # -- build GMP -- - curl -s -O https://ftp.gnu.org/gnu/gmp/gmp-${GMP_VERSION}.tar.xz - tar -xf gmp-${GMP_VERSION}.tar.xz - cd gmp-${GMP_VERSION} - # 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 - make -j6 - make install - cd ../ - - # -- build MPFR - curl -s -O https://ftp.gnu.org/gnu/mpfr/mpfr-${MPFR_VERSION}.tar.gz - tar -xf mpfr-${MPFR_VERSION}.tar.gz - cd mpfr-${MPFR_VERSION} - ./configure --enable-shared \ - --disable-static \ - --with-gmp-include=$CWD/gmp-${GMP_VERSION}/ \ - --with-gmp-lib=$CWD/gmp-${GMP_VERSION}/.libs/ - make -j6 - make install - cd ../ - # -- build MPC -- - curl -s -O https://ftp.gnu.org/gnu/mpc/mpc-${MPC_VERSION}.tar.gz - tar -xf mpc-${MPC_VERSION}.tar.gz - cd mpc-${MPC_VERSION} - ./configure --enable-shared \ - --disable-static \ - --with-gmp-include=$CWD/gmp-${GMP_VERSION}/ \ - --with-gmp-lib=$CWD/gmp-${GMP_VERSION}/.libs/ \ - --with-mpfr-include=$CWD/mpfr-${MPFR_VERSION}/src/ \ - --with-mpfr-lib=$CWD/mpfr-${MPFR_VERSION}/src/.libs/ - make -j6 - make install - cd ../ - - # -- copy headers -- - cp $PREFIX/include/{gmp,mpfr,mpc}.h gmpy2/ - - touch finish_before_ci_build -else - (cd gmp-*[0-9] && make install) - (cd mpfr-*[0-9] && make install) - (cd mpc-*[0-9] && make install) -fi diff --git a/scripts/repair_ci_wheel.sh b/scripts/repair_ci_wheel.sh index 0c55b371..7268ffea 100644 --- a/scripts/repair_ci_wheel.sh +++ b/scripts/repair_ci_wheel.sh @@ -1,17 +1,16 @@ -dest_dir=$1 -wheel=$2 -wheel unpack --dest ${dest_dir} ${wheel} -cp /usr/local/include/{gmp,mpfr,mpc}.h ${dest_dir}/gmpy2-*/gmpy2/ -(cd ${dest_dir} && wheel pack gmpy2-*[0-9]) -cp ${dest_dir}/gmpy2-*.whl ${wheel} -rm -rf ${dest_dir}/* +#!/bin/bash + +DEST_DIR=$1 +WHEEL=$2 + if [[ "$OSTYPE" == "darwin"* ]] then - delocate-wheel --require-archs $3 --lib-sdir ../gmpy2.libs -w ${dest_dir} -v ${wheel} + delocate-wheel --require-archs $3 --lib-sdir ../gmpy2.libs -w ${DEST_DIR} -v ${WHEEL} else - auditwheel repair -w ${dest_dir} ${wheel} + auditwheel repair -w ${DEST_DIR} ${WHEEL} fi -# cleanup libs from before_ci_build*.sh + +# cleanup libs from before_ci_build.sh (cd gmp-*[0-9] && make uninstall) (cd mpfr-*[0-9] && make uninstall) (cd mpc-*[0-9] && make uninstall)