diff options
author | Steve Dower <steve.dower@python.org> | 2021-12-18 13:05:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-18 13:05:45 (GMT) |
commit | 6fc91daf730c60b08b4b32cdce28ff26505a0622 (patch) | |
tree | 56de731264b748a79c5c698d4f944a7858ff3d0b /PCbuild/find_python.bat | |
parent | 6214caafbe66e34e84c1809abf0b7aab6791956b (diff) | |
download | cpython-6fc91daf730c60b08b4b32cdce28ff26505a0622.zip cpython-6fc91daf730c60b08b4b32cdce28ff26505a0622.tar.gz cpython-6fc91daf730c60b08b4b32cdce28ff26505a0622.tar.bz2 |
bpo-46088: Automatically detect or install bootstrap Python runtime when building from Visual Studio (GH-30143)
Diffstat (limited to 'PCbuild/find_python.bat')
-rw-r--r-- | PCbuild/find_python.bat | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/PCbuild/find_python.bat b/PCbuild/find_python.bat index a9bbe5a..fc1049c 100644 --- a/PCbuild/find_python.bat +++ b/PCbuild/find_python.bat @@ -6,6 +6,11 @@ @rem changing any other persistent state. @rem +@set _Py_D=%~dp0 + +@rem First argument -q means only show the command in output +@if '%1' EQU '-q' (shift && set _Py_Quiet=1) + @rem No arguments provided means do full search @if '%1' EQU '' goto :begin_search @@ -28,7 +33,7 @@ @if NOT "%VIRTUAL_ENV%"=="" (set PYTHON="%VIRTUAL_ENV%\Scripts\python.exe") & (set _Py_Python_Source=found in virtual env) & goto :found @set _Py_EXTERNALS_DIR=%EXTERNALS_DIR% -@if "%_Py_EXTERNALS_DIR%"=="" (set _Py_EXTERNALS_DIR=%~dp0\..\externals) +@if "%_Py_EXTERNALS_DIR%"=="" (set _Py_EXTERNALS_DIR=%_Py_D%\..\externals) @rem If we have Python in externals, use that one @if exist "%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe" ("%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe" -Ec "import sys; assert sys.version_info[:2] >= (3, 8)" >nul 2>nul) && (set PYTHON="%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe") && (set _Py_Python_Source=found in externals directory) && goto :found || rmdir /Q /S "%_Py_EXTERNALS_DIR%\pythonx86" @@ -53,15 +58,18 @@ @rem If it fails, retry with any available copy of Python @powershell.exe -Command Invoke-WebRequest %_Py_NUGET_URL% -OutFile '%_Py_NUGET%' @if errorlevel 1 ( - @%_Py_HOST_PYTHON% -E "%~dp0\urlretrieve.py" "%_Py_NUGET_URL%" "%_Py_NUGET%" + @%_Py_HOST_PYTHON% -E "%_Py_D%\urlretrieve.py" "%_Py_NUGET_URL%" "%_Py_NUGET%" ) ) -@echo Installing Python via nuget... + +@if not "%_Py_Quiet%"=="1" @echo Installing Python via nuget... @"%_Py_NUGET%" install pythonx86 -ExcludeVersion -OutputDirectory "%_Py_EXTERNALS_DIR%" @rem Quote it here; it's not quoted later because "py -x.y" wouldn't work @if not errorlevel 1 (set PYTHON="%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe") & (set _Py_Python_Source=found on nuget.org) & goto :found +@set _Py_D= +@set _Py_Quiet= @set _Py_Python_Source= @set _Py_EXTERNALS_DIR= @set _Py_NUGET= @@ -70,7 +78,10 @@ @exit /b 1 :found -@echo Using %PYTHON% (%_Py_Python_Source%) +@if "%_Py_Quiet%"=="1" (@echo %PYTHON%) else @echo Using %PYTHON% (%_Py_Python_Source%) + +@set _Py_D= +@set _Py_Quiet= @set _Py_Python_Source= @set _Py_EXTERNALS_DIR= @set _Py_NUGET= |