8000 pip_install: avoid assuming 'Root-Is-Purelib' is provided in all WHEE… · lapointexavier/rules_python@ce19337 · GitHub
[go: up one dir, main page]

Skip to content

Commit ce19337

Browse files
author
Jonathon Belotti
authored
pip_install: avoid assuming 'Root-Is-Purelib' is provided in all WHEEL files. bazel-contrib#435 (bazel-contrib#485)
1 parent d95e89f commit ce19337

File 8000 tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

python/pip_install/extract_wheels/lib/purelib.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@ def spread_purelib_into_root(wheel_dir: str) -> None:
1515
wheel_metadata_file_path = pathlib.Path(dist_info, "WHEEL")
1616
wheel_metadata_dict = wheel.parse_wheel_meta_file(str(wheel_metadata_file_path))
1717

18-
if "Root-Is-Purelib" not in wheel_metadata_dict:
19-
raise ValueError(
20-
"Invalid WHEEL file '%s'. Expected key 'Root-Is-Purelib'."
21-
% wheel_metadata_file_path
22-
)
23-
root_is_purelib = wheel_metadata_dict["Root-Is-Purelib"]
24-
18+
# It is not guaranteed that a WHEEL file author populates 'Root-Is-Purelib'.
19+
# See: https://github.com/bazelbuild/rules_python/issues/435
20+
root_is_purelib: str = wheel_metadata_dict.get("Root-Is-Purelib", "")
2521
if root_is_purelib.lower() == "true":
2622
# The Python package code is in the root of the Wheel, so no need to 'spread' anything.
2723
return

0 commit comments

Comments
 (0)
0