diff --git a/eng/pipelines/templates/steps/use-python-version.yml b/eng/pipelines/templates/steps/use-python-version.yml index 4b8abd59c000..94446e4201c8 100644 --- a/eng/pipelines/templates/steps/use-python-version.yml +++ b/eng/pipelines/templates/steps/use-python-version.yml @@ -12,6 +12,60 @@ steps: } 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: diff --git a/sdk/ml/ci.yml b/sdk/ml/ci.yml index 82c4f5a25c82..2569853d82ef 100644 --- a/sdk/ml/ci.yml +++ b/sdk/ml/ci.yml @@ -32,6 +32,11 @@ extends: ServiceDirectory: ml TestTimeoutInMinutes: 75 TestProxy: true + MatrixConfigs: + - Name: Python_ml_ci_matrix + Path: sdk/ml/platform-matrix.json + Selection: sparse + GenerateVMJobs: true # This is a short term solution to create API review for python azure-ml package only when running pipeline manually # Long term solution should be to have different versions on main branch and release branch for python package so APIView can have different revisions for each version. # Tracking issue: https://github.com/Azure/azure-sdk-for-python/issues/29196 diff --git a/sdk/ml/platform-matrix.json b/sdk/ml/platform-matrix.json new file mode 100644 index 000000000000..290055b0ed6a --- /dev/null +++ b/sdk/ml/platform-matrix.json @@ -0,0 +1,76 @@ +{ + "displayNames": { + "--disablecov": "", + "false": "", + "true": "" + }, + "matrix": { + "Agent": { + "ubuntu-24.04": { "OSVmImage": "env:LINUXVMIMAGE", "Pool": "env:LINUXPOOL" }, + "windows-2022": { "OSVmImage": "env:WINDOWSVMIMAGE", "Pool": "env:WINDOWSPOOL" } + }, + "PythonVersion": [ "3.10", "3.12" ], + "CoverageArg": "--disablecov", + "TestSamples": "false" + }, + "include": [ + { + "MacTestConfig": { + "macos311": { + "OSVmImage": "env:MACVMIMAGE", + "Pool": "env:MACPOOL", + "PythonVersion": "3.11", + "CoverageArg": "--disablecov", + "TestSamples": "false" + } + } + }, + { + "PyPyConfig": { + "ubuntu2404_pypy311": { + "OSVmImage": "env:LINUXVMIMAGE", + "Pool": "env:LINUXPOOL", + "PythonVersion": "pypy3.11", + "CoverageArg": "--disablecov", + "TestSamples": "false", + "OverridePyPyVersion": "true", + "PyPyBuildVersion": "v7.3.22", + "PyPyLangVersion": "3.11.15" + } + } + }, + { + "CoverageConfig": { + "ubuntu2404_310_coverage": { + "OSVmImage": "env:LINUXVMIMAGE", + "Pool": "env:LINUXPOOL", + "PythonVersion": "3.10", + "CoverageArg": "", + "TestSamples": "false" + } + } + }, + { + "Config": { + "Ubuntu2404_313": { + "OSVmImage": "env:LINUXVMIMAGE", + "Pool": "env:LINUXPOOL", + "PythonVersion": "3.13", + "CoverageArg": "--disablecov", + "TestSamples": "false" + } + } + }, + { + "Config": { + "Ubuntu2404_314": { + "OSVmImage": "env:LINUXVMIMAGE", + "Pool": "env:LINUXPOOL", + "PythonVersion": "3.14", + "CoverageArg": "--disablecov", + "TestSamples": "false" + } + } + } + ] +}