-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup_pip.ps1
29 lines (29 loc) · 1.37 KB
/
setup_pip.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$Version = $env:PYTHON_VERSION
$PythonPath = $env:SETUP_PYTHON_PATH
$Semver = $Version.Split('.')
Write-Output "Setting up pip for python $Version in path $PythonPath"
if (!($Semver[0] -like 'pypy*') -and ([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 manual 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"
}