Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
_meson_ver_str = subprocess.run(['meson', '--version'], check=True, stdout=subprocess.PIPE, text=True).stdout
MESON_VERSION = tuple(map(int, _meson_ver_str.split('.')[:3]))

EXT_SUFFIX = sysconfig.get_config_var('EXT_SUFFIX')
if sys.version_info <= (3, 8, 7):
if MESON_VERSION >= (0, 99):
# Fixed in Meson 1.0, see https://github.com/mesonbuild/meson/pull/10961.
from distutils.sysconfig import get_config_var
EXT_SUFFIX = get_config_var('EXT_SUFFIX')

FREE_THREADED_BUILD = bool(sysconfig.get_config_var('Py_GIL_DISABLED'))


def metadata(data):
meta, other = packaging.metadata.parse_email(data)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from mesonpy import _editable

from .test_wheel import EXT_SUFFIX, NOGIL_BUILD
from .conftest import EXT_SUFFIX, FREE_THREADED_BUILD


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


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


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


@pytest.mark.skipif(NOGIL_BUILD and CYTHON_VERSION < (3, 1, 0),
@pytest.mark.skipif(FREE_THREADED_BUILD and CYTHON_VERSION < (3, 1, 0),
reason='Cython version too old, no free-threaded CPython support')
def test_editable_verbose(venv, package_complex, editable_complex, monkeypatch):
monkeypatch.setenv('MESONPY_EDITABLE_VERBOSE', '1')
Expand Down
5 changes: 2 additions & 3 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import mesonpy
import mesonpy._tags

from .conftest import adjust_packaging_platform_tag
from .test_wheel import NOGIL_BUILD
from .conftest import FREE_THREADED_BUILD, adjust_packaging_platform_tag


# Test against the wheel tag generated by packaging module.
Expand Down Expand Up @@ -136,7 +135,7 @@ def test_tag_stable_abi():
# PyPy does not support the stable ABI.
if '__pypy__' in sys.builtin_module_names:
abi = ABI
elif NOGIL_BUILD and sys.version_info >= (3, 15):
elif FREE_THREADED_BUILD and sys.version_info >= (3, 15):
abi = 'abi3.abi3t'
else:
abi = 'abi3'
Expand Down
18 changes: 4 additions & 14 deletions tests/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import shutil
import stat
import sys
import sysconfig
import textwrap

import packaging.tags
Expand All @@ -16,16 +15,9 @@

import mesonpy

from .conftest import MESON_VERSION, adjust_packaging_platform_tag, metadata
from .conftest import EXT_SUFFIX, FREE_THREADED_BUILD, MESON_VERSION, adjust_packaging_platform_tag, metadata


EXT_SUFFIX = sysconfig.get_config_var('EXT_SUFFIX')
if sys.version_info <= (3, 8, 7):
if MESON_VERSION >= (0, 99):
# Fixed in Meson 1.0, see https://github.com/mesonbuild/meson/pull/10961.
from distutils.sysconfig import get_config_var
EXT_SUFFIX = get_config_var('EXT_SUFFIX')

if sys.platform in {'win32', 'cygwin'}:
EXT_IMP_SUFFIX = re.sub(r'.(pyd|dll)$', '.lib' if shutil.which('cl.exe') else '.dll.a', EXT_SUFFIX)

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

NOGIL_BUILD = bool(sysconfig.get_config_var('Py_GIL_DISABLED'))

# Test against the wheel tag generated by packaging module.
tag = next(packaging.tags.sys_tags())
ABI = tag.abi
Expand Down Expand Up @@ -321,7 +311,7 @@ def test_skip_subprojects(package_subproject, tmp_path, arg):

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

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