Skip to content

Commit

Permalink
pip_install: avoid assuming 'Root-Is-Purelib' is provided in all WHEE…
Browse files Browse the repository at this point in the history
…L files. #435 (#485)
  • Loading branch information
Jonathon Belotti authored Jun 9, 2021
1 parent d95e89f commit ce19337
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions python/pip_install/extract_wheels/lib/purelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ def spread_purelib_into_root(wheel_dir: str) -> None:
wheel_metadata_file_path = pathlib.Path(dist_info, "WHEEL")
wheel_metadata_dict = wheel.parse_wheel_meta_file(str(wheel_metadata_file_path))

if "Root-Is-Purelib" not in wheel_metadata_dict:
raise ValueError(
"Invalid WHEEL file '%s'. Expected key 'Root-Is-Purelib'."
% wheel_metadata_file_path
)
root_is_purelib = wheel_metadata_dict["Root-Is-Purelib"]

# It is not guaranteed that a WHEEL file author populates 'Root-Is-Purelib'.
# See: https://github.com/bazelbuild/rules_python/issues/435
root_is_purelib: str = wheel_metadata_dict.get("Root-Is-Purelib", "")
if root_is_purelib.lower() == "true":
# The Python package code is in the root of the Wheel, so no need to 'spread' anything.
return
Expand Down

0 comments on commit ce19337

Please sign in to comment.