Skip to content

Commit f975747

Browse files
authored
Remove vendored pip and add Metadata class (#87)
1 parent 1807ccb commit f975747

21 files changed

+249
-855
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ micropip/_version.py
44
dist/
55
build/
66
.venv*
7+
.hypothesis/
78

89
.vscode
910
pyodide/

micropip/_compat.py

-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
loadedPackages,
1414
loadPackage,
1515
to_js,
16-
wheel_dist_info_dir,
1716
)
1817
else:
1918
from ._compat_not_in_pyodide import (
@@ -26,7 +25,6 @@
2625
loadedPackages,
2726
loadPackage,
2827
to_js,
29-
wheel_dist_info_dir,
3028
)
3129

3230
__all__ = [
@@ -38,6 +36,5 @@
3836
"loadDynlib",
3937
"loadPackage",
4038
"get_dynlibs",
41-
"wheel_dist_info_dir",
4239
"to_js",
4340
]

micropip/_compat_in_pyodide.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import IO
33
from urllib.parse import urlparse
44

5-
from pyodide._package_loader import get_dynlibs, wheel_dist_info_dir
5+
from pyodide._package_loader import get_dynlibs
66
from pyodide.ffi import IN_BROWSER, to_js
77
from pyodide.http import pyfetch
88

@@ -54,6 +54,5 @@ async def fetch_string_and_headers(
5454
"loadDynlib",
5555
"loadPackage",
5656
"get_dynlibs",
57-
"wheel_dist_info_dir",
5857
"to_js",
5958
]

micropip/_compat_not_in_pyodide.py

-39
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from io import BytesIO
33
from pathlib import Path
44
from typing import IO, Any
5-
from zipfile import ZipFile
65

76
REPODATA_PACKAGES: dict[str, dict[str, Any]] = {}
87

@@ -64,43 +63,6 @@ def canonicalize_name(name: str) -> str:
6463
return _canonicalize_regex.sub("-", name).lower()
6564

6665

67-
# Vendored from pip
68-
class UnsupportedWheel(Exception):
69-
"""Unsupported wheel."""
70-
71-
72-
def wheel_dist_info_dir(source: ZipFile, name: str) -> str:
73-
"""Returns the name of the contained .dist-info directory.
74-
Raises UnsupportedWheel if not found, >1 found, or it doesn't match the
75-
provided name.
76-
"""
77-
# Zip file path separators must be /
78-
subdirs = {p.split("/", 1)[0] for p in source.namelist()}
79-
80-
info_dirs = [s for s in subdirs if s.endswith(".dist-info")]
81-
82-
if not info_dirs:
83-
raise UnsupportedWheel(f".dist-info directory not found in wheel {name!r}")
84-
85-
if len(info_dirs) > 1:
86-
raise UnsupportedWheel(
87-
"multiple .dist-info directories found in wheel {!r}: {}".format(
88-
name, ", ".join(info_dirs)
89-
)
90-
)
91-
92-
info_dir = info_dirs[0]
93-
94-
info_dir_name = canonicalize_name(info_dir)
95-
canonical_name = canonicalize_name(name)
96-
if not info_dir_name.startswith(canonical_name):
97-
raise UnsupportedWheel(
98-
f".dist-info directory {info_dir!r} does not start with {canonical_name!r}"
99-
)
100-
101-
return info_dir
102-
103-
10466
class pyodide_js_:
10567
def __get__(self, attr):
10668
raise RuntimeError(f"Attempted to access property '{attr}' on pyodide_js dummy")
@@ -122,6 +84,5 @@ def loadPackage(packages: str | list[str]) -> None:
12284
"loadedPackages",
12385
"loadPackage",
12486
"get_dynlibs",
125-
"wheel_dist_info_dir",
12687
"to_js",
12788
]

micropip/externals/pip/__init__.py

-3
This file was deleted.

micropip/externals/pip/_internal/__init__.py

Whitespace-only changes.

micropip/externals/pip/_internal/utils/__init__.py

Whitespace-only changes.

micropip/externals/pip/_internal/utils/pkg_resources.py

-40
This file was deleted.

micropip/externals/pip/_internal/utils/wheel.py

-194
This file was deleted.

micropip/externals/pip/_vendor/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)