Skip to content

Commit

Permalink
Update setup pip script
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoH2O1999 committed Jan 25, 2023
1 parent 82b02bc commit 8601ed5
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions setup_pip.ps1
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
$Version = $env:PYTHON_VERSION
$PythonPath = $env:SETUP_PYTHON_PATH
$Semver = $Version.Split('.')
$pip = 0
Write-Output "Setting up pip for python $Version in path $PythonPath"
if ([int]$Semver[0] -eq 3 -and [int]$Semver[1] -ge 4) {
Write-Output "Using ensurepip..."
Invoke-Expression -Command "$PythonPath -m ensurepip"
if ([int]$Semver[1] -gt 4) {
Write-Output "Updating pip..."
Invoke-Expression -Command "$PythonPath -m pip install --upgrade pip"
}
$pip = 1
} elseif ([int]$Semver[1] -ge 3) {
Write-Output "Using get_pip.py..."
$GetPipFile = New-TemporaryFile
Invoke-WebRequest -Uri 'https://bootstrap.pypa.io/pip/3.3/get-pip.py' -OutFile $GetPipFile
Invoke-Expression -Command "$PythonPath $GetPipFile"
Remove-Item $GetPipFile
$pip = 1
}
if ($pip) {
if ([int]$Semver[0] -eq 3 -and [int]$Semver[1] -lt 5) {
if ([int]$Semver[0] -eq 3 -and [int]$Semver[1] -lt 5) {
if ([int]$Semver[1] -gt 2) {
Write-Output "Using get_pip.py..."
$VersionNumber = $Semver[0]
$Major = $Semver[1]
$GetPipFile = New-TemporaryFile
Invoke-WebRequest -Uri "https://bootstrap.pypa.io/pip/$VersionNumber.$Major/get-pip.py" -OutFile $GetPipFile
Invoke-Expression -Command "$PythonPath $GetPipFile"
Write-Output "Installing typing for old Python versions..."
Invoke-Expression -Command "$PythonPath -m pip install typing"
Remove-Item $GetPipFile
if ([int]$Semver[1] -eq 4) {
Invoke-Expression -Command "$PythonPath -m pip install --upgrade wheel setuptools"
}
} else {
Write-Output "Pip is not available for version $Version"
Write-Output "Proceed with manualk installation at own risk"
}
} else {
Write-Output "Using ensurepip..."
Invoke-Expression -Command "$PythonPath -m ensurepip"
Invoke-Expression -Command "$PythonPath -m pip install --upgrade pip"
Write-Output "Installing wheel and setuptools..."
Invoke-Expression -Command "$PythonPath -m pip install --upgrade wheel setuptools"
}

0 comments on commit 8601ed5

Please sign in to comment.