mirror of https://github.com/astral-sh/uv
## Summary When executing `.venv\Scripts\activate` in `cmd`, the script uses the local codepage for execution. This causes issues when the file path contains non-ASCII characters, resulting in corrupted environment variables such as `VIRTUAL_ENV`. See #11828. Code used to fix the issue was adapted from https://github.com/python/cpython/blob/3.13/Lib/venv/scripts/nt/activate.bat#L3-L9. ## Test Plan Before:  After:  (`chcp` command cleared the history lol)
This commit is contained in:
parent
ef95d79bfa
commit
4d9c861506
|
|
@ -19,6 +19,14 @@
|
|||
@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.
|
||||
|
||||
@REM This file is UTF-8 encoded, so we need to update the current code page while executing it
|
||||
@for /f "tokens=2 delims=:." %%a in ('"%SystemRoot%\System32\chcp.com"') do (
|
||||
@set _OLD_CODEPAGE=%%a
|
||||
)
|
||||
@if defined _OLD_CODEPAGE (
|
||||
@"%SystemRoot%\System32\chcp.com" 65001 > nul
|
||||
)
|
||||
|
||||
@for %%i in ("{{ VIRTUAL_ENV_DIR }}") do @set "VIRTUAL_ENV=%%~fi"
|
||||
|
||||
@set "VIRTUAL_ENV_PROMPT={{ VIRTUAL_PROMPT }}"
|
||||
|
|
@ -57,3 +65,9 @@
|
|||
:ENDIFVPATH2
|
||||
|
||||
@set "PATH=%VIRTUAL_ENV%\{{ BIN_NAME }};%PATH%"
|
||||
|
||||
:END
|
||||
@if defined _OLD_CODEPAGE (
|
||||
@"%SystemRoot%\System32\chcp.com" %_OLD_CODEPAGE% > nul
|
||||
@set _OLD_CODEPAGE=
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue