Skip to content

Commit baa218c

Browse files
authored
Resolve Issues with pypy on Mac (Azure#37734)
* update `use-python-version` to no longer use local scripts for downloading additional python versions, the UsePythonVersion task now does this for us. * update `macos` agents to install `pypy39` and move to the AGENT_TOOLSDIRECTORY so that any invocations of python version `pypy39` no longer errors
1 parent b66c36f commit baa218c

File tree

5 files changed

+21
-322
lines changed

5 files changed

+21
-322
lines changed

eng/pipelines/templates/jobs/run-cli-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ resources:
99
parameters:
1010
- name: TargetRepoPackages
1111
type: object
12-
default:
12+
default:
1313
- 'sdk/core/azure-core'
1414
# a list of any resolvable pip install. EG:
1515
# - https://<path-to-blobstorage>/blah.whl
@@ -68,14 +68,14 @@ jobs:
6868
set -ev
6969
source env/bin/activate
7070
python -m pip install -e $(Build.SourcesDirectory)/${{ artifact }}
71-
displayName: Install ${{ artifact }}
71+
displayName: Install ${{ artifact }}
7272
7373
- ${{ each package_spec in parameters.InjectedPackages }}:
7474
- bash: |
7575
set -ev
7676
source env/bin/activate
7777
python -m pip install -e ${{ package_spec }}
78-
displayName: Install ${{ package_spec }}
78+
displayName: Install ${{ package_spec }}
7979
8080
- bash: |
8181
set -ev

eng/pipelines/templates/steps/use-python-version.yml

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,20 @@ parameters:
22
versionSpec: ''
33

44
steps:
5-
# use python 3.8 for tooling. packaging. platform.
6-
- task: UsePythonVersion@0
7-
displayName: "Use Python 3.8"
8-
inputs:
9-
versionSpec: 3.8
10-
11-
- pwsh: |
12-
python -m pip install packaging==23.1
13-
displayName: Prep Environment
14-
15-
# select the appropriate version from manifest if present
16-
- task: PythonScript@0
17-
displayName: 'Install ${{ parameters.versionSpec }} from Python Manifest If Necessary'
18-
inputs:
19-
scriptPath: 'scripts/devops_tasks/install_python_version.py'
20-
arguments: '${{ parameters.versionSpec }} --installer_folder="../_pyinstaller'
21-
22-
# set up bypass of standard use python version
23-
- pwsh: |
24-
$incoming = "${{ parameters.versionSpec }}"
25-
26-
if($incoming.Contains("pypy3")){
27-
Write-Host "##vso[task.setvariable variable=ManualInstallNecessary]true"
28-
}
29-
displayName: Check UsePythonVersion Necessity
30-
31-
- task: PythonScript@0
32-
displayName: 'PyPy3 Specific Path Prepend'
33-
condition: and(succeeded(), eq(variables.ManualInstallNecessary, 'true'))
34-
inputs:
35-
scriptPath: 'scripts/devops_tasks/use_pypy_version.py'
36-
arguments: '${{ parameters.versionSpec }}'
5+
# as of macos-14, pypy of all stripes is no longer available on the predefined MAC agents
6+
# this script installs the newest version of pypy39 from the official pypy site into the hosted tool cache
7+
- script: |
8+
TOOL_LOCATION=$(AGENT_TOOLSDIRECTORY)/PyPy/3.9.4/x64
9+
curl -L -o pypy3.9-v7.3.16-macos_x86_64.tar.bz2 https://downloads.python.org/pypy/pypy3.9-v7.3.16-macos_x86_64.tar.bz2
10+
mkdir -p $TOOL_LOCATION
11+
tar -xvjf pypy3.9-v7.3.16-macos_x86_64.tar.bz2 -C $TOOL_LOCATION --strip-components=1
12+
chmod -R 0755 $TOOL_LOCATION/bin
13+
$TOOL_LOCATION/bin/python -m ensurepip
14+
touch $TOOL_LOCATION/../x64.complete
15+
displayName: Install pypy39 to hosted tool cache
16+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))
3717
38-
# use
3918
- task: UsePythonVersion@0
40-
displayName: "Use Python $(PythonVersion)"
41-
condition: and(succeeded(), not(eq(variables.ManualInstallNecessary, 'true')))
19+
displayName: "Use Python ${{ parameters.versionSpec }}"
4220
inputs:
4321
versionSpec: ${{ parameters.versionSpec }}

eng/scripts/create-venv.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<#!
1+
<#!
22
.SYNOPSIS
33
Creates a virtual environment for a CI machine.
44
@@ -22,10 +22,12 @@ param(
2222

2323
$venvPath = Join-Path $RepoRoot $VenvName
2424
if (!(Test-Path $venvPath)) {
25-
Write-Host "Creating virtual environment '$VenvName'."
25+
$invokingPython = (Get-Command "python").Source
26+
Write-Host "Creating virtual environment '$VenvName' using python located at '$invokingPython'."
2627
python -m pip install virtualenv==20.25.1
2728
python -m virtualenv "$venvPath"
28-
Write-Host "Virtual environment '$VenvName' created."
29+
$pythonVersion = python --version
30+
Write-Host "Virtual environment '$VenvName' created at directory path '$venvPath' utilizing python version $pythonVersion."
2931
Write-Host "##vso[task.setvariable variable=$($VenvName)_LOCATION]$venvPath"
3032
Write-Host "##vso[task.setvariable variable=$($VenvName)_ACTIVATION_SCRIPT]if(`$IsWindows){. $venvPath/Scripts/Activate.ps1;}else {. $venvPath/bin/activate.ps1}"
3133
}

scripts/devops_tasks/install_python_version.py

Lines changed: 0 additions & 186 deletions
This file was deleted.

scripts/devops_tasks/use_pypy_version.py

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)