From 219d11cbd1f301a8c11236dd9da37486655628b0 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Date: Thu, 21 Oct 2021 09:29:45 +0300 Subject: [PATCH] Fix PyPy permissions (#4317) --- .../win/scripts/Installers/Install-PyPy.ps1 | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/images/win/scripts/Installers/Install-PyPy.ps1 b/images/win/scripts/Installers/Install-PyPy.ps1 index 8d104b43..bff461ec 100644 --- a/images/win/scripts/Installers/Install-PyPy.ps1 +++ b/images/win/scripts/Installers/Install-PyPy.ps1 @@ -26,10 +26,17 @@ function Install-PyPy [String]$Architecture ) + # Create PyPy toolcache folder + $pypyToolcachePath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "PyPy" + if (-not (Test-Path $pypyToolcachePath)) { + Write-Host "Create PyPy toolcache folder" + New-Item -ItemType Directory -Path $pypyToolcachePath | Out-Null + } + # Expand archive with binaries $packageName = [IO.Path]::GetFileNameWithoutExtension((Split-Path -Path $packagePath -Leaf)) - $tempFolder = Join-Path -Path $env:Temp -ChildPath $packageName - Extract-7Zip -Path $packagePath -DestinationPath $env:Temp + $tempFolder = Join-Path -Path $pypyToolcachePath -ChildPath $packageName + Extract-7Zip -Path $packagePath -DestinationPath $pypyToolcachePath # Get Python version from binaries $pypyApp = Get-ChildItem -Path "$tempFolder\pypy*.exe" | Where-Object Name -match "pypy(\d+)?.exe" | Select-Object -First 1 @@ -37,20 +44,14 @@ function Install-PyPy $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 + New-Item -Path "$tempFolder\PYPY_VERSION" -Value $pypyFullVersion | Out-Null if ($pythonVersion) { Write-Host "Installing PyPy $pythonVersion" - $pypyToolcachePath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "PyPy" $pypyVersionPath = Join-Path -Path $pypyToolcachePath -ChildPath $pythonVersion $pypyArchPath = Join-Path -Path $pypyVersionPath -ChildPath $architecture - if (-not (Test-Path $pypyToolcachePath)) { - Write-Host "Create PyPy toolcache folder" - New-Item -ItemType Directory -Path $pypyToolcachePath | Out-Null - } - Write-Host "Create PyPy '${pythonVersion}' folder in '${pypyVersionPath}'" New-Item -ItemType Directory -Path $pypyVersionPath -Force | Out-Null