Skip to content

Commit 08132d3

Browse files
thirtysevengemini-code-assist[bot]rickeylev
authored andcommitted
fix(pip): add read permissions when extracting wheels (#3555)
Fix for wheels like https://files.pythonhosted.org/packages/ad/39/da8b5c0f875ccb1770349caaecd87a253949ccbcdc2c869929919d744551/ag_ui_adk-0.4.2-py3-none-any.whl where the contents do not have the read bit set. Fixes #3554 --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Richard Levasseur <rlevasseur@google.com> (cherry picked from commit 96a1653)
1 parent 0057883 commit 08132d3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

python/private/pypi/whl_extract.bzl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ 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 os_name != "windows":
27+
# On Unix-like systems, recursively add read permissions to all files
28+
# and ensure directories are traversable (need execute permission)
29+
result = repo_utils.execute_unchecked(
30+
rctx,
31+
op = "Fixing wheel permissions {}".format(whl_path),
32+
arguments = ["chmod", "-R", "a+rX", str(install_dir_path)],
33+
logger = logger,
34+
)
35+
if result.return_code != 0:
36+
# It's possible chmod is not available or the filesystem doesn't support it.
37+
# This is fine, we just want to try to fix permissions if possible.
38+
logger.warn(lambda: "Failed to fix file permissions: {}".format(result.stderr))
2239
metadata_file = find_whl_metadata(
2340
install_dir = install_dir_path,
2441
logger = logger,

0 commit comments

Comments
 (0)