Skip to content

Commit 24b049c

Browse files
Support abi3 wheels (#32)
* Support abi3 wheels abi3 is also known as the stable ABI https://docs.python.org/3/c-api/stable.html#stable-abi abi3 wheels are forwards compatible, meaning an abi3-py39 wheel will work with Python 3.9, 3.10, 3.11, 3.12, and so on. * Update CHANGELOG.md
1 parent 1cd330f commit 24b049c

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

CHANGELOG.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
# Changelog
2+
23
All notable changes to this project will be documented in this file.
34

45
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
56
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
67

78
## Unreleased
89

10+
## [0.1.0a8] - 2024-09-17
11+
12+
### Added
13+
14+
- Support stable ABI (`abi3`) wheels in lock file.
15+
[#32](https://github.com/pyodide/pyodide-lock/pull/32)
16+
917
## [0.1.0a7] - 2024-08-08
1018

1119
### Added
@@ -57,10 +65,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5765

5866
### Added
5967

60-
- Add `check_wheel_filenames` method to `PyodideLockSpec` that checks that the
61-
package name in version are consistent between the wheel filename and the
62-
corresponding pyodide-lock.json fields
63-
[#11](https://github.com/pyodide/pyodide-lock/pull/11)
68+
- Add `check_wheel_filenames` method to `PyodideLockSpec` that checks that the
69+
package name in version are consistent between the wheel filename and the
70+
corresponding pyodide-lock.json fields
71+
[#11](https://github.com/pyodide/pyodide-lock/pull/11)
6472

6573
## [0.1.0a1] - 2023-06-23
6674

pyodide_lock/utils.py

+5
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ def _check_wheel_compatible(path: Path, info: InfoSpec) -> None:
321321
raise RuntimeError(f"Wheel filename {path.name} is not valid") from e
322322
python_binary_abi = f"cp{target_python.major}{target_python.minor}"
323323
tags = list(tags)
324+
abi3_compat = {
325+
f"cp{target_python.major}{minor}" for minor in range(target_python.minor + 1)
326+
}
324327

325328
tag_match = False
326329
for t in tags:
@@ -331,6 +334,8 @@ def _check_wheel_compatible(path: Path, info: InfoSpec) -> None:
331334
and t.platform == target_platform
332335
):
333336
tag_match = True
337+
elif t.abi == "abi3" and t.interpreter in abi3_compat:
338+
tag_match = True
334339
elif t.abi == "none" and t.platform == "any":
335340
match = re.match(rf"py{target_python.major}(\d*)", t.interpreter)
336341
if match:

tests/test_wheel.py

+18
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,17 @@ def test_wheel_compatibility_checking(example_lock_spec):
169169
Path(f"test_wheel-1.0.0-{cpython_tag}-{cpython_tag}-{emscripten_tag}.whl"),
170170
example_lock_spec.info,
171171
)
172+
# abi3, current version
173+
_check_wheel_compatible(
174+
Path(f"test_wheel-1.0.0-{cpython_tag}-abi3-{emscripten_tag}.whl"),
175+
example_lock_spec.info,
176+
)
177+
# abi3, past version
178+
past_cpython_tag = f"cp{target_python.major}{target_python.minor-1}"
179+
_check_wheel_compatible(
180+
Path(f"test_wheel-1.0.0-{past_cpython_tag}-abi3-{emscripten_tag}.whl"),
181+
example_lock_spec.info,
182+
)
172183
with pytest.raises(RuntimeError):
173184
# cpython emscripten incorrect version
174185
_check_wheel_compatible(
@@ -177,6 +188,13 @@ def test_wheel_compatibility_checking(example_lock_spec):
177188
),
178189
example_lock_spec.info,
179190
)
191+
with pytest.raises(RuntimeError):
192+
# abi3, interpreter version too large
193+
future_cpython_tag = f"cp{target_python.major}{target_python.minor+1}"
194+
_check_wheel_compatible(
195+
Path(f"test_wheel-1.0.0-{future_cpython_tag}-abi3-{emscripten_tag}.whl"),
196+
example_lock_spec.info,
197+
)
180198
with pytest.raises(RuntimeError):
181199
# a linux wheel
182200
_check_wheel_compatible(

0 commit comments

Comments
 (0)