[Windows] Slight rework of the PyPy installation (#4392)
This commit is contained in:
@@ -3,22 +3,6 @@
|
|||||||
## Team: CI-Build
|
## Team: CI-Build
|
||||||
## Desc: Install PyPy
|
## Desc: Install PyPy
|
||||||
################################################################################
|
################################################################################
|
||||||
function Get-PyPyVersions
|
|
||||||
{
|
|
||||||
$uri = "https://downloads.python.org/pypy/"
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$hrefs = (Invoke-WebRequest -Uri $uri).Links.href
|
|
||||||
$hrefs | Where-Object {$_ -match '^pypy'} | Select-Object @{n = "Name"; e = {$_}}, @{n = "href"; e = {
|
|
||||||
[string]::Join('', ($uri, $_))
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Write-Host "Enable to send request to the '$uri'. Error: '$_'"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function Install-PyPy
|
function Install-PyPy
|
||||||
{
|
{
|
||||||
param(
|
param(
|
||||||
@@ -83,35 +67,29 @@ function Install-PyPy
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Get PyPy content from toolset
|
# Get PyPy content from toolset
|
||||||
$pypyTools = Get-ToolsetContent | Select-Object -ExpandProperty toolcache | Where-Object Name -eq "PyPy"
|
$toolsetVersions = Get-ToolsetContent | Select-Object -ExpandProperty toolcache | Where-Object Name -eq "PyPy"
|
||||||
|
|
||||||
# Get PyPy versions from the repo
|
# Get PyPy releases
|
||||||
$pypyVersions = Get-PyPyVersions
|
$pypyVersions = Invoke-RestMethod https://downloads.python.org/pypy/versions.json
|
||||||
|
|
||||||
Write-Host "Starting installation PyPy..."
|
Write-Host "Starting installation PyPy..."
|
||||||
foreach($pypyTool in $pypyTools)
|
foreach($toolsetVersion in $toolsetVersions.versions)
|
||||||
{
|
{
|
||||||
foreach($pypyVersion in $pypyTool.versions)
|
# Query latest PyPy version
|
||||||
|
$latestMajorPyPyVersion = $pypyVersions |
|
||||||
|
Where-Object {$_.python_version.StartsWith("$toolsetVersion") -and $_.stable -eq $true} |
|
||||||
|
Select-Object -ExpandProperty files -First 1 |
|
||||||
|
Where-Object platform -like "win*"
|
||||||
|
|
||||||
|
if ($latestMajorPyPyVersion)
|
||||||
{
|
{
|
||||||
# Query latest PyPy version
|
Write-Host "Found PyPy '$($latestMajorPyPyVersion.filename)' package"
|
||||||
# PyPy 3.6 is not updated anymore and win32 should be used
|
$tempPyPyPackagePath = Start-DownloadWithRetry -Url $latestMajorPyPyVersion.download_url -Name $latestMajorPyPyVersion.filename
|
||||||
$platform = if ($pypyVersion -like "3.6*") { "win32" } else { $pypyTool.platform }
|
Install-PyPy -PackagePath $tempPyPyPackagePath -Architecture $toolsetVersions.arch
|
||||||
$filter = '{0}{1}-v\d+\.\d+\.\d+-{2}.zip' -f $pypyTool.name, $pypyVersion, $platform
|
}
|
||||||
$latestMajorPyPyVersion = $pypyVersions | Where-Object {$_.name -match $filter} | Select-Object -First 1
|
else
|
||||||
|
{
|
||||||
if ($latestMajorPyPyVersion)
|
Write-Host "Failed to query PyPy version '$toolsetVersion'"
|
||||||
{
|
exit 1
|
||||||
$packageName = $latestMajorPyPyVersion.name
|
|
||||||
|
|
||||||
Write-Host "Found PyPy '$packageName' package"
|
|
||||||
$url = $latestMajorPyPyVersion.href
|
|
||||||
$tempPyPyPackagePath = Start-DownloadWithRetry -Url $url -Name $packageName
|
|
||||||
Install-PyPy -PackagePath $tempPyPyPackagePath -Architecture $pypyTool.arch
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Write-Host "Failed to query PyPy version '$pypyVersion' by '$filter' filter"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user