From c47db3a85460fade351c1207474e6f09d063ab8c Mon Sep 17 00:00:00 2001 From: Don Olmstead Date: Tue, 7 Oct 2025 14:28:19 -0700 Subject: [PATCH] refactor(): use choco for python Install python, 2 and 3, through chocolatey. --- WebKitDev/Functions/Install-Python.ps1 | 40 +++++++++----------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/WebKitDev/Functions/Install-Python.ps1 b/WebKitDev/Functions/Install-Python.ps1 index cf7cdf9..2c342b8 100644 --- a/WebKitDev/Functions/Install-Python.ps1 +++ b/WebKitDev/Functions/Install-Python.ps1 @@ -35,40 +35,28 @@ function Install-Python { ) $major,$minor,$patch = $version.split('.'); + $packageParameters = @(); + + if ($installationPath) { + $packageParameters += ('/InstallDir:"{0}"' -f $installationPath) + } if ($major -ne '2') { - $pythonUrl = ('https://www.python.org/ftp/python/{0}/python-{0}-amd64.exe' -f $version); + $name = ('python{0}{1}' -f $major,$minor); $getPip = 'https://bootstrap.pypa.io/get-pip.py'; - - $options = @( - '/quiet', - 'InstallAllUsers=1', - 'PrependPath=1', - 'AssociateFiles=0' - ); - - if ($installationPath) { - $options += ('TargetDir="{0}"' -f $installationPath) - } - - Install-FromExe -Name 'python' -url $pythonUrl -Options $options; } else { - $pythonUrl = ('https://www.python.org/ftp/python/{0}/python-{0}.amd64.msi' -f $version); + $name = 'python2' $getPip = 'https://bootstrap.pypa.io/pip/2.7/get-pip.py'; - - $options = @( - 'ALLUSERS=1', - 'ADDLOCAL=DefaultFeature,Extensions,TclTk,Tools,PrependPath' - ); - - if ($installationPath) { - $options += ('TARGETDIR="{0}"' -f $installationPath); - } - - Install-FromMsi -Name 'python' -url $pythonUrl -Options $options; } + # Install Python + Install-FromChoco ` + -Name $name ` + -Version $version ` + -VerifyExe 'python' ` + -PackageParameters $packageParameters; + # Install PIP $pipInstall = ('pip=={0}' -f $pipVersion); Write-Information -MessageData ('Installing {0} from {1} ...' -f ($pipInstall,$getPip)) -InformationAction Continue;