Skip to content

Commit c12d627

Browse files
committed
python: Enable build testing, cover freethreaded builds
1 parent e3459d0 commit c12d627

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed
Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
project('python extension', 'c')
1+
project('python extension', 'c', meson_version : '>=1.3.0')
22

33
py = import('python').find_installation('')
44

@@ -7,9 +7,14 @@ py.extension_module(
77
install: true,
88
)
99

10-
py.extension_module(
11-
'foo_stable', 'foo.c',
12-
install: true,
13-
limited_api: '3.2',
14-
)
15-
10+
limited_api_supported = true
11+
if py.language_version().version_compare('>=3.13') and py.language_version().version_compare('<3.15')
12+
limited_api_supported = py.get_variable('Py_GIL_DISABLED') != 1
13+
endif
14+
if limited_api_supported
15+
py.extension_module(
16+
'foo_stable', 'foo.c',
17+
install: true,
18+
limited_api: '3.2',
19+
)
20+
endif

unittests/allplatformstests.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3087,7 +3087,7 @@ def test_python_build_config_extensions(self):
30873087
if not attr.startswith('__')
30883088
},
30893089
'abi': {
3090-
'flags': [],
3090+
'flags': list(sys.abiflags),
30913091
'extension_suffix': EXTENSION_SUFFIX,
30923092
'stable_abi_suffix': STABLE_ABI_SUFFIX,
30933093
},
@@ -3115,16 +3115,23 @@ def test_python_build_config_extensions(self):
31153115
if py3library is not None:
31163116
python_build_config['libpython']['dynamic_stableabi'] = os.path.join(LIBDIR, py3library)
31173117

3118+
build_stable_abi = sysconfig.get_config_var('Py_GIL_DISABLED') != 1 or sys.version_info >= (3, 15)
31183119
intro_installed_file = os.path.join(self.builddir, 'meson-info', 'intro-installed.json')
31193120
expected_files = [
31203121
os.path.join(self.builddir, 'foo' + EXTENSION_SUFFIX),
3121-
os.path.join(self.builddir, 'foo_stable' + STABLE_ABI_SUFFIX),
31223122
]
3123+
if build_stable_abi:
3124+
expected_files += [
3125+
os.path.join(self.builddir, 'foo_stable' + STABLE_ABI_SUFFIX),
3126+
]
31233127
if is_cygwin():
31243128
expected_files += [
31253129
os.path.join(self.builddir, 'foo' + EXTENSION_SUFFIX.replace('.so', '.dll.a')),
3126-
os.path.join(self.builddir, 'foo_stable' + STABLE_ABI_SUFFIX.replace('.so', '.dll.a')),
31273130
]
3131+
if build_stable_abi:
3132+
expected_files += [
3133+
os.path.join(self.builddir, 'foo_stable' + STABLE_ABI_SUFFIX.replace('.so', '.dll.a')),
3134+
]
31283135

31293136
for with_pkgconfig in (False, True):
31303137
with self.subTest(with_pkgconfig=with_pkgconfig):
@@ -3154,6 +3161,7 @@ def test_python_build_config_extensions(self):
31543161
):
31553162
with self.subTest(extra_args=extra_args):
31563163
self.init(testdir, extra_args=extra_args)
3164+
self.build()
31573165
with open(intro_installed_file) as f:
31583166
intro_installed = json.load(f)
31593167
self.assertEqual(expected_files, list(intro_installed))

0 commit comments

Comments
 (0)