Skip to content

Commit

Permalink
Remove vendored pip and add Metadata class (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanking13 committed Oct 5, 2023
1 parent 1807ccb commit f975747
Show file tree
Hide file tree
Showing 21 changed files with 249 additions and 855 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ micropip/_version.py
dist/
build/
.venv*
.hypothesis/

.vscode
pyodide/
3 changes: 0 additions & 3 deletions micropip/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
loadedPackages,
loadPackage,
to_js,
wheel_dist_info_dir,
)
else:
from ._compat_not_in_pyodide import (
Expand All @@ -26,7 +25,6 @@
loadedPackages,
loadPackage,
to_js,
wheel_dist_info_dir,
)

__all__ = [
Expand All @@ -38,6 +36,5 @@
"loadDynlib",
"loadPackage",
"get_dynlibs",
"wheel_dist_info_dir",
"to_js",
]
3 changes: 1 addition & 2 deletions micropip/_compat_in_pyodide.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import IO
from urllib.parse import urlparse

from pyodide._package_loader import get_dynlibs, wheel_dist_info_dir
from pyodide._package_loader import get_dynlibs
from pyodide.ffi import IN_BROWSER, to_js
from pyodide.http import pyfetch

Expand Down Expand Up @@ -54,6 +54,5 @@ async def fetch_string_and_headers(
"loadDynlib",
"loadPackage",
"get_dynlibs",
"wheel_dist_info_dir",
"to_js",
]
39 changes: 0 additions & 39 deletions micropip/_compat_not_in_pyodide.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from io import BytesIO
from pathlib import Path
from typing import IO, Any
from zipfile import ZipFile

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

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


# Vendored from pip
class UnsupportedWheel(Exception):
"""Unsupported wheel."""


def wheel_dist_info_dir(source: ZipFile, name: str) -> str:
"""Returns the name of the contained .dist-info directory.
Raises UnsupportedWheel if not found, >1 found, or it doesn't match the
provided name.
"""
# Zip file path separators must be /
subdirs = {p.split("/", 1)[0] for p in source.namelist()}

info_dirs = [s for s in subdirs if s.endswith(".dist-info")]

if not info_dirs:
raise UnsupportedWheel(f".dist-info directory not found in wheel {name!r}")

if len(info_dirs) > 1:
raise UnsupportedWheel(
"multiple .dist-info directories found in wheel {!r}: {}".format(
name, ", ".join(info_dirs)
)
)

info_dir = info_dirs[0]

info_dir_name = canonicalize_name(info_dir)
canonical_name = canonicalize_name(name)
if not info_dir_name.startswith(canonical_name):
raise UnsupportedWheel(
f".dist-info directory {info_dir!r} does not start with {canonical_name!r}"
)

return info_dir


class pyodide_js_:
def __get__(self, attr):
raise RuntimeError(f"Attempted to access property '{attr}' on pyodide_js dummy")
Expand All @@ -122,6 +84,5 @@ def loadPackage(packages: str | list[str]) -> None:
"loadedPackages",
"loadPackage",
"get_dynlibs",
"wheel_dist_info_dir",
"to_js",
]
3 changes: 0 additions & 3 deletions micropip/externals/pip/__init__.py

This file was deleted.

Empty file.
Empty file.
40 changes: 0 additions & 40 deletions micropip/externals/pip/_internal/utils/pkg_resources.py

This file was deleted.

194 changes: 0 additions & 194 deletions micropip/externals/pip/_internal/utils/wheel.py

This file was deleted.

Empty file.
Loading

0 comments on commit f975747

Please sign in to comment.