diff --git a/Misc/NEWS.d/next/Build/2021-12-16-14-18-07.bpo-46088.8UUuAd.rst b/Misc/NEWS.d/next/Build/2021-12-16-14-18-07.bpo-46088.8UUuAd.rst new file mode 100644 index 00000000000..408ed53111f --- /dev/null +++ b/Misc/NEWS.d/next/Build/2021-12-16-14-18-07.bpo-46088.8UUuAd.rst @@ -0,0 +1,2 @@ +Automatically detect or install bootstrap Python runtime when building from +Visual Studio. diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj index 11a6a87daf9..42798bf8113 100644 --- a/PCbuild/_freeze_module.vcxproj +++ b/PCbuild/_freeze_module.vcxproj @@ -432,7 +432,10 @@ - + = (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= diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props index bbcabb5cdb4..3465adec65b 100644 --- a/PCbuild/pyproject.props +++ b/PCbuild/pyproject.props @@ -225,4 +225,17 @@ public override bool Execute() { + + + + + + + @(_CmdExeLines) + + + + diff --git a/PCbuild/regen.targets b/PCbuild/regen.targets index c0bde1ec6ba..a49d97190ce 100644 --- a/PCbuild/regen.targets +++ b/PCbuild/regen.targets @@ -1,11 +1,5 @@ - - - $(PYTHON) - - - <_PegenSources Include="$(PySourcePath)Grammar\python.gram;$(PySourcePath)Grammar\Tokens" /> <_PegenOutputs Include="$(PySourcePath)Parser\parser.c" /> @@ -44,20 +38,26 @@ AlwaysCreate="False" /> - + - + - + @@ -65,14 +65,18 @@ WorkingDirectory="$(PySourcePath)" /> - + - +