uv
b296c04a - Add CMD support (#1523)

Commit
1 year ago
Add CMD support (#1523) ## 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 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.
Author
Parents
Loading