mirror of https://github.com/python/cpython
gh-103088: Sanitize venv paths when using MSYS or Cygwin Bash (GH-103325)
This commit is contained in:
parent
b57105ae33
commit
ebc8103427
|
@ -38,8 +38,15 @@ deactivate () {
|
||||||
# unset irrelevant variables
|
# unset irrelevant variables
|
||||||
deactivate nondestructive
|
deactivate nondestructive
|
||||||
|
|
||||||
VIRTUAL_ENV="__VENV_DIR__"
|
# on Windows, a path can contain colons and backslashes and has to be converted:
|
||||||
export VIRTUAL_ENV
|
if [ "$OSTYPE" = "cygwin" ] || [ "$OSTYPE" = "msys" ] ; then
|
||||||
|
# transform D:\path\to\venv to /d/path/to/venv on MSYS
|
||||||
|
# and to /cygdrive/d/path/to/venv on Cygwin
|
||||||
|
export VIRTUAL_ENV=$(cygpath "__VENV_DIR__")
|
||||||
|
else
|
||||||
|
# use the path as-is
|
||||||
|
export VIRTUAL_ENV="__VENV_DIR__"
|
||||||
|
fi
|
||||||
|
|
||||||
_OLD_VIRTUAL_PATH="$PATH"
|
_OLD_VIRTUAL_PATH="$PATH"
|
||||||
PATH="$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH"
|
PATH="$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH"
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fixes venvs not working in bash on Windows across different disks
|
|
@ -42,7 +42,7 @@
|
||||||
@if NOT "%HOST_PYTHON%"=="" @%HOST_PYTHON% -Ec "import sys; assert sys.version_info[:2] >= (3, 9)" >nul 2>nul && (set PYTHON="%HOST_PYTHON%") && (set _Py_Python_Source=found as HOST_PYTHON) && goto :found
|
@if NOT "%HOST_PYTHON%"=="" @%HOST_PYTHON% -Ec "import sys; assert sys.version_info[:2] >= (3, 9)" >nul 2>nul && (set PYTHON="%HOST_PYTHON%") && (set _Py_Python_Source=found as HOST_PYTHON) && goto :found
|
||||||
|
|
||||||
@rem If py.exe finds a recent enough version, use that one
|
@rem If py.exe finds a recent enough version, use that one
|
||||||
@for %%p in (3.10 3.9) do @py -%%p -EV >nul 2>&1 && (set PYTHON=py -%%p) && (set _Py_Python_Source=found %%p with py.exe) && goto :found
|
@for %%p in (3.11 3.10 3.9) do @py -%%p -EV >nul 2>&1 && (set PYTHON=py -%%p) && (set _Py_Python_Source=found %%p with py.exe) && goto :found
|
||||||
|
|
||||||
@if NOT exist "%_Py_EXTERNALS_DIR%" mkdir "%_Py_EXTERNALS_DIR%"
|
@if NOT exist "%_Py_EXTERNALS_DIR%" mkdir "%_Py_EXTERNALS_DIR%"
|
||||||
@set _Py_NUGET=%NUGET%
|
@set _Py_NUGET=%NUGET%
|
||||||
|
|
Loading…
Reference in New Issue