Skip to content

Commit

Permalink
Support abi3 wheels (#32)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tomjakubowski authored Sep 17, 2024
1 parent 1cd330f commit 24b049c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
16 changes: 12 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# Changelog

All notable changes to this project will be documented in this file.

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

## Unreleased

## [0.1.0a8] - 2024-09-17

### Added

- Support stable ABI (`abi3`) wheels in lock file.
[#32](https://github.com/pyodide/pyodide-lock/pull/32)

## [0.1.0a7] - 2024-08-08

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

### Added

- Add `check_wheel_filenames` method to `PyodideLockSpec` that checks that the
package name in version are consistent between the wheel filename and the
corresponding pyodide-lock.json fields
[#11](https://github.com/pyodide/pyodide-lock/pull/11)
- Add `check_wheel_filenames` method to `PyodideLockSpec` that checks that the
package name in version are consistent between the wheel filename and the
corresponding pyodide-lock.json fields
[#11](https://github.com/pyodide/pyodide-lock/pull/11)

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

Expand Down
5 changes: 5 additions & 0 deletions pyodide_lock/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ def _check_wheel_compatible(path: Path, info: InfoSpec) -> None:
raise RuntimeError(f"Wheel filename {path.name} is not valid") from e
python_binary_abi = f"cp{target_python.major}{target_python.minor}"
tags = list(tags)
abi3_compat = {
f"cp{target_python.major}{minor}" for minor in range(target_python.minor + 1)
}

tag_match = False
for t in tags:
Expand All @@ -331,6 +334,8 @@ def _check_wheel_compatible(path: Path, info: InfoSpec) -> None:
and t.platform == target_platform
):
tag_match = True
elif t.abi == "abi3" and t.interpreter in abi3_compat:
tag_match = True
elif t.abi == "none" and t.platform == "any":
match = re.match(rf"py{target_python.major}(\d*)", t.interpreter)
if match:
Expand Down
18 changes: 18 additions & 0 deletions tests/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ def test_wheel_compatibility_checking(example_lock_spec):
Path(f"test_wheel-1.0.0-{cpython_tag}-{cpython_tag}-{emscripten_tag}.whl"),
example_lock_spec.info,
)
# abi3, current version
_check_wheel_compatible(
Path(f"test_wheel-1.0.0-{cpython_tag}-abi3-{emscripten_tag}.whl"),
example_lock_spec.info,
)
# abi3, past version
past_cpython_tag = f"cp{target_python.major}{target_python.minor-1}"
_check_wheel_compatible(
Path(f"test_wheel-1.0.0-{past_cpython_tag}-abi3-{emscripten_tag}.whl"),
example_lock_spec.info,
)
with pytest.raises(RuntimeError):
# cpython emscripten incorrect version
_check_wheel_compatible(
Expand All @@ -177,6 +188,13 @@ def test_wheel_compatibility_checking(example_lock_spec):
),
example_lock_spec.info,
)
with pytest.raises(RuntimeError):
# abi3, interpreter version too large
future_cpython_tag = f"cp{target_python.major}{target_python.minor+1}"
_check_wheel_compatible(
Path(f"test_wheel-1.0.0-{future_cpython_tag}-abi3-{emscripten_tag}.whl"),
example_lock_spec.info,
)
with pytest.raises(RuntimeError):
# a linux wheel
_check_wheel_compatible(
Expand Down

0 comments on commit 24b049c

Please sign in to comment.