Skip to content

Commit 22cc77c

Browse files
Merge pull request #80 from GiacomoPope/flint3
Bump to Flint version 3
2 parents 243d896 + 1e28c4f commit 22cc77c

31 files changed

+232
-148
lines changed

bin/build_dependencies_unix.sh

+173-71
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,46 @@ set -o errexit
1616
# #
1717
# ------------------------------------------------------------------------- #
1818

19+
SKIP_GMP=no
20+
SKIP_MPFR=no
21+
1922
USE_GMP=gmp
2023
PATCH_GMP_ARM64=no
24+
BUILD_ARB=no
2125

2226
while [[ $# -gt 0 ]]
2327
do
2428
key="$1"
2529
case $key in
2630
-h|--help)
27-
echo "bin/download_dependencies.sh [--gmp gmp|mpir] [--host HOST]"
31+
echo "bin/download_dependencies.sh [options]"
32+
echo
33+
echo "Build local installs of python-flint's dependencies."
34+
echo
35+
echo "Supported options:"
36+
echo " --help - show this help message"
37+
echo " --host <HOST> - set the host (target) for GMP build"
38+
echo " --skip-gmp - skip building GMP"
39+
echo " --skip-mpfr - skip building MPFR"
40+
echo
41+
echo "Legacy options:"
42+
echo " --gmp gmp - build based on GMP (default)"
43+
echo " --gmp mpir - build based on MPIR (no longer works)"
44+
echo " --patch-gmp-arm64 - apply patch to GMP 6.2.1 for OSX arm64"
45+
echo " --arb - build Arb (only needed for flint < 3.0.0)"
46+
echo
2847
exit
2948
;;
49+
--host)
50+
# e.g. --host x86_64-unknown-linux-gnu
51+
# or --host x86_64-apple-darwin
52+
HOST_ARG="$2"
53+
shift
54+
shift
55+
;;
3056
--gmp)
3157
# e.g. --gmp gmp or --gmp mpir
58+
# The mpir build no longer works because the download fails.
3259
USE_GMP="$2"
3360
if [[ "$USE_GMP" != "gmp" && "$USE_GMP" != "mpir" ]]; then
3461
echo "--gmp option should be gmp or mpir"
@@ -37,14 +64,27 @@ do
3764
shift
3865
shift
3966
;;
40-
--host)
41-
# e.g. --host x86_64-unknown-linux-gnu
42-
# or --host x86_64-apple-darwin
43-
HOST_ARG="$2"
67+
--arb)
68+
# With flint >= 3.0.0 Arb is included so we do not need to build it
69+
# separately. Pass --arb if building for older versions of flint.
70+
BUILD_ARB=yes
4471
shift
72+
;;
73+
--skip-gmp)
74+
# If you already have a local install of GMP you can pass --skip-gmp
75+
# to skip building it.
76+
SKIP_GMP=yes
77+
shift
78+
;;
79+
--skip-mpfr)
80+
# If you already have a local install of MPFR you can pass --skip-mpfr
81+
# to skip building it.
82+
SKIP_MPFR=yes
4583
shift
4684
;;
4785
--patch-gmp-arm64)
86+
# Needed only for GMP 6.2.1 on OSX arm64 (Apple M1) hardware
87+
# As of GMP 6.3.0 this patch is no longer needed
4888
PATCH_GMP_ARM64=yes
4989
shift
5090
;;
@@ -86,42 +126,60 @@ if [ $USE_GMP = "gmp" ]; then
86126
# #
87127
# ----------------------------------------------------------------------- #
88128

89-
if [ $USE_GMP_GITHUB_MIRROR = "yes" ]; then
90-
# Needed in GitHub Actions because it is blocked from gmplib.org
91-
git clone https://github.com/oscarbenjamin/gmp_mirror.git
92-
cp gmp_mirror/gmp-$GMPVER.tar.xz .
129+
if [ $SKIP_GMP = "yes" ]; then
130+
echo
131+
echo --------------------------------------------
132+
echo " skipping GMP"
133+
echo --------------------------------------------
134+
echo
93135
else
94-
curl -O https://gmplib.org/download/gmp/gmp-$GMPVER.tar.xz
95-
fi
136+
echo
137+
echo --------------------------------------------
138+
echo " building GMP"
139+
echo --------------------------------------------
140+
echo
141+
142+
if [ $USE_GMP_GITHUB_MIRROR = "yes" ]; then
143+
# Needed in GitHub Actions because it is blocked from gmplib.org
144+
git clone https://github.com/oscarbenjamin/gmp_mirror.git
145+
cp gmp_mirror/gmp-$GMPVER.tar.xz .
146+
else
147+
curl -O https://gmplib.org/download/gmp/gmp-$GMPVER.tar.xz
148+
fi
96149

97-
tar xf gmp-$GMPVER.tar.xz
98-
cd gmp-$GMPVER
150+
tar xf gmp-$GMPVER.tar.xz
151+
cd gmp-$GMPVER
152+
153+
#
154+
# See https://github.com/aleaxit/gmpy/issues/350
155+
#
156+
# We need to patch GMP for OSX arm64 (Apple M1) hardware. This patch is
157+
# from the GMP repo but was applied after the release of GMP 6.2.1.
158+
# This patch is no longer needed for GMP 6.3.0.
159+
#
160+
if [ $PATCH_GMP_ARM64 = "yes" ]; then
161+
echo
162+
echo --------------------------------------------
163+
echo " patching GMP"
164+
echo --------------------------------------------
165+
patch -N -Z -p0 < ../../../bin/patch-arm64.diff
166+
fi
99167

100-
#
101-
# See https://github.com/aleaxit/gmpy/issues/350
102-
#
103-
# We need to patch GMP for OSX arm64 (Apple M1) hardware for GMP 6.2.1.
104-
# Now with GMP 6.3.0 this should not be needed any more.
105-
#
106-
if [ $PATCH_GMP_ARM64 = "yes" ]; then
107-
echo
108-
echo --------------------------------------------
109-
echo " patching GMP"
110-
echo --------------------------------------------
111-
patch -N -Z -p0 < ../../../bin/patch-arm64.diff
112-
fi
168+
# Show the output of configfsf.guess
169+
chmod +x configfsf.guess
170+
./configfsf.guess
113171

114-
# Show the output of configfsf.guess
115-
chmod +x configfsf.guess
116-
./configfsf.guess
117-
./configure --prefix=$PREFIX\
118-
--enable-fat\
119-
--enable-shared=yes\
120-
--enable-static=no\
121-
--host=$HOST_ARG
122-
make -j3
123-
make install
124-
cd ..
172+
./configure --prefix=$PREFIX\
173+
--enable-fat\
174+
--enable-shared=yes\
175+
--enable-static=no\
176+
--host=$HOST_ARG
177+
make -j3
178+
make install
179+
180+
cd ..
181+
182+
fi
125183

126184
FLINTARB_WITHGMP="--with-gmp=$PREFIX"
127185

@@ -182,26 +240,47 @@ fi
182240
# #
183241
# ------------------------------------------------------------------------- #
184242

185-
curl -O https://ftp.gnu.org/gnu/mpfr/mpfr-$MPFRVER.tar.gz
186-
tar xf mpfr-$MPFRVER.tar.gz
187-
cd mpfr-$MPFRVER
188-
./configure --prefix=$PREFIX\
189-
--with-gmp=$PREFIX\
190-
--enable-shared=yes\
191-
--enable-static=no
192-
make -j3
193-
make install
194-
cd ..
243+
if [ $SKIP_MPFR = "yes" ]; then
244+
echo
245+
echo --------------------------------------------
246+
echo " skipping MPFR"
247+
echo --------------------------------------------
248+
echo
249+
else
250+
echo
251+
echo --------------------------------------------
252+
echo " building MPFR"
253+
echo --------------------------------------------
254+
echo
255+
256+
curl -O https://ftp.gnu.org/gnu/mpfr/mpfr-$MPFRVER.tar.gz
257+
tar xf mpfr-$MPFRVER.tar.gz
258+
cd mpfr-$MPFRVER
259+
./configure --prefix=$PREFIX\
260+
--with-gmp=$PREFIX\
261+
--enable-shared=yes\
262+
--enable-static=no
263+
make -j3
264+
make install
265+
cd ..
266+
fi
195267

196268
# ------------------------------------------------------------------------- #
197269
# #
198270
# FLINT #
199271
# #
200272
# ------------------------------------------------------------------------- #
201273

274+
echo
275+
echo --------------------------------------------
276+
echo " building Flint"
277+
echo --------------------------------------------
278+
echo
279+
202280
curl -O -L https://www.flintlib.org/flint-$FLINTVER.tar.gz
203281
tar xf flint-$FLINTVER.tar.gz
204282
cd flint-$FLINTVER
283+
./bootstrap.sh
205284
./configure --prefix=$PREFIX\
206285
$FLINTARB_WITHGMP\
207286
--with-mpfr=$PREFIX\
@@ -216,25 +295,34 @@ cd ..
216295
# #
217296
# ------------------------------------------------------------------------- #
218297

219-
curl -O -L https://github.com/fredrik-johansson/arb/archive/refs/tags/$ARBVER.tar.gz
220-
mv $ARBVER.tar.gz arb-$ARBVER.tar.gz
221-
tar xf arb-$ARBVER.tar.gz
222-
cd arb-$ARBVER
223-
./configure --prefix=$PREFIX\
224-
--with-flint=$PREFIX\
225-
$FLINTARB_WITHGMP\
226-
--with-mpfr=$PREFIX\
227-
--disable-static
228-
make -j3
229-
make install
230-
#
231-
# Set PATH so that DLLs are picked up on Windows.
232-
#
233-
PATH=$PATH:$PREFIX/lib:$PREFIX/bin \
234-
ARB_TEST_MULTIPLIER=0.1 \
235-
# Skip Arb tests now because they are slow.
236-
# make check
237-
cd ..
298+
if [ $BUILD_ARB = "yes" ]; then
299+
300+
echo
301+
echo --------------------------------------------
302+
echo " building Arb"
303+
echo --------------------------------------------
304+
echo
305+
306+
curl -O -L https://github.com/fredrik-johansson/arb/archive/refs/tags/$ARBVER.tar.gz
307+
mv $ARBVER.tar.gz arb-$ARBVER.tar.gz
308+
tar xf arb-$ARBVER.tar.gz
309+
cd arb-$ARBVER
310+
./configure --prefix=$PREFIX\
311+
--with-flint=$PREFIX\
312+
$FLINTARB_WITHGMP\
313+
--with-mpfr=$PREFIX\
314+
--disable-static
315+
make -j3
316+
make install
317+
#
318+
# Set PATH so that DLLs are picked up on Windows.
319+
#
320+
PATH=$PATH:$PREFIX/lib:$PREFIX/bin \
321+
ARB_TEST_MULTIPLIER=0.1 \
322+
# Skip Arb tests now because they are slow.
323+
# make check
324+
cd ..
325+
fi
238326

239327
# ------------------------------------------------------------------------- #
240328
# #
@@ -249,14 +337,28 @@ echo Build dependencies for python-flint compiled as shared libraries in:
249337
echo $PREFIX
250338
echo
251339
echo Versions:
252-
if [[ $USE_GMP = "gmp" ]]; then
253-
echo GMP: $GMPVER
340+
341+
if [ $SKIP_GMP = "yes" ]; then
342+
echo GMP: skipped
254343
else
255-
echo MPIR: $MPIRVER
344+
if [[ $USE_GMP = "gmp" ]]; then
345+
echo GMP: $GMPVER
346+
else
347+
echo MPIR: $MPIRVER
348+
fi
256349
fi
257-
echo MPFR: $MPFRVER
350+
351+
if [ $SKIP_MPFR = "yes" ]; then
352+
echo MPFR: skipped
353+
else
354+
echo MPFR: $MPFRVER
355+
fi
356+
258357
echo Flint: $FLINTVER
259-
echo Arb: $ARBVER
358+
359+
if [ $BUILD_ARB = "yes" ]; then
360+
echo Arb: $ARBVER
361+
fi
260362
echo
261363
echo -----------------------------------------------------------------------
262364
echo

bin/build_variables.sh

+7-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
PREFIX=$(pwd)/.local
1414
mkdir -p $PREFIX
1515

16+
ARBVER=2.23.0 # Not needed with flint >= 3.0.0 (Arb is included in flint)
17+
18+
YASMVER=1.3.0 # Only needed for MPIR
19+
MPIRVER=3.0.0 # MPIR build no longer works (not clear where to download from)
20+
21+
# These are the actual dependencies used (at least by default):
1622
GMPVER=6.3.0
17-
YASMVER=1.3.0
18-
MPIRVER=3.0.0
1923
MPFRVER=4.1.0
20-
FLINTVER=2.9.0
21-
ARBVER=2.23.0
24+
FLINTVER=3.0.0-alpha1

bin/cibw_before_all_macosx_arm64.sh

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
export CPPFLAGS=" --target=arm64-apple-macos11"
44
export LDFLAGS=" -arch arm64"
55

6+
brew install automake libtool
7+
68
bin/build_dependencies_unix.sh\
79
--gmp gmp\
810
--host aarch64-apple-darwin\

bin/cibw_before_all_macosx_x86_64.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22

3+
brew install automake libtool
4+
35
bin/build_dependencies_unix.sh\
46
--gmp gmp\
57
--host x86_64-apple-darwin\

bin/cibw_before_all_windows.sh

+11-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@ echo '[build]' > setup.cfg
1313
echo 'compiler = mingw32' >> setup.cfg
1414
cat setup.cfg
1515

16-
# Install the mingw-w64 toolchain
17-
pacman -S --noconfirm mingw-w64-x86_64-gcc m4 make mingw-w64-x86_64-tools-git
16+
# Install the mingw-w64 toolchain and build tools
17+
pacman -S --noconfirm \
18+
mingw-w64-x86_64-gcc\
19+
mingw-w64-x86_64-tools-git\
20+
m4\
21+
make\
22+
base-devel\
23+
autoconf-wrapper\
24+
automake-wrapper\
25+
libtool\
26+
#
1827

1928
# This takes ~30mins
2029
bin/build_dependencies_unix.sh --use-gmp-github-mirror

bin/cibw_repair_wheel_command_windows.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ wheeldir=$(dirname $WHEELNAME)
2929
echo $wheeldir
3030

3131
# delvewheel requires DLLs created by mingw64 to be stripped. This strips the
32-
# DLLs for GMP etc that will have been build previously.
33-
strip .local/bin/*.dll .local/lib/*.dll
32+
# DLLs for GMP etc that will have been built in the CIBW_BEFORE_ALL step.
33+
#
34+
# Previously the Arb DLLs would have been placed in .local/lib, but as of
35+
# flint 3.0.0 all DLLs aRe in .local/bin.
36+
strip .local/bin/*.dll
3437

3538
# Make sure to leave the wheel in the same directory
3639
wheeldir=$(dirname $WHEELNAME)
@@ -47,4 +50,4 @@ popd
4750
# .pyd files that are needed for the wheel.
4851
delvewheel repair $WHEELNAME \
4952
-w $WHEELHOUSE \
50-
--add-path .local/bin:.local/lib/
53+
--add-path .local/bin

0 commit comments

Comments
 (0)