Skip to content

Commit 804ca08

Browse files
committed
build: Check Cython version in meson build
1 parent 0fa5e3a commit 804ca08

File tree

1 file changed

+48
-39
lines changed

1 file changed

+48
-39
lines changed

meson.build

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,77 @@
11
project('python-flint', 'cython', 'c')
2+
#
3+
# The minimum versions are because we know that it will not work with earlier
4+
# versions. The maximum versions are because python-flint was not tested
5+
# against future versions that didn't exist at the time of release. In future
6+
# if it seems like new releases do not always break the build of python-flint
7+
# then we can consider not using a speculative upper version cap here.
8+
#
9+
flint_lower = '>=3.0'
10+
flint_upper = '<3.2'
11+
cython_lower = '>=3.0'
12+
cython_upper = '<3.2'
213

314
py = import('python').find_installation(pure: false)
415
dep_py = py.dependency()
516

617
cc = meson.get_compiler('c')
7-
8-
flint_ver_lower = '3.0' # >=3.0
9-
flint_ver_upper = '3.2' # <3.2
18+
cy = meson.get_compiler('cython')
1019

1120
gmp_dep = dependency('gmp')
1221
mpfr_dep = dependency('mpfr')
13-
flint_dep = dependency('flint', version: ['>=' + flint_ver_lower])
22+
flint_dep = dependency('flint')
1423

1524
#
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+
# For the source release, we should by default fail for new untested versions
26+
# with a clear error message about the version mismatch.
2527
#
2628
# We need an option to disable this though so that we can test newer versions
2729
# of Flint. Also good to have an escape hatch for users since we don't know
2830
# that future versions of Flint will not work.
2931
#
30-
if get_option('flint_version_check')
31-
if flint_dep.version().version_compare('>=' + flint_ver_upper)
32-
error('''
32+
ver_message = '''
33+
34+
Invalid @0@ version:
35+
Version needed is: @0@ @2@, @3@
36+
Version found is: @0@ == @1@
3337
34-
Invalid Flint version:
35-
Version needed is: @0@ <= flint < @1@
36-
Version found is: flint == @2@
38+
By default, python-flint will only build against @0@ versions that have
39+
been tested. If you are sure you want to use this version of @0@, you can
40+
disable this check with -Dflint_version_check=false.
3741
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.
42+
If building from the source directory using meson directly, you can do this
43+
with:
4144
42-
If building from the source directory using meson directly, you can do this
43-
with:
45+
meson setup build -Dflint_version_check=false
4446
45-
meson setup build -Dflint_version_check=false
47+
If you are installing with pip, you can do this with:
4648
47-
If you are installing with pip, you can do this with:
49+
pip install --config-settings=setup-args="-Dflint_version_check=false" python-flint
4850
49-
pip install --config-settings=setup-args="-Dflint_version_check=false" python-flint
51+
Other build frontends have similar options for passing this to meson.
5052
51-
Other build frontends have similar options for passing this to meson.
52-
'''.format(flint_ver_lower, flint_ver_upper, flint_dep.version()))
53+
'''
54+
if get_option('flint_version_check')
55+
if not (flint_dep.version().version_compare(flint_lower) and
56+
flint_dep.version().version_compare(flint_upper))
57+
error(ver_message.format('FLINT', flint_dep.version(), flint_lower, flint_upper))
5358
endif
59+
if not (cy.version().version_compare(cython_lower) and
60+
cy.version().version_compare(cython_upper))
61+
error(ver_message.format('Cython', cy.version(), cython_lower, cython_upper))
62+
endif
63+
endif
64+
65+
# flint.pc was missing -lflint until Flint 3.1.0
66+
if flint_dep.version().version_compare('<3.1')
67+
flint_dep = cc.find_library('flint')
68+
have_acb_theta = false
69+
else
70+
have_acb_theta = true
5471
endif
5572

73+
pyflint_deps = [dep_py, gmp_dep, mpfr_dep, flint_dep]
74+
5675
add_project_arguments(
5776
'-X', 'embedsignature=True',
5877
'-X', 'emit_code_comments=True',
@@ -74,14 +93,4 @@ if get_option('add_flint_rpath')
7493
)
7594
endif
7695

77-
# flint.pc was missing -lflint until Flint 3.1.0
78-
if flint_dep.version().version_compare('<3.1')
79-
flint_dep = cc.find_library('flint')
80-
have_acb_theta = false
81-
else
82-
have_acb_theta = true
83-
endif
84-
85-
pyflint_deps = [dep_py, gmp_dep, mpfr_dep, flint_dep]
86-
8796
subdir('src/flint')

0 commit comments

Comments
 (0)