Skip to content

Commit

Permalink
Merge pull request #48 from oscarbenjamin/pr_pip_linux
Browse files Browse the repository at this point in the history
Add tests for installing on Linux
  • Loading branch information
oscarbenjamin authored Aug 9, 2023
2 parents bde3dbd + 15addd2 commit 99fa557
Show file tree
Hide file tree
Showing 15 changed files with 300 additions and 72 deletions.
35 changes: 17 additions & 18 deletions .github/workflows/buildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ jobs:
python-version: ['3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
Expand All @@ -77,26 +76,26 @@ jobs:
name: artifact
path: wheelhouse
- run: pip install --find-links wheelhouse python_flint
- run: python test/test.py

doctest_wheels:
needs: build_wheels
name: Doctests for ${{ matrix.python-version }} wheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-12]
python-version: ['3.9', '3.10', '3.11']
- run: python -m flint.test --verbose

test_pip_linux_vcs:
name: Install from git checkout on Ubuntu
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v3
python-version: 3.11
- run: bin/pip_install_ubuntu.sh . # Install from checkout
- run: python -m flint.test --verbose

test_pip_linux_pypi:
name: Install from PyPI sdist on Ubuntu
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
name: artifact
path: wheelhouse
- run: pip install --find-links wheelhouse python_flint
- run: python test/dtest.py
python-version: 3.11
- run: bin/pip_install_ubuntu.sh python-flint # Install from PyPI sdist
- run: python -m flint.test --verbose
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ install:
- pip install .

script:
- python test/test.py
- python -m flint.test
33 changes: 25 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,43 @@ Author: Fredrik Johansson <[email protected]>
Installation
------------

First install both FLINT (version 2.5 or later) and Arb (version 2.15 or later).
See:
On Windows (x86-64) or OSX (x86-64 or arm64) there are prebuilt wheels for
python-flint 0.4.1 that can be installed from PyPI using pip

pip install python-flint

There is currently a problem with the Linux wheels and so for now Linux wheels
are not available on PyPI. Instead for Linux first install both FLINT 2.9.0 and
Arb 2.23. Note that as of python-flint 0.4.1 only these *exact* versions of
FLINT and Arb will work. While some Linux distributions may provide FLINT and
Arb it is unlikely that they will provide the exact versions required (e.g.
for Ubuntu only Ubuntu 23.04 provides these versions at the time of writing).

See here for instructions on building FLINT and Arb:

* http://flintlib.org/
* http://arblib.org/

The latest release of Python-FLINT can then be installed using:
The latest release of Python-FLINT can then be built and installed using:

pip install python-flint
pip install 'cython>=3' numpy wheel
pip install --no-build-isolation python-flint

Python-FLINT can also be installed git checkout or a source archive
Python-FLINT can also be installed from a git checkout or a source archive
as follows:

pip install .
pip install 'cython>=3' numpy wheel
pip install --no-build-isolation .

A script that builds and installs FLINT, Arb and Python-FLINT that is tested on
Ubuntu can be found in the git repo here:

* https://github.com/fredrik-johansson/python-flint/blob/master/bin/pip_install_ubuntu.sh

See the documentation for further notes on building and installing
Python-FLINT:

https://fredrikj.net/python-flint/setup.html
* https://fredrikj.net/python-flint/setup.html

Examples
-------------------------------------
Expand Down Expand Up @@ -95,7 +113,6 @@ To do
* Conversions to and from external types (numpy, sage, sympy, mpmath, gmpy)
* Improved printing and string input/output
* IPython hooks (TeX pretty-printing etc.)
* Windows support

License
------------
Expand Down
4 changes: 2 additions & 2 deletions bin/build_mingw64_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fi
PYTHON=$PYTHONDIR/python
VER="${PYTHONVER//./}"

WHEELNAME=python_flint-0.4.0-cp$VER-cp$VER-win_amd64.whl
WHEELNAME=python_flint-0.4.1-cp$VER-cp$VER-win_amd64.whl

$PYTHON -c 'print("hello world")'

Expand Down Expand Up @@ -90,7 +90,7 @@ wheel pack python_flint-*
cd ..

# Make the wheel relocatable
delvewheel repair dist/python_flint-0.4.0-cp$VER-cp$VER-win_amd64.whl \
delvewheel repair dist/python_flint-0.4.1-cp$VER-cp$VER-win_amd64.whl \
--add-path .local/bin:.local/lib/

# Make a virtual enironment to test the wheel
Expand Down
2 changes: 1 addition & 1 deletion bin/cibw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export CIBW_BEFORE_BUILD_WINDOWS='C:\\msys64\\usr\\bin\\bash bin/cibw_before_bui
export CIBW_REPAIR_WHEEL_COMMAND_WINDOWS='bin\cibw_repair_wheel_command_windows.bat {dest_dir} {wheel}'

# export CIBW_TEST_COMMAND="python -c 'import flint; print(str(flint.fmpz(2)))'"
export CIBW_TEST_COMMAND="python {project}/test/test.py && python {project}/test/dtest.py"
export CIBW_TEST_COMMAND="python -m flint.test"

# cibuildwheel --platform linux
# cibuildwheel --platform windows
Expand Down
3 changes: 1 addition & 2 deletions bin/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export PYTHON_FLINT_COVERAGE=true

python setup.py build_ext --inplace

pytest --cov flint test/test.py
coverage run --append test/dtest.py
coverage run -m flint.test $@

#coverage report -m
coverage html
87 changes: 87 additions & 0 deletions bin/pip_install_ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash

set -o errexit

# This script should work to install python-flint on Ubuntu from a VCS checkout
#
# $ git checkout https://github.com/fredrik-johansson/python-flint.git
# $ bin/pip_install_ubuntu.sh .
#
# To install an sdist from PyPI, use
#
# $ bin/pip_install_ubuntu.sh python-flint
#

# Install runtime and build dependencies

# The commented commands below would attempt to build python-flint against a
# system installation of Flint and Arb in Ubuntu.
#
# Ubuntu 23.04 has Flint 2.9.0 and Arb 2.23.0, so this script might work there
# (for python-flint 0.4.1). That is untested though (23.04 not available in CI).
#
# With Ubuntu 22.04, this will build but then crashes when running the tests.
# most likely this is because the versions of flint and flint-arb are too old.
# At the time of writing in Ubuntu 22.04 there is Flint 2.8.4 and Arb 2.22. The
# main CI tests and wheels for python-flint 0.4.1 are built with Flint 2.9.0
# and Arb 2.23.0.
#
# Link against libflint-arb instead of libarb on Ubuntu
# export PYTHON_FLINT_LIBFLINT_ARB=1
# sudo apt-get update
# sudo apt-get install libflint-dev libflint-arb-dev


# Build Flint and Arb manually
#
# First install their dependencies and build dependencies
sudo apt-get update
sudo apt-get install libgmp-dev libmpfr-dev xz-utils

# Only these *EXACT* versions will work.
FLINTVER=2.9.0
ARBVER=2.23.0

# This will default to installing in /usr/local. If you want to install in a
# non-standard location then configure flint with
# ./configure --disable-static --prefix=$PREFIX
# and arb with
# ./configure --disable-static --prefix=$PREFIX --with-flint=$PREFIX
# If $PREFIX is no in default search paths, then at build time set
# export C_INCLUDE_PATH=$PREFIX/include
# and at runtime set
# export LD_LIBRARY_PATH=$PREFIX/lib

curl -O -L https://www.flintlib.org/flint-$FLINTVER.tar.gz
tar xf flint-$FLINTVER.tar.gz
cd flint-$FLINTVER
./configure --disable-static
make -j
sudo make install
cd ..

curl -O -L https://github.com/fredrik-johansson/arb/archive/refs/tags/$ARBVER.tar.gz
mv $ARBVER.tar.gz arb-$ARBVER.tar.gz
tar xf arb-$ARBVER.tar.gz
cd arb-$ARBVER
./configure --disable-static
make -j
sudo make install
cd ..

ls -l /usr/local/lib
sudo ldconfig /usr/local/lib

# Python build requirements. Ideally these would be in pyprojec.toml, but
# first need to migrate from setup.py to pyproject.toml.
pip install 'cython>=3' numpy wheel

# Install from checkout (or sdist).
echo -----------------------------------------------------------
echo
echo Running:
echo $ pip install --no-build-isolation $1
echo
echo -----------------------------------------------------------

pip install --no-build-isolation $1
4 changes: 2 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
# built documents.
#
# The short X.Y version.
version = '0.4.0'
version = '0.4.1'
# The full version, including alpha/beta/rc tags.
release = '0.4.0'
release = '0.4.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
6 changes: 2 additions & 4 deletions doc/source/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ Then run::

Run the test suite::

python test/test.py
python test/dtest.py
python -m flint.test

Build the documentation::

Expand Down Expand Up @@ -86,8 +85,7 @@ you can then build Python-FLINT in place with::

and run the test suite with::

python test/test.py
python test/dtest.py
python -m flint.test

This way of building Python-FLINT depends on the ``bin/activate`` script to
locate the shared libraries at runtime. The script will also set ``PYTHONPATH``
Expand Down
14 changes: 11 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@
# For the MSVC toolchain link with mpir instead of gmp
libraries = ["arb", "flint", "mpir", "mpfr", "pthreads"]
else:
libraries = ["arb", "flint"]
# On Ubuntu libarb.so is called libflint-arb.so
if os.getenv('PYTHON_FLINT_LIBFLINT_ARB'):
arb = 'flint-arb'
else:
arb = 'arb'

libraries = [arb, "flint"]
(opt,) = get_config_vars('OPT')
os.environ['OPT'] = " ".join(flag for flag in opt.split() if flag != '-Wstrict-prototypes')

Expand Down Expand Up @@ -75,10 +81,12 @@
cmdclass={'build_ext': build_ext},
ext_modules=cythonize(ext_modules, compiler_directives=compiler_directives),
#ext_modules=cythonize(ext_modules, compiler_directives=compiler_directives, annotate=True),
packages=['flint'],
packages=['flint', 'flint.test'],
package_dir={'': 'src'},
description='Bindings for FLINT and Arb',
version='0.4.0',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
version='0.4.1',
url='https://github.com/python-flint/python-flint',
author='Fredrik Johansson',
author_email='[email protected]',
Expand Down
2 changes: 1 addition & 1 deletion src/flint/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from ._flint import *

__version__ = '0.4.0'
__version__ = '0.4.1'
Empty file added src/flint/test/__init__.py
Empty file.
Loading

0 comments on commit 99fa557

Please sign in to comment.