Skip to content

Commit 0dd421f

Browse files
Merge pull request #326 from oscarbenjamin/pr_limited_api
build: enable building with the limited API
2 parents 0a59f53 + 3c13818 commit 0dd421f

17 files changed

+30
-14
lines changed

meson.build

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ project(
22
'python-flint',
33
'cython',
44
'c',
5-
meson_version : '>=1.1',
5+
meson_version : '>=1.3.0',
6+
default_options: ['python.allow_limited_api=false'],
67
)
78
#
89
# The minimum versions are because we know that it will not work with earlier
@@ -83,15 +84,20 @@ add_project_arguments(
8384
language : 'cython'
8485
)
8586

87+
# Only used if python.allow_limited_api is true (not the default)
88+
limited_api_version = get_option('limited_api_version')
89+
8690
# Enable free-threading if Cython is new enough. The check should be
8791
# >= 3.1.0a1 but meson gets confused by the a1 alpha release suffix.
8892
# so we go with >= 3.1 (which will be correct once 3.1 is released).
8993
cy = meson.get_compiler('cython')
90-
if cy.version().version_compare('>=3.1')
94+
if get_option('python.allow_limited_api')
95+
message('Using Python limited API version ' + limited_api_version)
96+
elif cy.version().version_compare('>=3.1')
9197
message('Enabling freethreading')
9298
add_project_arguments('-Xfreethreading_compatible=true', language : 'cython')
9399
else
94-
message('Disabling freethreading')
100+
message('Normal build (no freethreading and no limited API)')
95101
endif
96102

97103
if get_option('coverage')

meson.options

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

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ content-type = "text/markdown"
4444
requires = ["meson-python >= 0.18", "cython >=3.1,<3.2"]
4545
build-backend = "mesonpy"
4646

47+
[tool.meson-python]
48+
49+
limited-api = true
50+
4751
[tool.cython-lint]
4852
# E129 visually indented line with same indent as next logical line
4953
# Reasoning: this rule is a little controversial

src/flint/flint_base/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ foreach ext : exts
2323
dependencies: pyflint_deps,
2424
install: true,
2525
subdir: pkgdir,
26+
limited_api: limited_api_version,
2627
)
2728
endforeach

src/flint/functions/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ foreach ext : exts
1919
dependencies: pyflint_deps,
2020
install: true,
2121
subdir: 'flint/functions',
22+
limited_api: limited_api_version,
2223
)
2324
endforeach

src/flint/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ foreach ext : exts
3131
dependencies: pyflint_deps,
3232
install: true,
3333
subdir: thisdir,
34+
limited_api: limited_api_version,
3435
)
3536
endforeach
3637

src/flint/types/acb_poly.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from cpython.list cimport PyList_GET_SIZE
1+
from cpython.list cimport PyList_Size as PyList_GET_SIZE
22
from flint.utils.typecheck cimport typecheck
33
from flint.flint_base.flint_context cimport getprec
44
from flint.flint_base.flint_base cimport flint_poly

src/flint/types/arb.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from cpython.float cimport PyFloat_AS_DOUBLE
1+
from cpython.float cimport PyFloat_AsDouble
22
from cpython.long cimport PyLong_Check
33

44
from flint.flint_base.flint_context cimport getprec
@@ -101,7 +101,7 @@ cdef int arb_set_python(arb_t x, obj, bint allow_conversion) except -1:
101101
return 1
102102

103103
if typecheck(obj, float):
104-
arf_set_d(arb_midref(x), PyFloat_AS_DOUBLE(obj))
104+
arf_set_d(arb_midref(x), PyFloat_AsDouble(obj))
105105
mag_zero(arb_radref(x))
106106
return 1
107107

src/flint/types/arb_poly.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from cpython.list cimport PyList_GET_SIZE
1+
from cpython.list cimport PyList_Size as PyList_GET_SIZE
22
from flint.utils.typecheck cimport typecheck
33
from flint.flint_base.flint_context cimport getprec
44
from flint.flint_base.flint_base cimport flint_poly

src/flint/types/arf.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from cpython.float cimport PyFloat_AS_DOUBLE
1+
from cpython.float cimport PyFloat_AsDouble
22
from flint.flint_base.flint_context cimport getprec
33
from flint.flint_base.flint_context cimport thectx
44
from flint.utils.typecheck cimport typecheck
@@ -44,7 +44,7 @@ cdef class arf:
4444
elif typecheck(val, arf):
4545
arf_set(self.val, (<arf>val).val)
4646
elif typecheck(val, float):
47-
arf_set_d(self.val, PyFloat_AS_DOUBLE(val))
47+
arf_set_d(self.val, PyFloat_AsDouble(val))
4848
elif typecheck(val, tuple):
4949
man = any_as_fmpz(val[0])
5050
exp = any_as_fmpz(val[1])

0 commit comments

Comments
 (0)