Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions python/private/pypi/whl_extract.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ def whl_extract(rctx, *, whl_path, logger):
output = install_dir_path,
supports_whl_extraction = rp_config.supports_whl_extraction,
)

# Fix permissions on extracted files. Some wheels have files without read permissions set,
# which causes errors when trying to read them later.
os_name = repo_utils.get_platforms_os_name(rctx)
if os_name != "windows":
# On Unix-like systems, recursively add read permissions to all files
# and ensure directories are traversable (need execute permission)
result = repo_utils.execute_unchecked(
rctx,
op = "Fixing wheel permissions {}".format(whl_path),
arguments = ["chmod", "-R", "a+rX", str(install_dir_path)],
logger = logger,
)
if result.return_code != 0:
# It's possible chmod is not available or the filesystem doesn't support it.
# This is fine, we just want to try to fix permissions if possible.
logger.warn(lambda: "Failed to fix file permissions: {}".format(result.stderr))
metadata_file = find_whl_metadata(
install_dir = install_dir_path,
logger = logger,
Expand Down