forked from Azure/azure-sdk-for-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuse-python-version.yml
More file actions
73 lines (70 loc) · 3.51 KB
/
use-python-version.yml
File metadata and controls
73 lines (70 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
parameters:
versionSpec: ''
steps:
# Using built-in Azure DevOps tasks can result in auto-retrieval of packages like pip from pypi.
# Set a default PIP_INDEX_URL ASAP so that these auto-restores do not fail in isolated networks.
- pwsh: |
if (-not $env:PIP_INDEX_URL) {
Write-Host "##vso[task.setvariable variable=PIP_INDEX_URL]https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
} else {
Write-Host "PIP_INDEX_URL is already set; preserving existing value."
}
displayName: 'Use Public Feed'
# Optional override for the hosted toolcache PyPy build. Activated when the
# matrix entry sets:
# OverridePyPyVersion: "true"
# PyPyBuildVersion: "v7.3.22" (or any release from downloads.python.org/pypy)
# PyPyLangVersion: "3.11.15" (the Python language version directory in the toolcache)
# Rationale: PyPy 7.3.21 (currently in the hosted toolcache for Python 3.11.15)
# crashes with `Fatal RPython error: AssertionError` from
# `PythonCodeMaker_duplicate_exits_without_lineno` while compiling
# `azure.ai.ml`. PyPy 7.3.22+ does not exhibit this bug.
- bash: |
set -euo pipefail
PYPY_BUILD="${PYPY_BUILD_VERSION:?PyPyBuildVersion must be set in the matrix when OverridePyPyVersion=true}"
PY_LANG="${PYPY_LANG_VERSION:?PyPyLangVersion must be set in the matrix when OverridePyPyVersion=true}"
TARGET="/opt/hostedtoolcache/PyPy/${PY_LANG}/x64"
WANT_MICRO="${PYPY_BUILD#v}"
if [ -x "${TARGET}/bin/python3" ]; then
CURRENT=$("${TARGET}/bin/python3" -c 'import sys; v=sys.pypy_version_info; print(f"{v.major}.{v.minor}.{v.micro}")') || CURRENT="unknown"
echo "Existing toolcache PyPy: ${CURRENT}"
if [ "$CURRENT" = "$WANT_MICRO" ]; then
echo "PyPy ${WANT_MICRO} already installed; nothing to do."
exit 0
fi
fi
echo "Installing PyPy ${PYPY_BUILD} for Python ${PY_LANG} into ${TARGET}..."
TARBALL="pypy3.11-${PYPY_BUILD}-linux64.tar.bz2"
cd /tmp
curl -sSLO "https://downloads.python.org/pypy/${TARBALL}"
tar xjf "${TARBALL}"
sudo rm -rf "${TARGET}"
sudo mkdir -p "$(dirname "${TARGET}")"
sudo mv "pypy3.11-${PYPY_BUILD}-linux64" "${TARGET}"
# Recreate the python3/python symlinks that the upstream toolcache layout provides.
if [ ! -e "${TARGET}/bin/python3" ]; then
sudo ln -sf "${TARGET}/bin/pypy3.11" "${TARGET}/bin/python3"
fi
if [ ! -e "${TARGET}/bin/python" ]; then
sudo ln -sf "${TARGET}/bin/pypy3.11" "${TARGET}/bin/python"
fi
sudo touch "${TARGET}.complete"
"${TARGET}/bin/python3" --version
# The plain pypy tarball does not include pip; the Azure hosted
# toolcache build does. Bootstrap pip via ensurepip so downstream
# steps (e.g. `python -m pip install uv`) keep working.
if ! "${TARGET}/bin/python3" -c "import pip" >/dev/null 2>&1; then
echo "Bootstrapping pip via ensurepip..."
sudo "${TARGET}/bin/python3" -m ensurepip --upgrade
fi
"${TARGET}/bin/python3" -m pip --version
env:
PYPY_BUILD_VERSION: $(PyPyBuildVersion)
PYPY_LANG_VERSION: $(PyPyLangVersion)
displayName: 'Override hosted toolcache PyPy build'
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'), eq(variables['OverridePyPyVersion'], 'true'))
- task: UsePythonVersion@0
displayName: "Use Python ${{ parameters.versionSpec }}"
inputs:
versionSpec: ${{ parameters.versionSpec }}
allowUnstable: true