From 2433d6c93a5f8da49f3c7d19e56bf8de2756d4ca Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 17 Dec 2020 11:46:43 +0300 Subject: [PATCH 1/4] add PYPY_VERSION file --- images/linux/scripts/installers/pypy.sh | 5 +++++ images/macos/provision/core/pypy.sh | 8 +++++++- images/win/scripts/Installers/Install-PyPy.ps1 | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/images/linux/scripts/installers/pypy.sh b/images/linux/scripts/installers/pypy.sh index 99dab0a77e59..69229ec50b97 100644 --- a/images/linux/scripts/installers/pypy.sh +++ b/images/linux/scripts/installers/pypy.sh @@ -52,6 +52,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/macos/provision/core/pypy.sh b/images/macos/provision/core/pypy.sh index 51f0f6ba1755..894ff3ac88dd 100644 --- a/images/macos/provision/core/pypy.sh +++ b/images/macos/provision/core/pypy.sh @@ -11,6 +11,8 @@ function InstallPyPy PACKAGE_URL=$1 PACKAGE_TAR_NAME=$(echo $PACKAGE_URL | awk -F/ '{print $NF}') + versionV=$(echo $PACKAGE_URL | cut -f2 -d"-") + version=${versionV/"v"/""} echo "Downloading tar archive '$PACKAGE_TAR_NAME' - '$PACKAGE_URL'" PACKAGE_TAR_TEMP_PATH="/tmp/$PACKAGE_TAR_NAME" download_with_retries $PACKAGE_URL "/tmp" "$PACKAGE_TAR_NAME" @@ -36,7 +38,6 @@ function InstallPyPy PYPY_TOOLCACHE_PATH=$AGENT_TOOLSDIRECTORY/PyPy PYPY_TOOLCACHE_VERSION_PATH=$PYPY_TOOLCACHE_PATH/$PYTHON_FULL_VERSION PYPY_TOOLCACHE_VERSION_ARCH_PATH=$PYPY_TOOLCACHE_VERSION_PATH/x64 - echo "Check if PyPy hostedtoolcache folder exist..." if [ ! -d $PYPY_TOOLCACHE_PATH ]; then mkdir -p $PYPY_TOOLCACHE_PATH @@ -50,6 +51,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 8b029f0240eb..6e5eadc32d61 100644 --- a/images/win/scripts/Installers/Install-PyPy.ps1 +++ b/images/win/scripts/Installers/Install-PyPy.ps1 @@ -72,6 +72,10 @@ function Install-PyPy Write-Host "Symbolic link created for '$pypyArchPath\Scripts' <<===>> '$pypyArchPath\bin'" New-Item -Path "$pypyArchPath\bin" -ItemType SymbolicLink -Value "$pypyArchPath\Scripts" | Out-Null + $pypy_version = & $pypyApp -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))" + Write-Host "Write $pypy_version to PYPY_VERSION FILE" + New-Item -Path "$pypyArchPath\PYPY_VERSION" -Value $pypy_version + Write-Host "Create complete file" New-Item -ItemType File -Path $pypyVersionPath -Name "$architecture.complete" | Out-Null } From 185dd6f8afe9c1b502e627721a1e0c16ef531958 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 17 Dec 2020 12:49:44 +0300 Subject: [PATCH 2/4] resolving comments --- images/linux/scripts/installers/pypy.sh | 7 +++---- images/macos/provision/core/pypy.sh | 6 ++++-- .../win/scripts/Installers/Install-PyPy.ps1 | 20 +++++++++---------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/images/linux/scripts/installers/pypy.sh b/images/linux/scripts/installers/pypy.sh index 69229ec50b97..f387a7fe7068 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 @@ -53,10 +56,6 @@ 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/macos/provision/core/pypy.sh b/images/macos/provision/core/pypy.sh index 894ff3ac88dd..30bde57c68ad 100644 --- a/images/macos/provision/core/pypy.sh +++ b/images/macos/provision/core/pypy.sh @@ -11,8 +11,6 @@ function InstallPyPy PACKAGE_URL=$1 PACKAGE_TAR_NAME=$(echo $PACKAGE_URL | awk -F/ '{print $NF}') - versionV=$(echo $PACKAGE_URL | cut -f2 -d"-") - version=${versionV/"v"/""} echo "Downloading tar archive '$PACKAGE_TAR_NAME' - '$PACKAGE_URL'" PACKAGE_TAR_TEMP_PATH="/tmp/$PACKAGE_TAR_NAME" download_with_retries $PACKAGE_URL "/tmp" "$PACKAGE_TAR_NAME" @@ -33,11 +31,15 @@ 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 PYPY_TOOLCACHE_VERSION_PATH=$PYPY_TOOLCACHE_PATH/$PYTHON_FULL_VERSION PYPY_TOOLCACHE_VERSION_ARCH_PATH=$PYPY_TOOLCACHE_VERSION_PATH/x64 + echo "Check if PyPy hostedtoolcache folder exist..." if [ ! -d $PYPY_TOOLCACHE_PATH ]; then mkdir -p $PYPY_TOOLCACHE_PATH diff --git a/images/win/scripts/Installers/Install-PyPy.ps1 b/images/win/scripts/Installers/Install-PyPy.ps1 index 6e5eadc32d61..8d5c24ce1afb 100644 --- a/images/win/scripts/Installers/Install-PyPy.ps1 +++ b/images/win/scripts/Installers/Install-PyPy.ps1 @@ -34,13 +34,13 @@ 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) + 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 +48,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) @@ -72,9 +72,9 @@ function Install-PyPy Write-Host "Symbolic link created for '$pypyArchPath\Scripts' <<===>> '$pypyArchPath\bin'" New-Item -Path "$pypyArchPath\bin" -ItemType SymbolicLink -Value "$pypyArchPath\Scripts" | Out-Null - $pypy_version = & $pypyApp -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))" - Write-Host "Write $pypy_version to PYPY_VERSION FILE" - New-Item -Path "$pypyArchPath\PYPY_VERSION" -Value $pypy_version + $pypyFullVersion = & $pypyApp -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))" + Write-Host "Write $pypyFullVersion to PYPY_VERSION FILE" + New-Item -Path "$pypyArchPath\PYPY_VERSION" -Value $pypyFullVersion Write-Host "Create complete file" New-Item -ItemType File -Path $pypyVersionPath -Name "$architecture.complete" | Out-Null From 9817313f7876cb7d4a5b38c26d7e99bc3250781f Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 17 Dec 2020 12:52:20 +0300 Subject: [PATCH 3/4] fix output for windows --- images/win/scripts/Installers/Install-PyPy.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Install-PyPy.ps1 b/images/win/scripts/Installers/Install-PyPy.ps1 index 8d5c24ce1afb..72432a6e3205 100644 --- a/images/win/scripts/Installers/Install-PyPy.ps1 +++ b/images/win/scripts/Installers/Install-PyPy.ps1 @@ -73,7 +73,7 @@ function Install-PyPy New-Item -Path "$pypyArchPath\bin" -ItemType SymbolicLink -Value "$pypyArchPath\Scripts" | Out-Null $pypyFullVersion = & $pypyApp -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))" - Write-Host "Write $pypyFullVersion to PYPY_VERSION FILE" + Write-Host "Put '$pypyFullVersion' to PYPY_VERSION file" New-Item -Path "$pypyArchPath\PYPY_VERSION" -Value $pypyFullVersion Write-Host "Create complete file" From 5015b0ed565568e6042d133cae71323338e26b47 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 17 Dec 2020 18:01:20 +0300 Subject: [PATCH 4/4] add fix for windows --- images/win/scripts/Installers/Install-PyPy.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/images/win/scripts/Installers/Install-PyPy.ps1 b/images/win/scripts/Installers/Install-PyPy.ps1 index 72432a6e3205..aaae1b35aa86 100644 --- a/images/win/scripts/Installers/Install-PyPy.ps1 +++ b/images/win/scripts/Installers/Install-PyPy.ps1 @@ -36,6 +36,10 @@ function Install-PyPy $pypyName = $pypyApp.Name $pythonVersion = & $pypyApp -c "import sys;print('{}.{}.{}'.format(sys.version_info[0],sys.version_info[1],sys.version_info[2]))" + $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 $pythonVersion" @@ -72,10 +76,6 @@ function Install-PyPy Write-Host "Symbolic link created for '$pypyArchPath\Scripts' <<===>> '$pypyArchPath\bin'" New-Item -Path "$pypyArchPath\bin" -ItemType SymbolicLink -Value "$pypyArchPath\Scripts" | Out-Null - $pypyFullVersion = & $pypyApp -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))" - Write-Host "Put '$pypyFullVersion' to PYPY_VERSION file" - New-Item -Path "$pypyArchPath\PYPY_VERSION" -Value $pypyFullVersion - Write-Host "Create complete file" New-Item -ItemType File -Path $pypyVersionPath -Name "$architecture.complete" | Out-Null }