Update installation output to better match .command starters

This commit is contained in:
CorpNewt
2025-03-05 17:24:49 -06:00
committed by GitHub
parent 52f48e448e
commit ef0960c783
+23 -13
View File
@@ -27,7 +27,7 @@ REM --install-python and if so, we'll just install
REM Can optionally take a version number as the
REM second arg - i.e. --install-python 3.13.1
set "just_installing=FALSE"
set "release="
set "user_provided="
REM Get the system32 (or equivalent) path
call :getsyspath "syspath"
@@ -64,7 +64,7 @@ if "!syspath!" == "" (
if "%~1" == "--install-python" (
set "just_installing=TRUE"
set "release=%~2"
set "user_provided=%~2"
goto installpy
)
@@ -124,7 +124,8 @@ if !tried! lss 1 (
echo.
REM Couldn't install for whatever reason - give the error message
echo Python is not installed or not found in your PATH var.
echo Please install it from https://www.python.org/downloads/windows/
echo Please go to https://www.python.org/downloads/windows/ to
echo download and install the latest version, then try again.
echo.
echo Make sure you check the box labeled:
echo.
@@ -228,21 +229,21 @@ echo ### ###
echo # Installing Python #
echo ### ###
echo.
set "release=!user_provided!"
if "!release!" == "" (
REM No explicit release set - get the latest from python.org
echo Gathering info from https://www.python.org/downloads/windows/...
echo Gathering latest version...
powershell -command "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12;(new-object System.Net.WebClient).DownloadFile('https://www.python.org/downloads/windows/','%TEMP%\pyurl.txt')"
REM Extract it if it's gzip compressed
powershell -command "$infile='%TEMP%\pyurl.txt';$outfile='%TEMP%\pyurl.temp';try{$input=New-Object System.IO.FileStream $infile,([IO.FileMode]::Open),([IO.FileAccess]::Read),([IO.FileShare]::Read);$output=New-Object System.IO.FileStream $outfile,([IO.FileMode]::Create),([IO.FileAccess]::Write),([IO.FileShare]::None);$gzipStream=New-Object System.IO.Compression.GzipStream $input,([IO.Compression.CompressionMode]::Decompress);$buffer=New-Object byte[](1024);while($true){$read=$gzipstream.Read($buffer,0,1024);if($read -le 0){break};$output.Write($buffer,0,$read)};$gzipStream.Close();$output.Close();$input.Close();Move-Item -Path $outfile -Destination $infile -Force}catch{}"
if not exist "%TEMP%\pyurl.txt" (
if /i "!just_installing!" == "TRUE" (
echo Failed to get info
echo - Failed to get info
exit /b 1
) else (
goto checkpy
)
)
echo Parsing for latest...
pushd "%TEMP%"
:: Version detection code slimmed by LussacZheng (https://github.com/corpnewt/gibMacOS/issues/20)
for /f "tokens=9 delims=< " %%x in ('findstr /i /c:"Latest Python !targetpy! Release" pyurl.txt') do ( set "release=%%x" )
@@ -251,7 +252,7 @@ if "!release!" == "" (
del "%TEMP%\pyurl.txt"
if "!release!" == "" (
if /i "!just_installing!" == "TRUE" (
echo Failed to get python version
echo - Failed to get python version
exit /b 1
) else (
goto checkpy
@@ -267,7 +268,12 @@ if "!release!" == "" (
)
)
)
echo Found Python !release! - Downloading...
if "!user_provided!" == "" (
echo Located Version: !release!
) else (
echo User-Provided Version: !release!
)
echo Building download url...
REM At this point - we should have the version number.
REM We can build the url like so: "https://www.python.org/ftp/python/[version]/python-[version]-amd64.exe"
set "url=https://www.python.org/ftp/python/!release!/python-!release!-amd64.exe"
@@ -276,30 +282,34 @@ if "!targetpy!" == "2" (
set "url=https://www.python.org/ftp/python/!release!/python-!release!.amd64.msi"
set "pytype=msi"
)
echo - !url!
echo Downloading...
REM Now we download it with our slick powershell command
powershell -command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (new-object System.Net.WebClient).DownloadFile('!url!','%TEMP%\pyinstall.!pytype!')"
REM If it doesn't exist - we bail
if not exist "%TEMP%\pyinstall.!pytype!" (
if /i "!just_installing!" == "TRUE" (
echo Failed to download installer
echo - Failed to download python installer
exit /b 1
) else (
goto checkpy
)
)
REM It should exist at this point - let's run it to install silently
echo Installing...
echo Running python !pytype! installer...
pushd "%TEMP%"
if /i "!pytype!" == "exe" (
echo pyinstall.exe /quiet PrependPath=1 Include_test=0 Shortcuts=0 Include_launcher=0
echo - pyinstall.exe /quiet PrependPath=1 Include_test=0 Shortcuts=0 Include_launcher=0
pyinstall.exe /quiet PrependPath=1 Include_test=0 Shortcuts=0 Include_launcher=0
) else (
set "foldername=!release:.=!"
echo msiexec /i pyinstall.msi /qb ADDLOCAL=ALL TARGETDIR="%LocalAppData%\Programs\Python\Python!foldername:~0,2!"
echo - msiexec /i pyinstall.msi /qb ADDLOCAL=ALL TARGETDIR="%LocalAppData%\Programs\Python\Python!foldername:~0,2!"
msiexec /i pyinstall.msi /qb ADDLOCAL=ALL TARGETDIR="%LocalAppData%\Programs\Python\Python!foldername:~0,2!"
)
popd
echo Installer finished with %ERRORLEVEL% status.
set "py_error=!errorlevel!"
echo Installer finished with status: !py_error!
echo Cleaning up...
REM Now we should be able to delete the installer and check for py again
del "%TEMP%\pyinstall.!pytype!"
REM If it worked, then we should have python in our PATH