Skip to content

Commit

Permalink
BUG: PyPy does not use a special filename suffix for the stable API
Browse files Browse the repository at this point in the history
  • Loading branch information
dnicolodi authored and rgommers committed Sep 10, 2023
1 parent a0f0827 commit b4d4240
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
27 changes: 15 additions & 12 deletions mesonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,18 +382,21 @@ def entrypoints_txt(self) -> bytes:
@cached_property
def _stable_abi(self) -> Optional[str]:
if self._limited_api:
# Verify stabe ABI compatibility: examine files installed
# in {platlib} that look like extension modules, and raise
# an exception if any of them has a Python version
# specific extension filename suffix ABI tag.
for path, _ in self._manifest['platlib']:
match = _EXTENSION_SUFFIX_REGEX.match(path.name)
if match:
abi = match.group('abi')
if abi is not None and abi != 'abi3':
raise BuildError(
f'The package declares compatibility with Python limited API but extension '
f'module {os.fspath(path)!r} is tagged for a specific Python version.')
# PyPy does not use a special extension module filename
# suffix for modules targeting the stable API.
if '__pypy__' not in sys.builtin_module_names:
# Verify stable ABI compatibility: examine files installed
# in {platlib} that look like extension modules, and raise
# an exception if any of them has a Python version
# specific extension filename suffix ABI tag.
for path, _ in self._manifest['platlib']:
match = _EXTENSION_SUFFIX_REGEX.match(path.name)
if match:
abi = match.group('abi')
if abi is not None and abi != 'abi3':
raise BuildError(
f'The package declares compatibility with Python limited API but extension '
f'module {os.fspath(path)!r} is tagged for a specific Python version.')
return 'abi3'
return None

Expand Down
4 changes: 2 additions & 2 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def test_tag_stable_abi():
assert str(builder.tag) == f'{INTERPRETER}-abi3-{PLATFORM}'


@pytest.mark.skipif(sys.version_info < (3, 8) and sys.platform == 'win32',
reason='Extension modules filename suffix without ABI tags')
@pytest.mark.xfail(sys.version_info < (3, 8) and sys.platform == 'win32', reason='Extension modules suffix without ABI tags')
@pytest.mark.xfail('__pypy__' in sys.builtin_module_names, reason='PyPy does not use special modules suffix for stable ABI')
def test_tag_mixed_abi():
builder = wheel_builder_test_factory({
'platlib': [f'extension{ABI3SUFFIX}', f'another{SUFFIX}'],
Expand Down
1 change: 1 addition & 0 deletions tests/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,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 version too old')
@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 '):
with mesonpy._project({'setup-args': ['-Dextra=true']}) as project:
Expand Down

0 comments on commit b4d4240

Please sign in to comment.