Skip to content

Commit e5a180c

Browse files
lpsingerdnicolodi
authored andcommitted
BUG: disable abi3 wheel tag for PyPy
PyPy supports the limited API but not the stable ABI.
1 parent 691d312 commit e5a180c

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

Diff for: mesonpy/__init__.py

+17-16
Original file line numberDiff line numberDiff line change
@@ -406,22 +406,23 @@ def entrypoints_txt(self) -> bytes:
406406

407407
@cached_property
408408
def _stable_abi(self) -> Optional[str]:
409-
if self._limited_api:
410-
# PyPy does not use a special extension module filename
411-
# suffix for modules targeting the stable API.
412-
if '__pypy__' not in sys.builtin_module_names:
413-
# Verify stable ABI compatibility: examine files installed
414-
# in {platlib} that look like extension modules, and raise
415-
# an exception if any of them has a Python version
416-
# specific extension filename suffix ABI tag.
417-
for path, _ in self._manifest['platlib']:
418-
match = _EXTENSION_SUFFIX_REGEX.match(path.name)
419-
if match:
420-
abi = match.group('abi')
421-
if abi is not None and abi != 'abi3':
422-
raise BuildError(
423-
f'The package declares compatibility with Python limited API but extension '
424-
f'module {os.fspath(path)!r} is tagged for a specific Python version.')
409+
# PyPy supports the limited API but does not provide a stable
410+
# ABI, therefore extension modules using the limited API do
411+
# not use the stable ABI filename suffix and wheels should not
412+
# be tagged with the abi3 tag.
413+
if self._limited_api and '__pypy__' not in sys.builtin_module_names:
414+
# Verify stable ABI compatibility: examine files installed
415+
# in {platlib} that look like extension modules, and raise
416+
# an exception if any of them has a Python version
417+
# specific extension filename suffix ABI tag.
418+
for path, _ in self._manifest['platlib']:
419+
match = _EXTENSION_SUFFIX_REGEX.match(path.name)
420+
if match:
421+
abi = match.group('abi')
422+
if abi is not None and abi != 'abi3':
423+
raise BuildError(
424+
f'The package declares compatibility with Python limited API but extension '
425+
f'module {os.fspath(path)!r} is tagged for a specific Python version.')
425426
return 'abi3'
426427
return None
427428

Diff for: tests/test_tags.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,13 @@ def test_tag_stable_abi():
103103
builder = wheel_builder_test_factory({
104104
'platlib': [f'extension{ABI3SUFFIX}'],
105105
}, limited_api=True)
106-
assert str(builder.tag) == f'{INTERPRETER}-abi3-{PLATFORM}'
106+
# PyPy does not support the stable ABI.
107+
abi = 'abi3' if '__pypy__' not in sys.builtin_module_names else ABI
108+
assert str(builder.tag) == f'{INTERPRETER}-{abi}-{PLATFORM}'
107109

108110

109111
@pytest.mark.xfail(sys.version_info < (3, 8) and sys.platform == 'win32', reason='Extension modules suffix without ABI tags')
110-
@pytest.mark.xfail('__pypy__' in sys.builtin_module_names, reason='PyPy does not use special modules suffix for stable ABI')
112+
@pytest.mark.xfail('__pypy__' in sys.builtin_module_names, reason='PyPy does not support the stable ABI')
111113
def test_tag_mixed_abi():
112114
builder = wheel_builder_test_factory({
113115
'platlib': [f'extension{ABI3SUFFIX}', f'another{SUFFIX}'],

Diff for: tests/test_wheel.py

+1
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ def test_skip_subprojects(package_subproject, tmp_path, arg):
290290
# Requires Meson 1.3.0, see https://github.com/mesonbuild/meson/pull/11745.
291291
@pytest.mark.skipif(MESON_VERSION < (1, 2, 99), reason='Meson version too old')
292292
@pytest.mark.skipif(NOGIL_BUILD, reason='Free-threaded CPython does not support the limited API')
293+
@pytest.mark.xfail('__pypy__' in sys.builtin_module_names, reason='PyPy does not support the abi3 platform tag for wheels')
293294
def test_limited_api(wheel_limited_api):
294295
artifact = wheel.wheelfile.WheelFile(wheel_limited_api)
295296
name = artifact.parsed_filename

0 commit comments

Comments
 (0)