From 0672acdf2f3f24855d10ddd2a6796d4636dc4b15 Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Fri, 22 Nov 2024 14:24:18 +0100 Subject: [PATCH 1/2] Hardcode support for platform pyodide_wasm32 I don't like it; this feels like a hack, but it works, and I would be happy to get more guidance. Also one weird thing, is if I installl pywavelets nightly, it installs numpy stable; while the index does have a numpy nightly; And with the same config, if I ask it to install numpy; it does install numpy nightly. So there is something wonkey in recursive dependency handling of indexes. --- CHANGELOG.md | 7 +++++++ micropip/_utils.py | 13 ++++++++++--- micropip/package_index.py | 3 +++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4b4bbf..eef708f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ 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 + +### Fixed + + - Fix a bug that prevented some wasm32 wheel to be recognized as compatible with pyodide + [#159](https://github.com/pyodide/micropip/pull/159) + ## [0.7.1] - 2024/11/11 ### Fixed diff --git a/micropip/_utils.py b/micropip/_utils.py index 1167a01..70d4724 100644 --- a/micropip/_utils.py +++ b/micropip/_utils.py @@ -2,7 +2,7 @@ import json from importlib.metadata import Distribution from pathlib import Path -from sysconfig import get_platform +from sysconfig import get_config_var, get_platform from packaging.requirements import Requirement from packaging.tags import Tag @@ -62,8 +62,15 @@ def get_files_in_distribution(dist: Distribution) -> set[Path]: @functools.cache -def sys_tags() -> list[Tag]: - return list(sys_tags_orig()) +def sys_tags() -> tuple[Tag, ...]: + new_tags = [] + abi_version = get_config_var("PYODIDE_ABI_VERSION") + pyodide_platform_tag = f"pyodide_{abi_version}_wasm32" + for tag in sys_tags_orig(): + if "emscripten" in tag.platform: + new_tags.append(Tag(tag.interpreter, tag.abi, pyodide_platform_tag)) + new_tags.append(tag) + return tuple(new_tags) @functools.cache diff --git a/micropip/package_index.py b/micropip/package_index.py index 526db89..3e07d8c 100644 --- a/micropip/package_index.py +++ b/micropip/package_index.py @@ -214,6 +214,9 @@ def _fast_check_incompatibility(filename: str) -> bool: if not filename.endswith(".whl"): return False + if filename.endswith("wasm32.whl") and sys.platform == "emscripten": + return True + if sys.platform not in filename and not filename.endswith("-none-any.whl"): return False From 65d3e879fda8836245e4ea1b116e6f43e3ccc979 Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Tue, 26 Nov 2024 10:10:41 +0100 Subject: [PATCH 2/2] try to add test --- tests/test_utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_utils.py b/tests/test_utils.py index 51de135..7d0522b 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -3,6 +3,7 @@ import pytest from conftest import CPVER, EMSCRIPTEN_VER, PLATFORM +from pytest_pyodide import run_in_pyodide import micropip._utils as _utils @@ -103,6 +104,18 @@ def test_check_compatible(mock_platform, interp, abi, arch, ctx): check_compatible(wheel_name) +@run_in_pyodide +def test_check_compatible_wasm32(selenium_standalone_micropip): + """ + Here we check in particular that pyodide_2024_0_wasm32 wheels are seen as + compatible as the platform is emscripten + """ + from micropip._utils import check_compatible + + wheel_name = "pywavelets-1.8.0.dev0-cp312-cp312-pyodide_2024_0_wasm32.whl" + check_compatible(wheel_name) + + _best_tag_test_cases = ( "package, version, incompatible_tags, compatible_tags", # Tests assume that `compatible_tags` is sorted from least to most compatible: