From 4de7f89a42529d48d04cc7a7eb85b570b709448c Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 21 Dec 2020 15:07:19 +0300 Subject: [PATCH] Add PYPY_VERSION file to the images (#2285) * add PYPY_VERSION file * resolving comments * fix output for windows * add fix for windows --- images/linux/scripts/installers/pypy.sh | 4 ++++ images/macos/provision/core/pypy.sh | 8 ++++++++ images/win/scripts/Installers/Install-PyPy.ps1 | 18 +++++++++++------- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/images/linux/scripts/installers/pypy.sh b/images/linux/scripts/installers/pypy.sh index 99dab0a77..f387a7fe7 100644 --- a/images/linux/scripts/installers/pypy.sh +++ b/images/linux/scripts/installers/pypy.sh @@ -33,6 +33,9 @@ function InstallPyPy PACKAGE_TEMP_FOLDER="/tmp/$PACKAGE_NAME" PYTHON_FULL_VERSION=$("$PACKAGE_TEMP_FOLDER/bin/$PYPY_MAJOR" -c "import sys;print('{}.{}.{}'.format(sys.version_info[0],sys.version_info[1],sys.version_info[2]))") + PYPY_FULL_VERSION=$("$PACKAGE_TEMP_FOLDER/bin/$PYPY_MAJOR" -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))") + echo "Put '$PYPY_FULL_VERSION' to PYPY_VERSION file" + echo $PYPY_FULL_VERSION > "$PACKAGE_TEMP_FOLDER/PYPY_VERSION" # PyPy folder structure PYPY_TOOLCACHE_PATH=$AGENT_TOOLSDIRECTORY/PyPy @@ -52,6 +55,7 @@ function InstallPyPy echo "Create additional symlinks (Required for UsePythonVersion Azure DevOps task)" cd $PYPY_TOOLCACHE_VERSION_ARCH_PATH/bin + ln -s $PYPY_MAJOR $PYTHON_MAJOR ln -s $PYTHON_MAJOR python diff --git a/images/macos/provision/core/pypy.sh b/images/macos/provision/core/pypy.sh index 51f0f6ba1..30bde57c6 100644 --- a/images/macos/provision/core/pypy.sh +++ b/images/macos/provision/core/pypy.sh @@ -31,6 +31,9 @@ function InstallPyPy PACKAGE_TEMP_FOLDER="/tmp/$PACKAGE_NAME" PYTHON_FULL_VERSION=$("$PACKAGE_TEMP_FOLDER/bin/$PYPY_MAJOR" -c "import sys;print('{}.{}.{}'.format(sys.version_info[0],sys.version_info[1],sys.version_info[2]))") + PYPY_FULL_VERSION=$("$PACKAGE_TEMP_FOLDER/bin/$PYPY_MAJOR" -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))") + echo "Put '$PYPY_FULL_VERSION' to PYPY_VERSION file" + echo $PYPY_FULL_VERSION > "$PACKAGE_TEMP_FOLDER/PYPY_VERSION" # PyPy folder structure PYPY_TOOLCACHE_PATH=$AGENT_TOOLSDIRECTORY/PyPy @@ -50,6 +53,11 @@ function InstallPyPy echo "Create additional symlinks (Required for UsePythonVersion Azure DevOps task)" cd $PYPY_TOOLCACHE_VERSION_ARCH_PATH/bin + + PYPY_FULL_VERSION=$(./$PYPY_MAJOR -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))") + echo "PYPY_FULL_VERSION is $PYPY_FULL_VERSION" + echo $PYPY_FULL_VERSION > "PYPY_VERSION" + ln -s $PYPY_MAJOR $PYTHON_MAJOR ln -s $PYTHON_MAJOR python diff --git a/images/win/scripts/Installers/Install-PyPy.ps1 b/images/win/scripts/Installers/Install-PyPy.ps1 index 8b029f024..aaae1b35a 100644 --- a/images/win/scripts/Installers/Install-PyPy.ps1 +++ b/images/win/scripts/Installers/Install-PyPy.ps1 @@ -34,13 +34,17 @@ function Install-PyPy # Get Python version from binaries $pypyApp = Get-ChildItem -Path "$tempFolder\pypy*.exe" | Where-Object Name -match "pypy(\d+)?.exe" $pypyName = $pypyApp.Name - $pypyVersion = & $pypyApp -c "import sys;print('{}.{}.{}'.format(sys.version_info[0],sys.version_info[1],sys.version_info[2]))" + $pythonVersion = & $pypyApp -c "import sys;print('{}.{}.{}'.format(sys.version_info[0],sys.version_info[1],sys.version_info[2]))" - if ($pypyVersion) + $pypyFullVersion = & $pypyApp -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))" + Write-Host "Put '$pypyFullVersion' to PYPY_VERSION file" + New-Item -Path "$tempFolder\PYPY_VERSION" -Value $pypyFullVersion + + if ($pythonVersion) { - Write-Host "Installing PyPy $pypyVersion" + Write-Host "Installing PyPy $pythonVersion" $pypyToolcachePath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "PyPy" - $pypyVersionPath = Join-Path -Path $pypyToolcachePath -ChildPath $pypyVersion + $pypyVersionPath = Join-Path -Path $pypyToolcachePath -ChildPath $pythonVersion $pypyArchPath = Join-Path -Path $pypyVersionPath -ChildPath $architecture if (-not (Test-Path $pypyToolcachePath)) { @@ -48,13 +52,13 @@ function Install-PyPy New-Item -ItemType Directory -Path $pypyToolcachePath | Out-Null } - Write-Host "Create PyPy '${pypyVersion}' folder in '${pypyVersionPath}'" + Write-Host "Create PyPy '${pythonVersion}' folder in '${pypyVersionPath}'" New-Item -ItemType Directory -Path $pypyVersionPath -Force | Out-Null - Write-Host "Move PyPy '${pypyVersion}' files to '${pypyArchPath}'" + Write-Host "Move PyPy '${pythonVersion}' files to '${pypyArchPath}'" Move-Item -Path $tempFolder -Destination $pypyArchPath | Out-Null - Write-Host "Install PyPy '${pypyVersion}' in '${pypyArchPath}'" + Write-Host "Install PyPy '${pythonVersion}' in '${pypyArchPath}'" cmd.exe /c "cd /d $pypyArchPath && mklink python.exe $pypyName && python.exe -m ensurepip && python.exe -m pip install --upgrade pip" if ($LASTEXITCODE -ne 0)