Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executable permissions for scripts are reset or are not set #66

Closed
stanislavlevin opened this issue Apr 8, 2024 · 0 comments · Fixed by #67
Closed

Executable permissions for scripts are reset or are not set #66

stanislavlevin opened this issue Apr 8, 2024 · 0 comments · Fixed by #67

Comments

@stanislavlevin
Copy link
Owner

Problem:

executable permissions for scripts are reset or are not set.

How to reproduce:

  1. build a project that has a compiled binary (e.g. uv):
[user@host dir]$ /usr/bin/python3 -m pyproject_installer -v build
  1. install it into virtual environment and run:
[user@host dir]$ /usr/bin/python3 -m pyproject_installer run -- uv --version
...
INFO     : Command's error: [Errno 13] Permission denied: 'uv'
  1. unpacked file permissions:
[user@host dir]$ ls -la .run_venv/bin/uv 
-rw-r--r-- 1 user user 29215160 Apr  8 15:04 .run_venv/bin/uv
  1. packed file permissions:
[user@host dir]$ zipinfo dist/uv-0.1.26-py3-none-linux_x86_64.whl uv-0.1.26.data/scripts/uv
-rwxr-xr-x  4.6 unx 29215160 b- defN 24-Apr-08 14:41 uv-0.1.26.data/scripts/uv

ZipFile doesn't preserve file permissions in Python:
python/cpython#59999

Today's Python packaging specification is not clear about that:
https://packaging.python.org/en/latest/specifications/binary-distribution-format/

In wheel, scripts are packaged in {distribution}-{version}.data/scripts/. If the first line of a file in scripts/ starts with exactly b'#!python', rewrite to point to the correct interpreter. Unix installers may need to add the +x bit to these files if the archive was created on Windows.

stanislavlevin added a commit that referenced this issue Apr 9, 2024
Today's Python packaging specification is not clear about making
binaries executable on installation from data/scripts/ directory:
https://packaging.python.org/en/latest/specifications/binary-distribution-format/

> In wheel, scripts are packaged in
  {distribution}-{version}.data/scripts/. If the first line of a file in
  scripts/ starts with exactly b'#!python', rewrite to point to the
  correct interpreter. Unix installers may need to add the +x bit to these
  files if the archive was created on Windows.

ZipFile in turn, doesn't preserve file permissions in Python:
python/cpython#59999

This leads to situation when freshly installed binaries can't be
executed.

Fixes: #66
Signed-off-by: Stanislav Levin <slev@altlinux.org>
stanislavlevin added a commit that referenced this issue Apr 9, 2024
Today's Python packaging specification is not clear about making
binaries executable on installation from data/scripts/ directory:
https://packaging.python.org/en/latest/specifications/binary-distribution-format/

> In wheel, scripts are packaged in
  {distribution}-{version}.data/scripts/. If the first line of a file in
  scripts/ starts with exactly b'#!python', rewrite to point to the
  correct interpreter. Unix installers may need to add the +x bit to these
  files if the archive was created on Windows.

ZipFile in turn, doesn't preserve file permissions in Python:
python/cpython#59999

This leads to situation when freshly installed binaries can't be
executed.

Fixes: #66
Signed-off-by: Stanislav Levin <slev@altlinux.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant