mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-03 18:38:21 +00:00
![]() ## 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 https://github.com/astral-sh/uv/issues/1471 ## Test Plan |
||
---|---|---|
.. | ||
uv-trampoline-aarch64-console.exe | ||
uv-trampoline-aarch64-gui.exe | ||
uv-trampoline-x86_64-console.exe | ||
uv-trampoline-x86_64-gui.exe |