Skip to content

Commit 920a3a2

Browse files
Merge pull request #194 from oscarbenjamin/pr_flint_version_cap
Add CPython 3.13 and set dependency version constraints
2 parents 162ded1 + 8898d6f commit 920a3a2

File tree

4 files changed

+128
-29
lines changed

4 files changed

+128
-29
lines changed

.github/workflows/buildwheel.yml

Lines changed: 60 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
if: ${{ matrix.os == 'windows-2019' }}
4343

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

112112
steps:
113113
- uses: actions/setup-python@v5
@@ -138,8 +138,62 @@ jobs:
138138
- run: pip install .
139139
- run: python -m flint.test --verbose
140140

141-
# Test that we can still make a coverage build with setuptools.
142-
test_coverage_setuptools:
141+
# Test build with minimum Cython and meson-python versions.
142+
test_old_build_requires:
143+
name: 'Test old Cython/meson-python'
144+
runs-on: ubuntu-24.04
145+
steps:
146+
- uses: actions/checkout@v4
147+
- uses: actions/setup-python@v5
148+
with:
149+
python-version: '3.12'
150+
- run: sudo apt-get update
151+
- run: sudo apt-get install libflint-dev
152+
# The versions of cython and meson-python here should be kept in sync
153+
# with those in pyproject.toml so that we test the stated minimum
154+
# versions.
155+
#
156+
# We don't need to specify ninja as a requirement in pyproject.toml
157+
# because without --no-build-isolation meson-python handles it
158+
# automatically in get_requirements_for_build_wheel().
159+
- run: 'pip install "cython==3.0" "meson-python==0.13" "ninja<1.11"'
160+
- run: pip install --no-build-isolation .
161+
- run: python -m flint.test --verbose
162+
163+
# For older Ubuntu we have to build Flint >= 3.0.0
164+
test_flint_releases:
165+
name: Test flint ${{ matrix.flint-tag }}
166+
runs-on: ubuntu-22.04
167+
strategy:
168+
fail-fast: false
169+
matrix:
170+
# Supported Flint versions:
171+
flint-tag: ['v3.0.0', 'v3.0.1', 'v3.1.0', 'v3.1.1', 'v3.1.2']
172+
steps:
173+
- uses: actions/checkout@v4
174+
- uses: actions/setup-python@v5
175+
with:
176+
python-version: '3.12'
177+
- run: bin/install_flint_ubuntu.sh ${{ matrix.flint-tag }}
178+
- run: pip install .
179+
- run: python -m flint.test --verbose
180+
181+
# Test against flint main
182+
test_flint_main:
183+
name: Test flint main
184+
runs-on: ubuntu-22.04
185+
steps:
186+
- uses: actions/checkout@v4
187+
- uses: actions/setup-python@v5
188+
with:
189+
python-version: '3.12'
190+
- run: bin/install_flint_ubuntu.sh main
191+
# Need to disable flint version check to build against main
192+
- run: pip install --config-settings=setup-args="-Dflint_version_check=false" .
193+
- run: python -m flint.test --verbose
194+
195+
# Test that we can make a coverage build and report coverage
196+
test_coverage_build:
143197
name: Test coverage setuptools build
144198
runs-on: ubuntu-24.04
145199
steps:
@@ -149,6 +203,8 @@ jobs:
149203
python-version: '3.12'
150204
- run: sudo apt-get update
151205
- run: sudo apt-get install libflint-dev
206+
# This is branch is for a Cython PR:
207+
# https://github.com/cython/cython/pull/6341
152208
- run: pip install git+https://github.com/oscarbenjamin/cython.git@pr_relative_paths
153209
- run: pip install -r requirements-dev.txt
154210
- run: bin/coverage.sh
@@ -173,24 +229,6 @@ jobs:
173229
- run: pip install sympy==${{ matrix.sympy-version }}
174230
- run: python -c 'import sympy; sympy.test(parallel=True)'
175231

176-
# For older Ubuntu we have to build Flint >= 3.0.0
177-
test_flint_versions:
178-
name: Test flint ${{ matrix.flint-tag }}
179-
runs-on: ubuntu-22.04
180-
strategy:
181-
fail-fast: false
182-
matrix:
183-
# Supported versions and latest git
184-
flint-tag: ['v3.0.0', 'v3.0.1', 'v3.1.0', 'v3.1.1', 'v3.1.2', 'main']
185-
steps:
186-
- uses: actions/checkout@v4
187-
- uses: actions/setup-python@v5
188-
with:
189-
python-version: '3.12'
190-
- run: bin/install_flint_ubuntu.sh ${{ matrix.flint-tag }}
191-
- run: pip install .
192-
- run: python -m flint.test --verbose
193-
194232
# Deploy wheels and sdist to PyPI
195233

196234
pypi_release:

meson.build

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,53 @@ dep_py = py.dependency()
55

66
cc = meson.get_compiler('c')
77

8+
flint_ver_lower = '3.0' # >=3.0
9+
flint_ver_upper = '3.2' # <3.2
10+
811
gmp_dep = dependency('gmp')
912
mpfr_dep = dependency('mpfr')
10-
flint_dep = dependency('flint')
13+
flint_dep = dependency('flint', version: ['>=' + flint_ver_lower])
14+
15+
#
16+
# The minimum Flint version is because we know that it will not work with
17+
# earlier versions. The maximum version is because python-flint has not been
18+
# tested against versions that didn't exist at the time of release. In future
19+
# if it seems like new Flint releases do not break the build of python-flint
20+
# every time, then we can consider not using a speculative upper version cap
21+
# here.
22+
#
23+
# For the source release, we should by default fail for newer versions of Flint
24+
# that are untested with a nice error message.
25+
#
26+
# We need an option to disable this though so that we can test newer versions
27+
# of Flint. Also good to have an escape hatch for users since we don't know
28+
# that future versions of Flint will not work.
29+
#
30+
if get_option('flint_version_check')
31+
if flint_dep.version().version_compare('>=' + flint_ver_upper)
32+
error('''
33+
34+
Invalid Flint version:
35+
Version needed is: @0@ <= flint < @1@
36+
Version found is: flint == @2@
37+
38+
By default, python-flint will only build against Flint versions that have
39+
been tested. If you are sure you want to use this version of Flint, you can
40+
disable this check with -Dflint_version_check=false.
41+
42+
If building from the source directory using meson directly, you can do this
43+
with:
44+
45+
meson setup build -Dflint_version_check=false
46+
47+
If you are installing with pip, you can do this with:
48+
49+
pip install --config-settings=setup-args="-Dflint_version_check=false" python-flint
50+
51+
Other build frontends have similar options for passing this to meson.
52+
'''.format(flint_ver_lower, flint_ver_upper, flint_dep.version()))
53+
endif
54+
endif
1155

1256
add_project_arguments(
1357
'-X', 'embedsignature=True',

meson.options

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
option('coverage', type : 'boolean', value : false, description : 'enable coverage build')
22
option('add_flint_rpath', type : 'boolean', value : false)
3+
option('flint_version_check', type: 'boolean', value : true)

pyproject.toml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
[build-system]
2-
requires = ["meson-python", "cython"]
3-
build-backend = "mesonpy"
4-
51
[project]
62
name = "python-flint"
7-
description = "Bindings for FLINT and Arb"
3+
description = "Bindings for FLINT"
84
version = "0.7.0a4"
5+
requires-python = ">= 3.9"
96
urls = {Homepage = "https://github.com/flintlib/python-flint"}
107
authors = [
118
{name = "Fredrik Johansson", email = "[email protected]"},
@@ -19,6 +16,23 @@ classifiers = [
1916
file = "README.md"
2017
content-type = "text/markdown"
2118

19+
[build-system]
20+
#
21+
# Minimum build requirements tested in CI need to be kept in sync with the
22+
# versions in requires below so that they are tested.
23+
#
24+
# The upper cap on Cython is speculative but we may as well cap it given that
25+
# it is only a build requirement and that it is not uncommon for newer Cython
26+
# versions to break the build. For example Cython 3.0 broke the build and then
27+
# Cython 3.1 broke the build again so python-flint 0.6.0 did not have any upper
28+
# cap but it should have had cython>=3.0,<3.1 i.e. precisely one minor release
29+
# of Cython works. In future we could contemplate not having an upper cap but
30+
# until we have actually witnessed a Cython 3.x release that does not break the
31+
# build we should keep the upper cap.
32+
#
33+
requires = ["meson-python>=0.13", "cython>=3.0,<3.1"]
34+
build-backend = "mesonpy"
35+
2236
[tool.spin]
2337
package = "flint"
2438

@@ -41,7 +55,9 @@ package = "flint"
4155
]
4256

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

0 commit comments

Comments
 (0)