diff --git a/.github/appveyor.yml b/.github/appveyor.yml index 06b9b2f87ba..deb0e309a9d 100644 --- a/.github/appveyor.yml +++ b/.github/appveyor.yml @@ -9,6 +9,8 @@ build_script: - cmd: PCbuild\build.bat -e test_script: - cmd: PCbuild\rt.bat -q -uall -u-cpu -rwW --slowest --timeout=1200 --fail-env-changed -j0 +environment: + HOST_PYTHON: C:\Python36\python.exe # Only trigger AppVeyor if actual code or its configuration changes only_commits: diff --git a/PCbuild/find_python.bat b/PCbuild/find_python.bat index 82358c864eb..ba3a0f5a10d 100644 --- a/PCbuild/find_python.bat +++ b/PCbuild/find_python.bat @@ -30,20 +30,28 @@ @rem If we have Python in externals, use that one @if exist "%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe" (set PYTHON="%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe") & (set _Py_Python_Source=found in externals directory) & goto :found +@rem If HOST_PYTHON is recent enough, use that +@if NOT "%HOST_PYTHON%"=="" @%HOST_PYTHON% -c "import sys; assert sys.version_info[:2] >= (3, 6)" >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 @py -3.6 -V >nul 2>&1 && (set PYTHON=py -3.6) && (set _Py_Python_Source=found with py.exe) && goto :found @if NOT exist "%_Py_EXTERNALS_DIR%" mkdir "%_Py_EXTERNALS_DIR%" @set _Py_NUGET=%NUGET% @set _Py_NUGET_URL=%NUGET_URL% -@if "%_Py_NUGET%"=="" (set _Py_NUGET=%EXTERNALS_DIR%\nuget.exe) +@set _Py_HOST_PYTHON=%HOST_PYTHON% +@if "%_Py_HOST_PYTHON%"=="" set _Py_HOST_PYTHON=py +@if "%_Py_NUGET%"=="" (set _Py_NUGET=%_Py_EXTERNALS_DIR%\nuget.exe) @if "%_Py_NUGET_URL%"=="" (set _Py_NUGET_URL=https://aka.ms/nugetclidl) @if NOT exist "%_Py_NUGET%" ( @echo Downloading nuget... @rem NB: Must use single quotes around NUGET here, NOT double! @rem Otherwise, a space in the path would break things @rem If it fails, retry with any available copy of Python - @powershell.exe -Command Invoke-WebRequest %_Py_NUGET_URL% -OutFile '%_Py_NUGET%' || @py -c "%~dp0\urlretrieve.py" "%_Py_NUGET_URL%" "%_Py_NUGET%" + @powershell.exe -Command Invoke-WebRequest %_Py_NUGET_URL% -OutFile '%_Py_NUGET%' + @if errorlevel 1 ( + @%_Py_HOST_PYTHON% "%~dp0\urlretrieve.py" "%_Py_NUGET_URL%" "%_Py_NUGET%" + ) ) @echo Installing Python via nuget... @"%_Py_NUGET%" install pythonx86 -ExcludeVersion -OutputDirectory "%_Py_EXTERNALS_DIR%" @@ -51,8 +59,17 @@ @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_Python_Source= +@set _Py_EXTERNALS_DIR= +@set _Py_NUGET= +@set _Py_NUGET_URL= +@set _Py_HOST_PYTHON= @exit /b 1 :found @echo Using %PYTHON% (%_Py_Python_Source%) @set _Py_Python_Source= +@set _Py_EXTERNALS_DIR= +@set _Py_NUGET= +@set _Py_NUGET_URL= +@set _Py_HOST_PYTHON=