Skip to content

Commit

Permalink
Resolve Issues with pypy on Mac (#37734)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
scbedd authored Oct 7, 2024
1 parent b66c36f commit baa218c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 322 deletions.
6 changes: 3 additions & 3 deletions eng/pipelines/templates/jobs/run-cli-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resources:
parameters:
- name: TargetRepoPackages
type: object
default:
default:
- 'sdk/core/azure-core'
# a list of any resolvable pip install. EG:
# - https://<path-to-blobstorage>/blah.whl
Expand Down Expand Up @@ -68,14 +68,14 @@ jobs:
set -ev
source env/bin/activate
python -m pip install -e $(Build.SourcesDirectory)/${{ artifact }}
displayName: Install ${{ artifact }}
displayName: Install ${{ artifact }}
- ${{ each package_spec in parameters.InjectedPackages }}:
- bash: |
set -ev
source env/bin/activate
python -m pip install -e ${{ package_spec }}
displayName: Install ${{ package_spec }}
displayName: Install ${{ package_spec }}
- bash: |
set -ev
Expand Down
48 changes: 13 additions & 35 deletions eng/pipelines/templates/steps/use-python-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,20 @@ parameters:
versionSpec: ''

steps:
# use python 3.8 for tooling. packaging. platform.
- task: UsePythonVersion@0
displayName: "Use Python 3.8"
inputs:
versionSpec: 3.8

- pwsh: |
python -m pip install packaging==23.1
displayName: Prep Environment
# select the appropriate version from manifest if present
- task: PythonScript@0
displayName: 'Install ${{ parameters.versionSpec }} from Python Manifest If Necessary'
inputs:
scriptPath: 'scripts/devops_tasks/install_python_version.py'
arguments: '${{ parameters.versionSpec }} --installer_folder="../_pyinstaller'

# set up bypass of standard use python version
- pwsh: |
$incoming = "${{ parameters.versionSpec }}"
if($incoming.Contains("pypy3")){
Write-Host "##vso[task.setvariable variable=ManualInstallNecessary]true"
}
displayName: Check UsePythonVersion Necessity
- task: PythonScript@0
displayName: 'PyPy3 Specific Path Prepend'
condition: and(succeeded(), eq(variables.ManualInstallNecessary, 'true'))
inputs:
scriptPath: 'scripts/devops_tasks/use_pypy_version.py'
arguments: '${{ parameters.versionSpec }}'
# as of macos-14, pypy of all stripes is no longer available on the predefined MAC agents
# this script installs the newest version of pypy39 from the official pypy site into the hosted tool cache
- script: |
TOOL_LOCATION=$(AGENT_TOOLSDIRECTORY)/PyPy/3.9.4/x64
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
mkdir -p $TOOL_LOCATION
tar -xvjf pypy3.9-v7.3.16-macos_x86_64.tar.bz2 -C $TOOL_LOCATION --strip-components=1
chmod -R 0755 $TOOL_LOCATION/bin
$TOOL_LOCATION/bin/python -m ensurepip
touch $TOOL_LOCATION/../x64.complete
displayName: Install pypy39 to hosted tool cache
condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))
# use
- task: UsePythonVersion@0
displayName: "Use Python $(PythonVersion)"
condition: and(succeeded(), not(eq(variables.ManualInstallNecessary, 'true')))
displayName: "Use Python ${{ parameters.versionSpec }}"
inputs:
versionSpec: ${{ parameters.versionSpec }}
8 changes: 5 additions & 3 deletions eng/scripts/create-venv.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#!
<#!
.SYNOPSIS
Creates a virtual environment for a CI machine.
Expand All @@ -22,10 +22,12 @@ param(

$venvPath = Join-Path $RepoRoot $VenvName
if (!(Test-Path $venvPath)) {
Write-Host "Creating virtual environment '$VenvName'."
$invokingPython = (Get-Command "python").Source
Write-Host "Creating virtual environment '$VenvName' using python located at '$invokingPython'."
python -m pip install virtualenv==20.25.1
python -m virtualenv "$venvPath"
Write-Host "Virtual environment '$VenvName' created."
$pythonVersion = python --version
Write-Host "Virtual environment '$VenvName' created at directory path '$venvPath' utilizing python version $pythonVersion."
Write-Host "##vso[task.setvariable variable=$($VenvName)_LOCATION]$venvPath"
Write-Host "##vso[task.setvariable variable=$($VenvName)_ACTIVATION_SCRIPT]if(`$IsWindows){. $venvPath/Scripts/Activate.ps1;}else {. $venvPath/bin/activate.ps1}"
}
Expand Down
186 changes: 0 additions & 186 deletions scripts/devops_tasks/install_python_version.py

This file was deleted.

95 changes: 0 additions & 95 deletions scripts/devops_tasks/use_pypy_version.py

This file was deleted.

0 comments on commit baa218c

Please sign in to comment.