Skip to content

Commit 3a754a3

Browse files
committed
Add tests for installing on Linux
1 parent bde3dbd commit 3a754a3

File tree

4 files changed

+142
-8
lines changed

4 files changed

+142
-8
lines changed

.github/workflows/buildwheel.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,27 @@ jobs:
100100
path: wheelhouse
101101
- run: pip install --find-links wheelhouse python_flint
102102
- run: python test/dtest.py
103+
104+
test_pip_linux_vcs:
105+
name: Install from git checkout on Ubuntu
106+
runs-on: ubuntu-22.04
107+
steps:
108+
- uses: actions/checkout@v3
109+
- uses: actions/setup-python@v4
110+
with:
111+
python-version: 3.11
112+
- run: bin/pip_install_ubuntu.sh . # Install from checkout
113+
- run: python test/test.py
114+
- run: python test/dtest.py
115+
116+
test_pip_linux_pypi:
117+
name: Install from PyPI sdist on Ubuntu
118+
runs-on: ubuntu-22.04
119+
steps:
120+
- uses: actions/checkout@v3
121+
- uses: actions/setup-python@v4
122+
with:
123+
python-version: 3.11
124+
- run: bin/pip_install_ubuntu.sh python-flint # Install from PyPI sdist
125+
- run: python test/test.py
126+
- run: python test/dtest.py

README.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,38 @@ Author: Fredrik Johansson <[email protected]>
1818
Installation
1919
------------
2020

21-
First install both FLINT (version 2.5 or later) and Arb (version 2.15 or later).
22-
See:
21+
On Windows (x86-64) or OSX (x86-64 or arm64) there are prebuilt wheels for
22+
python-flint 0.4.0 that can be installed from PyPI using pip
23+
24+
pip install python-flint
25+
26+
There is currently a problem with the Linux wheels and so for now Linux wheels
27+
are not available on PyPI. Instead for Linux first install both FLINT 2.9.0 and
28+
Arb 2.23. Note that as of python-flint 0.4.0 only these *exact* versions of
29+
FLINT and Arb will work. While some Linux distributions may provide FLINT and
30+
Arb it is unlikely that they will provide the exact versions required (e.g.
31+
for Ubuntu only Ubuntu 23.04 provides these versions at the time of writing).
32+
33+
See here for instructions on building FLINT and Arb:
2334

2435
* http://flintlib.org/
2536
* http://arblib.org/
2637

27-
The latest release of Python-FLINT can then be installed using:
38+
The latest release of Python-FLINT can then be built and installed using:
2839

29-
pip install python-flint
40+
pip install 'cython>=3' numpy wheel
41+
pip install --no-build-isolation python-flint
3042

31-
Python-FLINT can also be installed git checkout or a source archive
43+
Python-FLINT can also be installed from a git checkout or a source archive
3244
as follows:
3345

34-
pip install .
46+
pip install 'cython>=3' numpy wheel
47+
pip install --no-build-isolation .
48+
49+
A script that builds and installs FLINT, Arb and Python-FLINT that is tested on
50+
Ubuntu can be found in the git repo here:
51+
52+
https://github.com/fredrik-johansson/python-flint/blob/master/bin/pip_install_ubuntu.sh
3553

3654
See the documentation for further notes on building and installing
3755
Python-FLINT:
@@ -95,7 +113,6 @@ To do
95113
* Conversions to and from external types (numpy, sage, sympy, mpmath, gmpy)
96114
* Improved printing and string input/output
97115
* IPython hooks (TeX pretty-printing etc.)
98-
* Windows support
99116

100117
License
101118
------------

bin/pip_install_ubuntu.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
5+
# This script should work to install python-flint on Ubuntu from a VCS checkout
6+
#
7+
# $ git checkout https://github.com/fredrik-johansson/python-flint.git
8+
# $ bin/pip_install_ubuntu.sh .
9+
#
10+
# To install an sdist from PyPI, use
11+
#
12+
# $ bin/pip_install_ubuntu.sh python-flint
13+
#
14+
15+
# Install runtime and build dependencies
16+
17+
# The commented commands below would attempt to build python-flint against a
18+
# system installation of Flint and Arb in Ubuntu.
19+
#
20+
# Ubuntu 23.04 has Flint 2.9.0 and Arb 2.23.0, so this script might work there
21+
# (for python-flint 0.4.0). That is untested though (23.04 not available in CI).
22+
#
23+
# With Ubuntu 22.04, this will build but then crashes when running the tests.
24+
# most likely this is because the versions of flint and flint-arb are too old.
25+
# At the time of writing in Ubuntu 22.04 there is Flint 2.8.4 and Arb 2.22. The
26+
# main CI tests and wheels for python-flint 0.4.0 are built with Flint 2.9.0
27+
# and Arb 2.23.0.
28+
#
29+
# Link against libflint-arb instead of libarb on Ubuntu
30+
# export PYTHON_FLINT_LIBFLINT_ARB=1
31+
# sudo apt-get update
32+
# sudo apt-get install libflint-dev libflint-arb-dev
33+
34+
35+
# Build Flint and Arb manually
36+
#
37+
# First install their dependencies and build dependencies
38+
sudo apt-get update
39+
sudo apt-get install libgmp-dev libmpfr-dev xz-utils
40+
41+
# Only these *EXACT* versions will work.
42+
FLINTVER=2.9.0
43+
ARBVER=2.23.0
44+
45+
# This will default to installing in /usr/local. If you want to install in a
46+
# non-standard location then configure flint with
47+
# ./configure --disable-static --prefix=$PREFIX
48+
# and arb with
49+
# ./configure --disable-static --prefix=$PREFIX --with-flint=$PREFIX
50+
# If $PREFIX is no in default search paths, then at build time set
51+
# export C_INCLUDE_PATH=$PREFIX/include
52+
# and at runtime set
53+
# export LD_LIBRARY_PATH=$PREFIX/lib
54+
55+
curl -O -L https://www.flintlib.org/flint-$FLINTVER.tar.gz
56+
tar xf flint-$FLINTVER.tar.gz
57+
cd flint-$FLINTVER
58+
./configure --disable-static
59+
make -j
60+
sudo make install
61+
cd ..
62+
63+
curl -O -L https://github.com/fredrik-johansson/arb/archive/refs/tags/$ARBVER.tar.gz
64+
mv $ARBVER.tar.gz arb-$ARBVER.tar.gz
65+
tar xf arb-$ARBVER.tar.gz
66+
cd arb-$ARBVER
67+
./configure --disable-static
68+
make -j
69+
sudo make install
70+
cd ..
71+
72+
ls -l /usr/local/lib
73+
sudo ldconfig /usr/local/lib
74+
75+
# Python build requirements. Ideally these would be in pyprojec.toml, but
76+
# first need to migrate from setup.py to pyproject.toml.
77+
pip install 'cython>=3' numpy wheel
78+
79+
# Install from checkout (or sdist).
80+
echo -----------------------------------------------------------
81+
echo
82+
echo Running:
83+
echo $ pip install --no-build-isolation $1
84+
echo
85+
echo -----------------------------------------------------------
86+
87+
pip install --no-build-isolation $1

setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@
3434
# For the MSVC toolchain link with mpir instead of gmp
3535
libraries = ["arb", "flint", "mpir", "mpfr", "pthreads"]
3636
else:
37-
libraries = ["arb", "flint"]
37+
# On Ubuntu libarb.so is called libflint-arb.so
38+
if os.getenv('PYTHON_FLINT_LIBFLINT_ARB'):
39+
arb = 'flint-arb'
40+
else:
41+
arb = 'arb'
42+
43+
libraries = [arb, "flint"]
3844
(opt,) = get_config_vars('OPT')
3945
os.environ['OPT'] = " ".join(flag for flag in opt.split() if flag != '-Wstrict-prototypes')
4046

0 commit comments

Comments
 (0)