Skip to content

Commit

Permalink
merge scripts/before_ci_build.sh and scripts/before_ci_build_windows.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Mar 8, 2024
1 parent e538a34 commit dfb4ebb
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 93 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/ &&
Expand Down
74 changes: 57 additions & 17 deletions scripts/before_ci_build.sh
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
64 changes: 0 additions & 64 deletions scripts/before_ci_build_windows.sh

This file was deleted.

19 changes: 9 additions & 10 deletions scripts/repair_ci_wheel.sh
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit dfb4ebb

Please sign in to comment.