Skip to content

Commit ab47095

Browse files
committed
move the requirement line parsing to starlark
1 parent 8a39422 commit ab47095

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

python/private/pypi/whl_installer/wheel_installer.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def _setup_namespace_pkg_compatibility(wheel_dir: str) -> None:
103103

104104
def _extract_wheel(
105105
wheel_file: str,
106-
extras: Dict[str, Set[str]],
107106
enable_implicit_namespace_pkgs: bool,
108107
installation_dir: Path = Path("."),
109108
) -> None:
@@ -112,7 +111,6 @@ def _extract_wheel(
112111
Args:
113112
wheel_file: the filepath of the .whl
114113
installation_dir: the destination directory for installation of the wheel.
115-
extras: a list of extras to add as dependencies for the installed wheel
116114
enable_implicit_namespace_pkgs: if true, disables conversion of implicit namespace packages and will unzip as-is
117115
"""
118116

@@ -122,13 +120,11 @@ def _extract_wheel(
122120
if not enable_implicit_namespace_pkgs:
123121
_setup_namespace_pkg_compatibility(installation_dir)
124122

125-
extras_requested = extras[whl.name] if whl.name in extras else set()
126123
requires_dist = whl.metadata.get_all("Requires-Dist", [])
127124
abi = f"cp{sys.version_info.major}{sys.version_info.minor}"
128125
metadata = {
129126
"name": whl.name,
130127
"version": whl.version,
131-
"extras": list(extras_requested),
132128
"python_version": sys.version.partition(" ")[0],
133129
"requires_dist": requires_dist,
134130
"abi": abi,
@@ -157,11 +153,8 @@ def main() -> None:
157153
if args.whl_file:
158154
whl = Path(args.whl_file)
159155

160-
name, extras_for_pkg = _parse_requirement_for_extra(args.requirement)
161-
extras = {name: extras_for_pkg} if extras_for_pkg and name else dict()
162156
_extract_wheel(
163157
wheel_file=whl,
164-
extras=extras,
165158
enable_implicit_namespace_pkgs=args.enable_implicit_namespace_pkgs,
166159
)
167160
return

python/private/pypi/whl_library.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ load(":parse_requirements.bzl", "host_platform")
2525
load(":parse_whl_name.bzl", "parse_whl_name")
2626
load(":patch_whl.bzl", "patch_whl")
2727
load(":pep508_deps.bzl", "deps")
28+
load(":pep508_requirement.bzl", "requirement")
2829
load(":pypi_repo_utils.bzl", "pypi_repo_utils")
2930
load(":whl_target_platforms.bzl", "whl_target_platforms")
3031

@@ -430,7 +431,7 @@ def _whl_library_impl(rctx):
430431
platforms = target_platforms or [
431432
"{}_{}".format(metadata["abi"], host_platform(rctx)),
432433
],
433-
extras = metadata["extras"],
434+
extras = requirement(rctx.attr.requirement).extras,
434435
host_python_version = metadata["python_version"],
435436
)
436437

0 commit comments

Comments
 (0)