Skip to content

Commit 3390747

Browse files
Merge pull request #16 from oscarbenjamin/pr_build_script
maint(build): build wheels for OSX and Linux in CI
2 parents 579df14 + 29d4250 commit 3390747

7 files changed

Lines changed: 169 additions & 0 deletions

File tree

.github/workflows/buildwheel.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build_wheels:
7+
name: Build wheels for ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
# os: [ubuntu-20.04, windows-2019, macOS-10.15]
12+
os: [ubuntu-20.04, macOS-10.15]
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: actions/setup-python@v2
17+
18+
- name: Install cibuildwheel
19+
run: python -m pip install cibuildwheel==1.10.0
20+
- name: Build wheels
21+
run: python -m cibuildwheel --output-dir wheelhouse
22+
env:
23+
CIBW_BUILD: cp37-* cp38-*
24+
CIBW_BEFORE_ALL_LINUX: bin/cibw_before_build_linux.sh
25+
CIBW_BEFORE_ALL_MACOS: bin/cibw_before_build_macosx.sh
26+
# There are problems with both older and newer cython versions...
27+
CIBW_BEFORE_BUILD: pip install numpy cython==0.27.3
28+
CIBW_ENVIRONMENT: >
29+
C_INCLUDE_PATH=$(pwd)/.local/include/
30+
LIBRARY_PATH=$(pwd)/.local/lib/
31+
LD_LIBRARY_PATH=$(pwd)/.local/lib:$LD_LIBRARY_PATH
32+
- uses: actions/upload-artifact@v2
33+
with:
34+
path: wheelhouse/*.whl

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ dist/*
33
src/*.c
44
doc/build/*
55
fmake*
6+
*.whl
67
MANIFEST
78
.eggs
9+
.local

bin/build_dependencies.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Build local installs of python-flint's dependencies.
4+
# This should be run after bin/download_dependencies.sh
5+
#
6+
7+
set -o errexit
8+
set -o xtrace
9+
10+
# Sets variables like PREFIX and dependency versions
11+
source bin/build_variables.sh
12+
13+
cd $PREFIX
14+
mkdir -p src
15+
cd src
16+
17+
curl -O https://gmplib.org/download/gmp/gmp-$GMPVER.tar.xz
18+
curl -O https://www.mpfr.org/mpfr-current/mpfr-$MPFRVER.tar.gz
19+
curl -O https://www.flintlib.org/flint-$FLINTVER.tar.gz
20+
curl -O -L https://github.com/fredrik-johansson/arb/archive/refs/tags/$ARBVER.tar.gz
21+
mv $ARBVER.tar.gz arb-$ARBVER.tar.gz
22+
23+
tar xf mpfr-$MPFRVER.tar.gz
24+
tar xf flint-$FLINTVER.tar.gz
25+
tar xf arb-$ARBVER.tar.gz
26+
tar xf gmp-$GMPVER.tar.xz
27+
28+
cd gmp-$GMPVER
29+
./configure --prefix=$PREFIX --enable-fat --enable-shared=yes --enable-static=no
30+
make -j3
31+
make install
32+
cd ..
33+
34+
cd mpfr-$MPFRVER
35+
./configure --prefix=$PREFIX --with-gmp=$PREFIX --enable-shared=yes --enable-static=no
36+
make -j3
37+
make install
38+
cd ..
39+
40+
cd flint-$FLINTVER
41+
./configure --prefix=$PREFIX --with-gmp=$PREFIX --with-mpfr=$PREFIX --disable-static
42+
make -j3
43+
make install
44+
cd ..
45+
46+
cd arb-$ARBVER
47+
./configure --prefix=$PREFIX --with-flint=$PREFIX --with-gmp=$PREFIX --with-mpfr=$PREFIX --disable-static
48+
make -j3
49+
make install
50+
cd ..
51+
52+
53+
echo
54+
echo -----------------------------------------------------------------------
55+
echo
56+
echo Build dependencies for python-flint compiled as shared libraries in:
57+
echo $PREFIX
58+
echo
59+
echo Versions:
60+
echo GMP: $GMPVER
61+
echo MPFR: $MPFRVER
62+
echo Flint: $FLINTVER
63+
echo Arb: $ARBVER
64+
echo
65+
echo -----------------------------------------------------------------------
66+
echo

bin/build_variables.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Create a local directory .local to be used as --prefix when building
4+
# local installs of python-flint's dependencies. This also sets the PREFIX
5+
# shell variable and environment variables giving the versions to use for each
6+
# dependency. This script should be sourced rather than executed e.g.:
7+
#
8+
# $ source bin/build_variables.sh
9+
#
10+
# This is used implicitly by the other build scripts and does not need to be
11+
# executed directly.
12+
13+
PREFIX=$(pwd)/.local
14+
mkdir -p $PREFIX
15+
16+
GMPVER=6.2.1
17+
MPFRVER=4.1.0
18+
FLINTVER=2.7.1
19+
ARBVER=2.19.0

bin/build_wheel.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Compile a python-flint wheel using the dependencies built by
4+
# build_dependencies.sh (which should be run first).
5+
6+
set -o errexit
7+
8+
PYTHONFLINTVER=0.3.0
9+
10+
source bin/build_variables.sh
11+
12+
python -m venv $PREFIX/venv
13+
source $PREFIX/venv/bin/activate
14+
pip install -U pip wheel delocate
15+
pip install numpy cython==0.27.3
16+
# N.B. bugs in both older and newer Cython versions...
17+
18+
C_INCLUDE_PATH=.local/include/ LIBRARY_PATH=.local/lib/ pip wheel .
19+
20+
wheelfinal=*.whl
21+
22+
# On OSX bundle the dynamic libraries for the dependencies
23+
mkdir -p wheelhouse
24+
delocate-wheel -w wheelhouse $wheelfinal
25+
26+
echo ------------------------------------------
27+
echo
28+
echo Built wheel: wheelhouse/$wheelfinal
29+
echo
30+
echo Link dependencies:
31+
delocate-listdeps wheelhouse/$wheelfinal
32+
echo
33+
pip install wheelhouse/$wheelfinal
34+
echo
35+
echo Demonstration:
36+
echo
37+
python -c 'import flint; print("(3/2)**2 =", flint.fmpq(3, 2)**2)'
38+
echo
39+
echo Done!
40+
echo
41+
echo ------------------------------------------

bin/cibw_before_build_linux.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
yum install -y xz
4+
bin/build_dependencies.sh

bin/cibw_before_build_macosx.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
bin/build_dependencies.sh

0 commit comments

Comments
 (0)