Skip to content

Commit

Permalink
Merge pull request #194 from oscarbenjamin/pr_flint_version_cap
Browse files Browse the repository at this point in the history
Add CPython 3.13 and set dependency version constraints
  • Loading branch information
oscarbenjamin authored Aug 21, 2024
2 parents 162ded1 + 8898d6f commit 920a3a2
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 29 deletions.
82 changes: 60 additions & 22 deletions .github/workflows/buildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
if: ${{ matrix.os == 'windows-2019' }}

- name: Build wheels
uses: pypa/cibuildwheel@v2.19.2
uses: pypa/cibuildwheel@v2.20.0
env:
# override setting in pyproject.toml to use msys2 instead of msys64 bash
CIBW_BEFORE_ALL_WINDOWS: msys2 -c bin/cibw_before_all_windows.sh
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-13, macos-14]
python-version: ['3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13-dev']

steps:
- uses: actions/setup-python@v5
Expand Down Expand Up @@ -138,8 +138,62 @@ jobs:
- run: pip install .
- run: python -m flint.test --verbose

# Test that we can still make a coverage build with setuptools.
test_coverage_setuptools:
# Test build with minimum Cython and meson-python versions.
test_old_build_requires:
name: 'Test old Cython/meson-python'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: sudo apt-get update
- run: sudo apt-get install libflint-dev
# The versions of cython and meson-python here should be kept in sync
# with those in pyproject.toml so that we test the stated minimum
# versions.
#
# We don't need to specify ninja as a requirement in pyproject.toml
# because without --no-build-isolation meson-python handles it
# automatically in get_requirements_for_build_wheel().
- run: 'pip install "cython==3.0" "meson-python==0.13" "ninja<1.11"'
- run: pip install --no-build-isolation .
- run: python -m flint.test --verbose

# For older Ubuntu we have to build Flint >= 3.0.0
test_flint_releases:
name: Test flint ${{ matrix.flint-tag }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
# Supported Flint versions:
flint-tag: ['v3.0.0', 'v3.0.1', 'v3.1.0', 'v3.1.1', 'v3.1.2']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: bin/install_flint_ubuntu.sh ${{ matrix.flint-tag }}
- run: pip install .
- run: python -m flint.test --verbose

# Test against flint main
test_flint_main:
name: Test flint main
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: bin/install_flint_ubuntu.sh main
# Need to disable flint version check to build against main
- run: pip install --config-settings=setup-args="-Dflint_version_check=false" .
- run: python -m flint.test --verbose

# Test that we can make a coverage build and report coverage
test_coverage_build:
name: Test coverage setuptools build
runs-on: ubuntu-24.04
steps:
Expand All @@ -149,6 +203,8 @@ jobs:
python-version: '3.12'
- run: sudo apt-get update
- run: sudo apt-get install libflint-dev
# This is branch is for a Cython PR:
# https://github.com/cython/cython/pull/6341
- run: pip install git+https://github.com/oscarbenjamin/cython.git@pr_relative_paths
- run: pip install -r requirements-dev.txt
- run: bin/coverage.sh
Expand All @@ -173,24 +229,6 @@ jobs:
- run: pip install sympy==${{ matrix.sympy-version }}
- run: python -c 'import sympy; sympy.test(parallel=True)'

# For older Ubuntu we have to build Flint >= 3.0.0
test_flint_versions:
name: Test flint ${{ matrix.flint-tag }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
# Supported versions and latest git
flint-tag: ['v3.0.0', 'v3.0.1', 'v3.1.0', 'v3.1.1', 'v3.1.2', 'main']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: bin/install_flint_ubuntu.sh ${{ matrix.flint-tag }}
- run: pip install .
- run: python -m flint.test --verbose

# Deploy wheels and sdist to PyPI

pypi_release:
Expand Down
46 changes: 45 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,53 @@ dep_py = py.dependency()

cc = meson.get_compiler('c')

flint_ver_lower = '3.0' # >=3.0
flint_ver_upper = '3.2' # <3.2

gmp_dep = dependency('gmp')
mpfr_dep = dependency('mpfr')
flint_dep = dependency('flint')
flint_dep = dependency('flint', version: ['>=' + flint_ver_lower])

#
# The minimum Flint version is because we know that it will not work with
# earlier versions. The maximum version is because python-flint has not been
# tested against versions that didn't exist at the time of release. In future
# if it seems like new Flint releases do not break the build of python-flint
# every time, then we can consider not using a speculative upper version cap
# here.
#
# For the source release, we should by default fail for newer versions of Flint
# that are untested with a nice error message.
#
# We need an option to disable this though so that we can test newer versions
# of Flint. Also good to have an escape hatch for users since we don't know
# that future versions of Flint will not work.
#
if get_option('flint_version_check')
if flint_dep.version().version_compare('>=' + flint_ver_upper)
error('''
Invalid Flint version:
Version needed is: @0@ <= flint < @1@
Version found is: flint == @2@
By default, python-flint will only build against Flint versions that have
been tested. If you are sure you want to use this version of Flint, you can
disable this check with -Dflint_version_check=false.
If building from the source directory using meson directly, you can do this
with:
meson setup build -Dflint_version_check=false
If you are installing with pip, you can do this with:
pip install --config-settings=setup-args="-Dflint_version_check=false" python-flint
Other build frontends have similar options for passing this to meson.
'''.format(flint_ver_lower, flint_ver_upper, flint_dep.version()))
endif
endif

add_project_arguments(
'-X', 'embedsignature=True',
Expand Down
1 change: 1 addition & 0 deletions meson.options
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
option('coverage', type : 'boolean', value : false, description : 'enable coverage build')
option('add_flint_rpath', type : 'boolean', value : false)
option('flint_version_check', type: 'boolean', value : true)
28 changes: 22 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
[build-system]
requires = ["meson-python", "cython"]
build-backend = "mesonpy"

[project]
name = "python-flint"
description = "Bindings for FLINT and Arb"
description = "Bindings for FLINT"
version = "0.7.0a4"
requires-python = ">= 3.9"
urls = {Homepage = "https://github.com/flintlib/python-flint"}
authors = [
{name = "Fredrik Johansson", email = "[email protected]"},
Expand All @@ -19,6 +16,23 @@ classifiers = [
file = "README.md"
content-type = "text/markdown"

[build-system]
#
# Minimum build requirements tested in CI need to be kept in sync with the
# versions in requires below so that they are tested.
#
# The upper cap on Cython is speculative but we may as well cap it given that
# it is only a build requirement and that it is not uncommon for newer Cython
# versions to break the build. For example Cython 3.0 broke the build and then
# Cython 3.1 broke the build again so python-flint 0.6.0 did not have any upper
# cap but it should have had cython>=3.0,<3.1 i.e. precisely one minor release
# of Cython works. In future we could contemplate not having an upper cap but
# until we have actually witnessed a Cython 3.x release that does not break the
# build we should keep the upper cap.
#
requires = ["meson-python>=0.13", "cython>=3.0,<3.1"]
build-backend = "mesonpy"

[tool.spin]
package = "flint"

Expand All @@ -41,7 +55,9 @@ package = "flint"
]

[tool.cibuildwheel]
build = "cp39-* cp310-* cp311-* cp312-*"
# requires-python needs to keep in sync with this and also the list of Python
# versions the wheels are tested against in CI.
build = "cp39-* cp310-* cp311-* cp312-* cp313-*"
skip = "*-win32 *-manylinux_i686 *-musllinux_*"
manylinux-x86_64-image = "manylinux2014"
manylinux-i686-image = "manylinux2014"
Expand Down

0 comments on commit 920a3a2

Please sign in to comment.