Skip to content

Commit b4d4240

Browse files
dnicolodirgommers
authored andcommitted
BUG: PyPy does not use a special filename suffix for the stable API
1 parent a0f0827 commit b4d4240

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

mesonpy/__init__.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -382,18 +382,21 @@ def entrypoints_txt(self) -> bytes:
382382
@cached_property
383383
def _stable_abi(self) -> Optional[str]:
384384
if self._limited_api:
385-
# Verify stabe ABI compatibility: examine files installed
386-
# in {platlib} that look like extension modules, and raise
387-
# an exception if any of them has a Python version
388-
# specific extension filename suffix ABI tag.
389-
for path, _ in self._manifest['platlib']:
390-
match = _EXTENSION_SUFFIX_REGEX.match(path.name)
391-
if match:
392-
abi = match.group('abi')
393-
if abi is not None and abi != 'abi3':
394-
raise BuildError(
395-
f'The package declares compatibility with Python limited API but extension '
396-
f'module {os.fspath(path)!r} is tagged for a specific Python version.')
385+
# PyPy does not use a special extension module filename
386+
# suffix for modules targeting the stable API.
387+
if '__pypy__' not in sys.builtin_module_names:
388+
# Verify stable ABI compatibility: examine files installed
389+
# in {platlib} that look like extension modules, and raise
390+
# an exception if any of them has a Python version
391+
# specific extension filename suffix ABI tag.
392+
for path, _ in self._manifest['platlib']:
393+
match = _EXTENSION_SUFFIX_REGEX.match(path.name)
394+
if match:
395+
abi = match.group('abi')
396+
if abi is not None and abi != 'abi3':
397+
raise BuildError(
398+
f'The package declares compatibility with Python limited API but extension '
399+
f'module {os.fspath(path)!r} is tagged for a specific Python version.')
397400
return 'abi3'
398401
return None
399402

tests/test_tags.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def test_tag_stable_abi():
9494
assert str(builder.tag) == f'{INTERPRETER}-abi3-{PLATFORM}'
9595

9696

97-
@pytest.mark.skipif(sys.version_info < (3, 8) and sys.platform == 'win32',
98-
reason='Extension modules filename suffix without ABI tags')
97+
@pytest.mark.xfail(sys.version_info < (3, 8) and sys.platform == 'win32', reason='Extension modules suffix without ABI tags')
98+
@pytest.mark.xfail('__pypy__' in sys.builtin_module_names, reason='PyPy does not use special modules suffix for stable ABI')
9999
def test_tag_mixed_abi():
100100
builder = wheel_builder_test_factory({
101101
'platlib': [f'extension{ABI3SUFFIX}', f'another{SUFFIX}'],

tests/test_wheel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ def test_limited_api(wheel_limited_api):
299299

300300
# Requires Meson 1.3.0, see https://github.com/mesonbuild/meson/pull/11745.
301301
@pytest.mark.skipif(MESON_VERSION < (1, 2, 99), reason='Meson version too old')
302+
@pytest.mark.xfail('__pypy__' in sys.builtin_module_names, reason='PyPy does not use special modules suffix for stable ABI')
302303
def test_limited_api_bad(package_limited_api, tmp_path):
303304
with pytest.raises(mesonpy.BuildError, match='The package declares compatibility with Python limited API but '):
304305
with mesonpy._project({'setup-args': ['-Dextra=true']}) as project:

0 commit comments

Comments
 (0)