Skip to content

Commit

Permalink
Merge pull request #515 from shubhbapna/set-permission-bits
Browse files Browse the repository at this point in the history
set the permission bits when unpacking a wheel
  • Loading branch information
mergify[bot] authored Nov 26, 2024
2 parents eb69a95 + 614f272 commit 43b62eb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/fromager/wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ def add_extra_metadata_to_wheels(
with tempfile.TemporaryDirectory() as dir_name:
wheel_root_dir = pathlib.Path(dir_name) / dist_filename
wheel_root_dir.mkdir()
zipfile.ZipFile(str(wheel_file)).extractall(str(wheel_root_dir))
with zipfile.ZipFile(str(wheel_file)) as zf:
for infolist in zf.filelist:
zf.extract(infolist, wheel_root_dir)
# the higher 16 bits store the permissions and type of file (i.e. stat.filemode)
# the lower bits of this give us the permission
permissions = infolist.external_attr >> 16 & 0o777
wheel_root_dir.joinpath(infolist.filename).chmod(permissions)

dist_info_dir = wheel_root_dir / f"{dist_filename}.dist-info"
if not dist_info_dir.is_dir():
Expand Down

0 comments on commit 43b62eb

Please sign in to comment.