Skip to content

Commit cf4b943

Browse files
committed
Refactor cibw_before_all.sh to make it usable for RTFD
1 parent 234096d commit cf4b943

2 files changed

Lines changed: 89 additions & 57 deletions

File tree

.readthedocs.yaml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,10 @@ build:
88
- libgmp-dev
99
- build-essential
1010
- pkg-config
11+
- curl
1112
jobs:
1213
pre_create_environment:
13-
- |
14-
PREFIX=$(pwd)/.local
15-
ZZ_VERSION=0.9.0a4
16-
ZZ_DIR=zz-${ZZ_VERSION}
17-
GITHUB_URL=https://github.com/diofant/zz/releases/download/
18-
ZZ_URL=${GITHUB_URL}v${ZZ_VERSION}/${ZZ_DIR}.tar.gz
19-
wget ${ZZ_URL}
20-
tar xzf ${ZZ_DIR}.tar.gz
21-
cd ${ZZ_DIR}
22-
./configure -q --prefix=$PREFIX
23-
make -s
24-
make -s install
14+
- sh scripts/cibw_before_all.sh --skip-gmp
2515
tools:
2616
python: "3"
2717
python:

scripts/cibw_before_all.sh

Lines changed: 87 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
set -e -x
3+
set -o errexit
44

55
PREFIX=${PREFIX:-"$(pwd)/.local"}
66
CFLAGS=
@@ -14,44 +14,98 @@ download () {
1414
sleep_ivl=$((${sleep_ivl}*2))
1515
done
1616
}
17+
genlib () {
18+
# -- generate *.lib files from *.dll on M$ Windows --
19+
cd .local/bin/
20+
dll_file=$1
21+
lib_name=$(basename -s .dll ${dll_file})
22+
name=$(echo ${lib_name}|sed 's/^lib//;s/-[0-9]\+//')
23+
24+
gendef ${dll_file}
25+
dlltool -d ${lib_name}.def -l ${name}.lib
26+
27+
cp ${name}.lib ../lib/
28+
cp ${dll_file} ../lib/
29+
cd ../../
30+
}
1731

18-
GMP_VERSION=6.3.0
19-
GMP_DIR=gmp-${GMP_VERSION}
20-
GMP_URL=https://ftp.gnu.org/gnu/gmp/${GMP_DIR}.tar.xz
21-
22-
download ${GMP_URL}
23-
tar --extract --file ${GMP_DIR}.tar.xz
24-
cd ${GMP_DIR}
32+
SKIP_GMP=no
2533

26-
for f in ../scripts/*.diff
34+
while [ $# -gt 0 ]
2735
do
28-
patch --strip 1 < $f
36+
key="$1"
37+
case $key in
38+
-h|--help)
39+
echo "scripts/cibw_before_all.sh [options]"
40+
echo
41+
echo "Build local installs of python-gmp's dependencies."
42+
echo
43+
echo "Supported options:"
44+
echo " --help - show this help message"
45+
echo " --skip-gmp - skip building GMP"
46+
echo
47+
exit
48+
;;
49+
--skip-gmp)
50+
# If you already have a local install of GMP you can pass --skip-gmp
51+
# to skip building it.
52+
SKIP_GMP=yes
53+
shift
54+
;;
55+
*)
56+
2>&1 echo "unrecognised argument:" $key
57+
exit 1
58+
;;
59+
esac
2960
done
3061

31-
CONFIG_ARGS="--enable-shared --disable-static --with-pic --disable-alloca --prefix=$PREFIX"
32-
if [ "$OSTYPE" = "cygwin" ]
62+
set -o xtrace
63+
64+
if [ $SKIP_GMP = "no" ]
3365
then
34-
if [ "${RUNNER_ARCH}" = "ARM64" ]
66+
GMP_VERSION=6.3.0
67+
GMP_DIR=gmp-${GMP_VERSION}
68+
GMP_URL=https://ftp.gnu.org/gnu/gmp/${GMP_DIR}.tar.xz
69+
70+
download ${GMP_URL}
71+
tar --extract --file ${GMP_DIR}.tar.xz
72+
cd ${GMP_DIR}
73+
74+
for f in ../scripts/*.diff
75+
do
76+
patch --strip 1 < $f
77+
done
78+
79+
CONFIG_ARGS="--enable-shared --disable-static --with-pic --disable-alloca --prefix=$PREFIX"
80+
if [ "$OSTYPE" = "cygwin" ]
3581
then
36-
autoreconf -fi
37-
CONFIG_ARGS="${CONFIG_ARGS} --disable-assembly"
82+
if [ "${RUNNER_ARCH}" = "ARM64" ]
83+
then
84+
autoreconf -fi
85+
CONFIG_ARGS="${CONFIG_ARGS} --disable-assembly"
86+
else
87+
CONFIG_ARGS="${CONFIG_ARGS} --enable-fat"
88+
fi
3889
else
3990
CONFIG_ARGS="${CONFIG_ARGS} --enable-fat"
4091
fi
41-
else
42-
CONFIG_ARGS="${CONFIG_ARGS} --enable-fat"
43-
fi
4492

45-
# config.guess uses microarchitecture and configfsf.guess doesn't
46-
# We replace config.guess with configfsf.guess to avoid microarchitecture
47-
# specific code in common code.
48-
rm config.guess && mv configfsf.guess config.guess && chmod +x config.guess
93+
# config.guess uses microarchitecture and configfsf.guess doesn't
94+
# We replace config.guess with configfsf.guess to avoid microarchitecture
95+
# specific code in common code.
96+
rm config.guess && mv configfsf.guess config.guess && chmod +x config.guess
4997

50-
./configure ${CONFIG_ARGS}
98+
./configure ${CONFIG_ARGS}
5199

52-
make --silent all install
100+
make --silent all install
53101

54-
cd ..
102+
cd ..
103+
104+
if [ "$OSTYPE" = "cygwin" ]
105+
then
106+
genlib libgmp-10.dll
107+
fi
108+
fi
55109

56110
ZZ_VERSION=0.9.0a4
57111
ZZ_DIR=zz-${ZZ_VERSION}
@@ -66,31 +120,19 @@ then
66120
autoreconf -if
67121
fi
68122

69-
./configure --enable-shared \
70-
--disable-static \
71-
--with-pic \
72-
--with-gmp=$PREFIX \
73-
--prefix=$PREFIX
123+
CONFIG_ARGS="--enable-shared --disable-static --with-pic --prefix=$PREFIX"
124+
if [ $SKIP_GMP = "no" ]
125+
then
126+
CONFIG_ARGS="${CONFIG_ARGS} --with-gmp=$PREFIX"
127+
fi
128+
129+
./configure ${CONFIG_ARGS}
74130

75131
make --silent all install
76132

77133
cd ../
78134

79-
# -- generate *.lib files from *.dll on M$ Windows --
80135
if [ "$OSTYPE" = "cygwin" ]
81136
then
82-
cd .local/bin
83-
for dll_file in libgmp-10.dll libzz-0.dll
84-
do
85-
lib_name=$(basename -s .dll ${dll_file})
86-
name=$(echo ${lib_name}|sed 's/^lib//;s/-[0-9]\+//')
87-
88-
gendef ${dll_file}
89-
dlltool -d ${lib_name}.def -l ${name}.lib
90-
91-
cp ${name}.lib ../lib/
92-
cp ${dll_file} ../lib/
93-
done
137+
genlib libzz-0.dll
94138
fi
95-
96-
cd ../..

0 commit comments

Comments
 (0)