Skip to content

Commit f489fa3

Browse files
dnicolodirgommers
authored andcommitted
TST: rename NOGIL_BUILD to FREE_THREADED_BUILD
For consistency with official nomenclature. Move common constants definitions into `conftest` instead than importing them from other test modules. Fixes #857.
1 parent 070c597 commit f489fa3

4 files changed

Lines changed: 19 additions & 21 deletions

File tree

tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@
2929
_meson_ver_str = subprocess.run(['meson', '--version'], check=True, stdout=subprocess.PIPE, text=True).stdout
3030
MESON_VERSION = tuple(map(int, _meson_ver_str.split('.')[:3]))
3131

32+
EXT_SUFFIX = sysconfig.get_config_var('EXT_SUFFIX')
33+
if sys.version_info <= (3, 8, 7):
34+
if MESON_VERSION >= (0, 99):
35+
# Fixed in Meson 1.0, see https://github.com/mesonbuild/meson/pull/10961.
36+
from distutils.sysconfig import get_config_var
37+
EXT_SUFFIX = get_config_var('EXT_SUFFIX')
38+
39+
FREE_THREADED_BUILD = bool(sysconfig.get_config_var('Py_GIL_DISABLED'))
40+
3241

3342
def metadata(data):
3443
meta, other = packaging.metadata.parse_email(data)

tests/test_editable.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from mesonpy import _editable
2020

21-
from .test_wheel import EXT_SUFFIX, NOGIL_BUILD
21+
from .conftest import EXT_SUFFIX, FREE_THREADED_BUILD
2222

2323

2424
def find_cython_version():
@@ -75,7 +75,7 @@ def test_collect(package_complex):
7575
assert tree['complex']['more']['__init__.py'] == os.path.join(root, 'complex', 'more', '__init__.py')
7676

7777

78-
@pytest.mark.skipif(NOGIL_BUILD and CYTHON_VERSION < (3, 1, 0),
78+
@pytest.mark.skipif(FREE_THREADED_BUILD and CYTHON_VERSION < (3, 1, 0),
7979
reason='Cython version too old, no free-threaded CPython support')
8080
def test_mesonpy_meta_finder(package_complex, tmp_path):
8181
# build a package in a temporary directory
@@ -209,7 +209,7 @@ def test_editble_reentrant(venv, editable_imports_itself_during_build):
209209
path.write_text(code)
210210

211211

212-
@pytest.mark.skipif(NOGIL_BUILD and CYTHON_VERSION < (3, 1, 0),
212+
@pytest.mark.skipif(FREE_THREADED_BUILD and CYTHON_VERSION < (3, 1, 0),
213213
reason='Cython version too old, no free-threaded CPython support')
214214
def test_editable_pkgutils_walk_packages(package_complex, tmp_path):
215215
# build a package in a temporary directory
@@ -295,7 +295,7 @@ def test_editable_rebuild(package_purelib_and_platlib, tmp_path, verbose, args):
295295
sys.modules.pop('pure', None)
296296

297297

298-
@pytest.mark.skipif(NOGIL_BUILD and CYTHON_VERSION < (3, 1, 0),
298+
@pytest.mark.skipif(FREE_THREADED_BUILD and CYTHON_VERSION < (3, 1, 0),
299299
reason='Cython version too old, no free-threaded CPython support')
300300
def test_editable_verbose(venv, package_complex, editable_complex, monkeypatch):
301301
monkeypatch.setenv('MESONPY_EDITABLE_VERBOSE', '1')

tests/test_tags.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
import mesonpy
1919
import mesonpy._tags
2020

21-
from .conftest import adjust_packaging_platform_tag
22-
from .test_wheel import NOGIL_BUILD
21+
from .conftest import FREE_THREADED_BUILD, adjust_packaging_platform_tag
2322

2423

2524
# Test against the wheel tag generated by packaging module.
@@ -136,7 +135,7 @@ def test_tag_stable_abi():
136135
# PyPy does not support the stable ABI.
137136
if '__pypy__' in sys.builtin_module_names:
138137
abi = ABI
139-
elif NOGIL_BUILD and sys.version_info >= (3, 15):
138+
elif FREE_THREADED_BUILD and sys.version_info >= (3, 15):
140139
abi = 'abi3.abi3t'
141140
else:
142141
abi = 'abi3'

tests/test_wheel.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import shutil
88
import stat
99
import sys
10-
import sysconfig
1110
import textwrap
1211

1312
import packaging.tags
@@ -16,16 +15,9 @@
1615

1716
import mesonpy
1817

19-
from .conftest import MESON_VERSION, adjust_packaging_platform_tag, metadata
18+
from .conftest import EXT_SUFFIX, FREE_THREADED_BUILD, MESON_VERSION, adjust_packaging_platform_tag, metadata
2019

2120

22-
EXT_SUFFIX = sysconfig.get_config_var('EXT_SUFFIX')
23-
if sys.version_info <= (3, 8, 7):
24-
if MESON_VERSION >= (0, 99):
25-
# Fixed in Meson 1.0, see https://github.com/mesonbuild/meson/pull/10961.
26-
from distutils.sysconfig import get_config_var
27-
EXT_SUFFIX = get_config_var('EXT_SUFFIX')
28-
2921
if sys.platform in {'win32', 'cygwin'}:
3022
EXT_IMP_SUFFIX = re.sub(r'.(pyd|dll)$', '.lib' if shutil.which('cl.exe') else '.dll.a', EXT_SUFFIX)
3123

@@ -35,8 +27,6 @@
3527
'win32': '.dll',
3628
}.get(sys.platform, '.so')
3729

38-
NOGIL_BUILD = bool(sysconfig.get_config_var('Py_GIL_DISABLED'))
39-
4030
# Test against the wheel tag generated by packaging module.
4131
tag = next(packaging.tags.sys_tags())
4232
ABI = tag.abi
@@ -321,7 +311,7 @@ def test_skip_subprojects(package_subproject, tmp_path, arg):
321311

322312
# Requires Meson 1.3.0, see https://github.com/mesonbuild/meson/pull/11745.
323313
@pytest.mark.skipif(MESON_VERSION < (1, 2, 99), reason='meson too old')
324-
@pytest.mark.skipif(NOGIL_BUILD, reason='Free-threaded CPython does not support the limited API')
314+
@pytest.mark.skipif(FREE_THREADED_BUILD, reason='Free-threaded CPython does not support the limited API')
325315
@pytest.mark.xfail('__pypy__' in sys.builtin_module_names, reason='PyPy does not support the abi3 platform tag for wheels')
326316
def test_limited_api(wheel_limited_api):
327317
artifact = wheel.wheelfile.WheelFile(wheel_limited_api)
@@ -333,7 +323,7 @@ def test_limited_api(wheel_limited_api):
333323

334324
# Requires Meson 1.3.0, see https://github.com/mesonbuild/meson/pull/11745.
335325
@pytest.mark.skipif(MESON_VERSION < (1, 2, 99), reason='meson too old')
336-
@pytest.mark.skipif(NOGIL_BUILD, reason='Free-threaded CPython does not support the limited API')
326+
@pytest.mark.skipif(FREE_THREADED_BUILD, reason='Free-threaded CPython does not support the limited API')
337327
@pytest.mark.xfail('__pypy__' in sys.builtin_module_names, reason='PyPy does not use special modules suffix for stable ABI')
338328
def test_limited_api_bad(package_limited_api, tmp_path):
339329
with pytest.raises(mesonpy.BuildError, match='The package declares compatibility with Python limited API but '):
@@ -421,5 +411,5 @@ def test_limited_api_free_threaded(wheel_limited_api_free_threaded):
421411
artifact = wheel.wheelfile.WheelFile(wheel_limited_api_free_threaded)
422412
name = artifact.parsed_filename
423413
assert name.group('pyver') == INTERPRETER
424-
assert name.group('abi') == 'abi3.abi3t' if NOGIL_BUILD else 'abi3'
414+
assert name.group('abi') == 'abi3.abi3t' if FREE_THREADED_BUILD else 'abi3'
425415
assert name.group('plat') == PLATFORM

0 commit comments

Comments
 (0)