Skip to content

Commit fd1c011

Browse files
committed
Set permissions when extracting wheels
1 parent abe2699 commit fd1c011

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

python/private/pypi/whl_extract.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ def whl_extract(rctx, *, whl_path, logger):
1919
output = install_dir_path,
2020
supports_whl_extraction = rp_config.supports_whl_extraction,
2121
)
22+
23+
# Fix permissions on extracted files. Some wheels have files without read permissions set,
24+
# which causes errors when trying to read them later.
25+
os_name = repo_utils.get_platforms_os_name(rctx)
26+
if "windows" not in os_name:
27+
# On Unix-like systems, recursively add read permissions to all files
28+
# and ensure directories are traversable (need execute permission)
29+
result = rctx.execute(["chmod", "-R", "u+rX,go+rX", str(install_dir_path)])
30+
if result.return_code != 0:
31+
logger.warn(lambda: "Failed to fix file permissions: {}".format(result.stderr))
2232
metadata_file = find_whl_metadata(
2333
install_dir = install_dir_path,
2434
logger = logger,

0 commit comments

Comments
 (0)