-
Notifications
You must be signed in to change notification settings - Fork 878
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Sumamry This PR adds the `activation.bat`, `deactivation.bat` and `pyenv.bat` files to add support for using uv from CMD. This PR further fixes an issue with our trampoline implementation where calling an executable like `black` failed: ``` (venv) C:\Users\Micha\astral\test>where black C:\Users\Micha\astral\test\.venv\Scripts\black.exe (venv) C:\Users\Micha\astral\test>black C:\Users\Micha\AppData\Local\Programs\Python\Python312\python.exe: can't open file 'C:\\Users\\Micha\\astral\\test\\black': [Errno 2] No such file or directory ``` The issue was that CMD doesn't extend `black` to its full path before passing it to the trampoline and our trampoline generated the command `<python> black` instead of `<python> .venv/Scripts/black`, and Python can't find `black` in the project directory. This PR fixes this by using the full executable name (that we already parsed out to discover the Python version). This adds one complication, we need to preserve the arguments without repeating the executable name that is the first argument. One option is to use [`CommandLineToArgvW`](https://learn.microsoft.com/de-de/windows/win32/api/shellapi/nf-shellapi-commandlinetoargvw) and then serialize the arguments 1.. to a string again. I decided against that. Win32 API calls are easy to get wrong. That's why I implemented the parsing rules specified in [`CommandLineToArgvW`](https://learn.microsoft.com/de-de/windows/win32/api/shellapi/nf-shellapi-commandlinetoargvw) to skip the first argument. Fixes #1471 ## Test Plan https://github.com/astral-sh/uv/assets/1203881/bdb537b6-97c8-4f7e-bb4a-3a614eb5e0f6 Powershell continues to work https://github.com/astral-sh/uv/assets/1203881/6c806477-a7c6-4047-9ffc-5ed91c6f1c84 I haven't been able to test the aarch binaries.
- Loading branch information
1 parent
ea62ae4
commit b296c04
Showing
10 changed files
with
257 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.bat text eol=crlf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
@REM Copyright (c) 2020-202x The virtualenv developers | ||
@REM | ||
@REM Permission is hereby granted, free of charge, to any person obtaining | ||
@REM a copy of this software and associated documentation files (the | ||
@REM "Software"), to deal in the Software without restriction, including | ||
@REM without limitation the rights to use, copy, modify, merge, publish, | ||
@REM distribute, sublicense, and/or sell copies of the Software, and to | ||
@REM permit persons to whom the Software is furnished to do so, subject to | ||
@REM the following conditions: | ||
@REM | ||
@REM The above copyright notice and this permission notice shall be | ||
@REM included in all copies or substantial portions of the Software. | ||
@REM | ||
@REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
@REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
@REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
@REM NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
@REM LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
@REM OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
@REM WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
@set "VIRTUAL_ENV={{ VIRTUAL_ENV_DIR }}" | ||
|
||
@set "VIRTUAL_ENV_PROMPT=venv" | ||
@if NOT DEFINED VIRTUAL_ENV_PROMPT ( | ||
@for %%d in ("%VIRTUAL_ENV%") do @set "VIRTUAL_ENV_PROMPT=%%~nxd" | ||
) | ||
|
||
@if defined _OLD_VIRTUAL_PROMPT ( | ||
@set "PROMPT=%_OLD_VIRTUAL_PROMPT%" | ||
) else ( | ||
@if not defined PROMPT ( | ||
@set "PROMPT=$P$G" | ||
) | ||
@if not defined VIRTUAL_ENV_DISABLE_PROMPT ( | ||
@set "_OLD_VIRTUAL_PROMPT=%PROMPT%" | ||
) | ||
) | ||
@if not defined VIRTUAL_ENV_DISABLE_PROMPT ( | ||
@set "PROMPT=(%VIRTUAL_ENV_PROMPT%) %PROMPT%" | ||
) | ||
|
||
@REM Don't use () to avoid problems with them in %PATH% | ||
@if defined _OLD_VIRTUAL_PYTHONHOME @goto ENDIFVHOME | ||
@set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%" | ||
:ENDIFVHOME | ||
|
||
@set PYTHONHOME= | ||
|
||
@REM if defined _OLD_VIRTUAL_PATH ( | ||
@if not defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH1 | ||
@set "PATH=%_OLD_VIRTUAL_PATH%" | ||
:ENDIFVPATH1 | ||
@REM ) else ( | ||
@if defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH2 | ||
@set "_OLD_VIRTUAL_PATH=%PATH%" | ||
:ENDIFVPATH2 | ||
|
||
@set "PATH=%VIRTUAL_ENV%\{{ BIN_NAME }};%PATH%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@REM Copyright (c) 2020-202x The virtualenv developers | ||
@REM | ||
@REM Permission is hereby granted, free of charge, to any person obtaining | ||
@REM a copy of this software and associated documentation files (the | ||
@REM "Software"), to deal in the Software without restriction, including | ||
@REM without limitation the rights to use, copy, modify, merge, publish, | ||
@REM distribute, sublicense, and/or sell copies of the Software, and to | ||
@REM permit persons to whom the Software is furnished to do so, subject to | ||
@REM the following conditions: | ||
@REM | ||
@REM The above copyright notice and this permission notice shall be | ||
@REM included in all copies or substantial portions of the Software. | ||
@REM | ||
@REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
@REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
@REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
@REM NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
@REM LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
@REM OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
@REM WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
@set VIRTUAL_ENV= | ||
@set VIRTUAL_ENV_PROMPT= | ||
|
||
@REM Don't use () to avoid problems with them in %PATH% | ||
@if not defined _OLD_VIRTUAL_PROMPT @goto ENDIFVPROMPT | ||
@set "PROMPT=%_OLD_VIRTUAL_PROMPT%" | ||
@set _OLD_VIRTUAL_PROMPT= | ||
:ENDIFVPROMPT | ||
|
||
@if not defined _OLD_VIRTUAL_PYTHONHOME @goto ENDIFVHOME | ||
@set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%" | ||
@set _OLD_VIRTUAL_PYTHONHOME= | ||
:ENDIFVHOME | ||
|
||
@if not defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH | ||
@set "PATH=%_OLD_VIRTUAL_PATH%" | ||
@set _OLD_VIRTUAL_PATH= | ||
:ENDIFVPATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@REM Copyright (c) 2020-202x The virtualenv developers | ||
@REM | ||
@REM Permission is hereby granted, free of charge, to any person obtaining | ||
@REM a copy of this software and associated documentation files (the | ||
@REM "Software"), to deal in the Software without restriction, including | ||
@REM without limitation the rights to use, copy, modify, merge, publish, | ||
@REM distribute, sublicense, and/or sell copies of the Software, and to | ||
@REM permit persons to whom the Software is furnished to do so, subject to | ||
@REM the following conditions: | ||
@REM | ||
@REM The above copyright notice and this permission notice shall be | ||
@REM included in all copies or substantial portions of the Software. | ||
@REM | ||
@REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
@REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
@REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
@REM NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
@REM LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
@REM OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
@REM WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
python.exe -m pydoc %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+2 KB
(110%)
crates/uv-trampoline/trampolines/uv-trampoline-aarch64-console.exe
Binary file not shown.
Binary file modified
BIN
+2 KB
(110%)
crates/uv-trampoline/trampolines/uv-trampoline-aarch64-gui.exe
Binary file not shown.
Binary file modified
BIN
+1 KB
(110%)
crates/uv-trampoline/trampolines/uv-trampoline-x86_64-console.exe
Binary file not shown.
Binary file not shown.