|
30 | 30 | @rem If we have Python in externals, use that one |
31 | 31 | @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 |
32 | 32 |
|
| 33 | +@rem If HOST_PYTHON is recent enough, use that |
| 34 | +@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 |
| 35 | + |
33 | 36 | @rem If py.exe finds a recent enough version, use that one |
34 | 37 | @py -3.6 -V >nul 2>&1 && (set PYTHON=py -3.6) && (set _Py_Python_Source=found with py.exe) && goto :found |
35 | 38 |
|
36 | 39 | @if NOT exist "%_Py_EXTERNALS_DIR%" mkdir "%_Py_EXTERNALS_DIR%" |
37 | 40 | @set _Py_NUGET=%NUGET% |
38 | 41 | @set _Py_NUGET_URL=%NUGET_URL% |
39 | | -@if "%_Py_NUGET%"=="" (set _Py_NUGET=%EXTERNALS_DIR%\nuget.exe) |
| 42 | +@set _Py_HOST_PYTHON=%HOST_PYTHON% |
| 43 | +@if "%_Py_HOST_PYTHON%"=="" set _Py_HOST_PYTHON=py |
| 44 | +@if "%_Py_NUGET%"=="" (set _Py_NUGET=%_Py_EXTERNALS_DIR%\nuget.exe) |
40 | 45 | @if "%_Py_NUGET_URL%"=="" (set _Py_NUGET_URL=https://aka.ms/nugetclidl) |
41 | 46 | @if NOT exist "%_Py_NUGET%" ( |
42 | 47 | @echo Downloading nuget... |
43 | 48 | @rem NB: Must use single quotes around NUGET here, NOT double! |
44 | 49 | @rem Otherwise, a space in the path would break things |
45 | 50 | @rem If it fails, retry with any available copy of Python |
46 | | - @powershell.exe -Command Invoke-WebRequest %_Py_NUGET_URL% -OutFile '%_Py_NUGET%' || @py -c "%~dp0\urlretrieve.py" "%_Py_NUGET_URL%" "%_Py_NUGET%" |
| 51 | + @powershell.exe -Command Invoke-WebRequest %_Py_NUGET_URL% -OutFile '%_Py_NUGET%' |
| 52 | + @if errorlevel 1 ( |
| 53 | + @%_Py_HOST_PYTHON% "%~dp0\urlretrieve.py" "%_Py_NUGET_URL%" "%_Py_NUGET%" |
| 54 | + ) |
47 | 55 | ) |
48 | 56 | @echo Installing Python via nuget... |
49 | 57 | @"%_Py_NUGET%" install pythonx86 -ExcludeVersion -OutputDirectory "%_Py_EXTERNALS_DIR%" |
50 | 58 | @rem Quote it here; it's not quoted later because "py -3.6" wouldn't work |
51 | 59 | @if not errorlevel 1 (set PYTHON="%_Py_EXTERNALS_DIR%\pythonx86\tools\python.exe") & (set _Py_Python_Source=found on nuget.org) & goto :found |
52 | 60 |
|
53 | 61 |
|
| 62 | +@set _Py_Python_Source= |
| 63 | +@set _Py_EXTERNALS_DIR= |
| 64 | +@set _Py_NUGET= |
| 65 | +@set _Py_NUGET_URL= |
| 66 | +@set _Py_HOST_PYTHON= |
54 | 67 | @exit /b 1 |
55 | 68 |
|
56 | 69 | :found |
57 | 70 | @echo Using %PYTHON% (%_Py_Python_Source%) |
58 | 71 | @set _Py_Python_Source= |
| 72 | +@set _Py_EXTERNALS_DIR= |
| 73 | +@set _Py_NUGET= |
| 74 | +@set _Py_NUGET_URL= |
| 75 | +@set _Py_HOST_PYTHON= |
0 commit comments