Skip to content

Commit

Permalink
Hardcode support for platform pyodide_wasm32
Browse files Browse the repository at this point in the history
Also cahnge some Generators to Tuple, as it is not the first time that
while debugging I exaust the generator when printing logs; and this make
micropip installing the package to fail.

I don't like it; this feels like a hack, but it works, and I woudl 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.
  • Loading branch information
Carreau committed Nov 22, 2024
1 parent 1fa0b52 commit 5428a37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
9 changes: 7 additions & 2 deletions micropip/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ 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 = []
for tag in sys_tags_orig():
if "emscripten" in tag.platform:
new_tags.append(Tag(tag.interpreter, tag.abi, "pyodide_2024_0_wasm32"))
new_tags.append(tag)
return tuple(new_tags)


@functools.cache
Expand Down
11 changes: 7 additions & 4 deletions micropip/package_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ProjectInfo:
# List of releases available for the package, sorted in ascending order by version.
# For each version, list of wheels compatible with the current platform are stored.
# If no such wheel is available, the list is empty.
releases: dict[Version, Generator[WheelInfo, None, None]]
releases: dict[Version, tuple[WheelInfo, ...]]

@staticmethod
def from_json_api(data: str | bytes | dict[str, Any]) -> "ProjectInfo":
Expand Down Expand Up @@ -174,15 +174,15 @@ def _compatible_only(
Checking compatibility takes a bit of time, so we use a generator to avoid doing it if not needed.
"""

releases_compatible = {
version: cls._compatible_wheels(files, version, name=name)
releases_compatible_x = {
version: tuple(cls._compatible_wheels(files, version, name=name))
for version, files in releases.items()
}

# Unfortunately, the JSON API seems to compare versions as strings...
# For example, pytest 3.10.0 is considered newer than 3.2.0.
# So we need to sort the releases by version again here.
releases_compatible = dict(sorted(releases_compatible.items()))
releases_compatible = dict(list(sorted(releases_compatible_x.items())))

return cls(
name=name,
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 5428a37

Please sign in to comment.