Skip to content

Commit 1a68cff

Browse files
Merge pull request #17 from oscarbenjamin/pr_build_script
maint: build wheels for Linux and OSX in CI
2 parents 3390747 + b671ee4 commit 1a68cff

6 files changed

Lines changed: 213 additions & 70 deletions

bin/build_dependencies.sh

Lines changed: 0 additions & 66 deletions
This file was deleted.

bin/build_dependencies_unix.sh

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Build local installs of python-flint's dependencies. This should be run
4+
# before attempting to build python-flint itself.
5+
6+
set -o errexit
7+
8+
# ------------------------------------------------------------------------- #
9+
# #
10+
# Supported options: #
11+
# #
12+
# --gmp gmp - build based on GMP (default) #
13+
# --gmp mpir - build based on MPIR (instead of GMP) #
14+
# #
15+
# ------------------------------------------------------------------------- #
16+
17+
USE_GMP=gmp
18+
19+
while [[ $# -gt 0 ]]
20+
do
21+
key="$1"
22+
case $key in
23+
-h|--help)
24+
echo "bin/download_dependencies.sh [--gmp gmp|mpir] [--host HOST]"
25+
exit
26+
;;
27+
--gmp)
28+
# e.g. --gmp gmp or --gmp mpir
29+
USE_GMP="$2"
30+
if [[ "$USE_GMP" != "gmp" && "$USE_GMP" != "mpir" ]]; then
31+
echo "--gmp option should be gmp or mpir"
32+
exit 1
33+
fi
34+
shift
35+
shift
36+
;;
37+
--host)
38+
# e.g. --host x86_64-unknown-linux-gnu
39+
# or --host x86_64-apple-darwin
40+
HOST_ARG="$2"
41+
shift
42+
shift
43+
;;
44+
esac
45+
done
46+
47+
# ------------------------------------------------------------------------- #
48+
# #
49+
# The build_variables.sh script sets variables specifying the versions to #
50+
# use for all dependencies and also the PREFIX variable. #
51+
# #
52+
# ------------------------------------------------------------------------- #
53+
54+
source bin/build_variables.sh
55+
56+
cd $PREFIX
57+
mkdir -p src
58+
cd src
59+
60+
# ------------------------------------------------------------------------- #
61+
# #
62+
# Now build all dependencies. #
63+
# #
64+
# ------------------------------------------------------------------------- #
65+
66+
if [ $USE_GMP = "gmp" ]; then
67+
68+
# ----------------------------------------------------------------------- #
69+
# #
70+
# GMP #
71+
# #
72+
# ----------------------------------------------------------------------- #
73+
74+
curl -O https://gmplib.org/download/gmp/gmp-$GMPVER.tar.xz
75+
tar xf gmp-$GMPVER.tar.xz
76+
cd gmp-$GMPVER
77+
./configure --prefix=$PREFIX\
78+
--enable-fat\
79+
--enable-shared=yes\
80+
--enable-static=no\
81+
--host=$HOSTARG
82+
make -j3
83+
make install
84+
cd ..
85+
86+
FLINTARB_WITHGMP="--with-gmp=$PREFIX"
87+
88+
else
89+
90+
# ----------------------------------------------------------------------- #
91+
# #
92+
# YASM (needed to build MPIR) #
93+
# #
94+
# ----------------------------------------------------------------------- #
95+
96+
curl -O http://www.tortall.net/projects/yasm/releases/yasm-$YASMVER.tar.gz
97+
tar xf yasm-$YASMVER.tar.gz
98+
cd yasm-$YASMVER
99+
./configure --prefix=$PREFIX
100+
make -j3
101+
make install
102+
cd ..
103+
104+
# ----------------------------------------------------------------------- #
105+
# #
106+
# MPIR #
107+
# #
108+
# ----------------------------------------------------------------------- #
109+
110+
curl -O http://mpir.org/mpir-$MPIRVER.tar.bz2
111+
tar xf mpir-$MPIRVER.tar.bz2
112+
cd mpir-$MPIRVER
113+
./configure --prefix=$PREFIX\
114+
--with-yasm=$PREFIX/bin/yasm\
115+
--enable-fat\
116+
--enable-shared=yes\
117+
--enable-static=no\
118+
--enable-gmpcompat
119+
make -j3
120+
make install
121+
cd ..
122+
123+
FLINTARB_WITHGMP="--with-mpir=$PREFIX"
124+
125+
fi
126+
127+
# ------------------------------------------------------------------------- #
128+
# #
129+
# MPFR #
130+
# #
131+
# ------------------------------------------------------------------------- #
132+
133+
curl -O https://www.mpfr.org/mpfr-current/mpfr-$MPFRVER.tar.gz
134+
tar xf mpfr-$MPFRVER.tar.gz
135+
cd mpfr-$MPFRVER
136+
./configure --prefix=$PREFIX\
137+
--with-gmp=$PREFIX\
138+
--enable-shared=yes\
139+
--enable-static=no
140+
make -j3
141+
make install
142+
cd ..
143+
144+
# ------------------------------------------------------------------------- #
145+
# #
146+
# FLINT #
147+
# #
148+
# ------------------------------------------------------------------------- #
149+
150+
curl -O https://www.flintlib.org/flint-$FLINTVER.tar.gz
151+
tar xf flint-$FLINTVER.tar.gz
152+
cd flint-$FLINTVER
153+
./configure --prefix=$PREFIX\
154+
$FLINTARB_WITHGMP\
155+
--with-mpfr=$PREFIX\
156+
--disable-static
157+
make -j3
158+
make install
159+
cd ..
160+
161+
# ------------------------------------------------------------------------- #
162+
# #
163+
# ARB #
164+
# #
165+
# ------------------------------------------------------------------------- #
166+
167+
curl -O -L https://github.com/fredrik-johansson/arb/archive/refs/tags/$ARBVER.tar.gz
168+
mv $ARBVER.tar.gz arb-$ARBVER.tar.gz
169+
tar xf arb-$ARBVER.tar.gz
170+
cd arb-$ARBVER
171+
./configure --prefix=$PREFIX\
172+
--with-flint=$PREFIX\
173+
$FLINTARB_WITHGMP\
174+
--with-mpfr=$PREFIX\
175+
--disable-static
176+
make -j3
177+
make install
178+
cd ..
179+
180+
# ------------------------------------------------------------------------- #
181+
# #
182+
# Done! #
183+
# #
184+
# ------------------------------------------------------------------------- #
185+
186+
echo
187+
echo -----------------------------------------------------------------------
188+
echo
189+
echo Build dependencies for python-flint compiled as shared libraries in:
190+
echo $PREFIX
191+
echo
192+
echo Versions:
193+
if [[ $USE_GMP = "gmp" ]]; then
194+
echo GMP: $GMPVER
195+
else
196+
echo MPIR: $MPIRVER
197+
fi
198+
echo MPFR: $MPFRVER
199+
echo Flint: $FLINTVER
200+
echo Arb: $ARBVER
201+
echo
202+
echo -----------------------------------------------------------------------
203+
echo

bin/build_variables.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ PREFIX=$(pwd)/.local
1414
mkdir -p $PREFIX
1515

1616
GMPVER=6.2.1
17+
YASMVER=1.3.1
18+
MPIRVER=3.0.0
1719
MPFRVER=4.1.0
1820
FLINTVER=2.7.1
1921
ARBVER=2.19.0

bin/build_wheel.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env bash
22
#
33
# Compile a python-flint wheel using the dependencies built by
4-
# build_dependencies.sh (which should be run first).
4+
# build_dependencies_unix.sh (which should be run first).
55

66
set -o errexit
77

88
PYTHONFLINTVER=0.3.0
99

1010
source bin/build_variables.sh
1111

12-
python -m venv $PREFIX/venv
12+
python3 -m venv $PREFIX/venv
1313
source $PREFIX/venv/bin/activate
1414
pip install -U pip wheel delocate
1515
pip install numpy cython==0.27.3

bin/cibw_before_build_linux.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env bash
22

33
yum install -y xz
4-
bin/build_dependencies.sh
4+
bin/build_dependencies_unix.sh\
5+
--gmp gmp\
6+
--host x86_64-unknown-linux-gnu

bin/cibw_before_build_macosx.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/usr/bin/env bash
22

3-
bin/build_dependencies.sh
3+
bin/build_dependencies_unix.sh\
4+
--gmp gmp\
5+
--host x86_64-apple-darwin

0 commit comments

Comments
 (0)