-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support paths with spaces in launchers #2076
Labels
Comments
I can grab this one later if no one gets to it. |
Nice, thank you. |
charliermarsh
added a commit
that referenced
this issue
Feb 29, 2024
## Summary This is based on Pradyun's installer branch (https://github.com/pradyunsg/installer/blob/d01624e5f20963f046e67d58f5319e21a07aa03e/src/installer/scripts.py#L54), which is itself based on pip (https://github.com/pypa/pip/blob/0ad4c94be74cc24874c6feb5bb3c2152c398a18e/src/pip/_vendor/distlib/scripts.py#L136). The gist of it is: on Posix platforms, if a path contains a space (or is too long), we wrap the shebang in a `/bin/sh` invocation. Closes #2076. ## Test Plan ``` ❯ cargo run venv "foo" Finished dev [unoptimized + debuginfo] target(s) in 0.14s Running `target/debug/uv venv foo` Using Python 3.12.0 interpreter at: /Users/crmarsh/.local/share/rtx/installs/python/3.12.0/bin/python3 Creating virtualenv at: foo Activate with: source foo/bin/activate ❯ source "foo bar/bin/activate" ❯ which black black not found ❯ cargo run pip install black Resolved 6 packages in 177ms Installed 6 packages in 17ms + black==24.2.0 + click==8.1.7 + mypy-extensions==1.0.0 + packaging==23.2 + pathspec==0.12.1 + platformdirs==4.2.0 ❯ which black /Users/crmarsh/workspace/uv/foo bar/bin/black ❯ black Usage: black [OPTIONS] SRC ... One of 'SRC' or 'code' is required. ❯ cat "foo bar/bin/black" #!/bin/sh '''exec' '/Users/crmarsh/workspace/uv/foo bar/bin/python' "$0" "$@" ' ''' # -*- coding: utf-8 -*- import re import sys from black import patched_main if __name__ == "__main__": sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0]) sys.exit(patched_main()) ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See #1997 (comment)
When creating a new launcher, we insert the path to the python interpreter as shebang. This fails if there is a space in the path:
The system tries to execute this as
/Users/ferris/my
with argumentspython
andproject/venv/bin/python
. We should instead use the same workaround as pip when there's a space in the path:pip reference code: https://github.com/pypa/pip/blob/0ad4c94be74cc24874c6feb5bb3c2152c398a18e/src/pip/_vendor/distlib/scripts.py#L136-L165
The text was updated successfully, but these errors were encountered: