[CD] Build Mac wheels using setup-python action (#162136)

Biggest difference between both conda and homebrew CPython builds and one from python.org, is that later are universal binaries and they are always trying to build universal extension...

Workaround lots of universal binary build attempts by explicitly specifying both `_PYTHON_PLATFORM` and `--plat-name` as well as `ARCH_FLAGS`

Suppressed actionlint warning on use of `freethreaded` flag which is document in https://github.com/actions/setup-python/tree/v5

TODO: Remove lots of temporary workarounds when `3.14` is out in October 2025

Pull Request resolved: https://github.com/pytorch/pytorch/pull/162136
Approved by: https://github.com/atalman, https://github.com/huydhn
ghstack dependencies: #162297, #162265
This commit is contained in:
Nikita Shulga 2025-09-09 08:51:14 -07:00 committed by PyTorch MergeBot
parent a956066b4e
commit 84d8ec73f1
5 changed files with 94 additions and 344 deletions

View File

@ -85,7 +85,7 @@ mkdir -p "$PYTORCH_FINAL_PACKAGE_DIR" || true
# Create an isolated directory to store this builds pytorch checkout and conda # Create an isolated directory to store this builds pytorch checkout and conda
# installation # installation
if [[ -z "$MAC_PACKAGE_WORK_DIR" ]]; then if [[ -z "$MAC_PACKAGE_WORK_DIR" ]]; then
MAC_PACKAGE_WORK_DIR="$(pwd)/tmp_wheel_conda_${DESIRED_PYTHON}_$(date +%H%M%S)" MAC_PACKAGE_WORK_DIR="$(pwd)/tmp_wheel_${DESIRED_PYTHON}_$(date +%H%M%S)"
fi fi
mkdir -p "$MAC_PACKAGE_WORK_DIR" || true mkdir -p "$MAC_PACKAGE_WORK_DIR" || true
if [[ -n ${GITHUB_ACTIONS} ]]; then if [[ -n ${GITHUB_ACTIONS} ]]; then
@ -96,11 +96,11 @@ fi
whl_tmp_dir="${MAC_PACKAGE_WORK_DIR}/dist" whl_tmp_dir="${MAC_PACKAGE_WORK_DIR}/dist"
mkdir -p "$whl_tmp_dir" mkdir -p "$whl_tmp_dir"
mac_version='macosx_11_0_arm64' mac_version='macosx-11_0-arm64'
libtorch_arch='arm64' libtorch_arch='arm64'
# Create a consistent wheel package name to rename the wheel to # Create a consistent wheel package name to rename the wheel to
wheel_filename_new="${TORCH_PACKAGE_NAME}-${build_version}${build_number_prefix}-cp${python_nodot}-none-${mac_version}.whl" wheel_filename_new="${TORCH_PACKAGE_NAME}-${build_version}${build_number_prefix}-cp${python_nodot}-none-${mac_version//[-,]/_}.whl"
########################################################### ###########################################################
@ -125,7 +125,6 @@ popd
export TH_BINARY_BUILD=1 export TH_BINARY_BUILD=1
export INSTALL_TEST=0 # dont install test binaries into site-packages export INSTALL_TEST=0 # dont install test binaries into site-packages
export MACOSX_DEPLOYMENT_TARGET=11.0 export MACOSX_DEPLOYMENT_TARGET=11.0
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
EXTRA_CONDA_INSTALL_FLAGS="" EXTRA_CONDA_INSTALL_FLAGS=""
CONDA_ENV_CREATE_FLAGS="" CONDA_ENV_CREATE_FLAGS=""
@ -133,25 +132,19 @@ RENAME_WHEEL=true
case $desired_python in case $desired_python in
3.14t) 3.14t)
echo "Using 3.14 deps" echo "Using 3.14 deps"
mac_version='macosx-11.0-arm64'
NUMPY_PINNED_VERSION="==2.1.0" NUMPY_PINNED_VERSION="==2.1.0"
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
RENAME_WHEEL=false RENAME_WHEEL=false
;; ;;
3.14) 3.14)
echo "Using 3.14t deps" echo "Using 3.14t deps"
mac_version='macosx-11.0-arm64'
NUMPY_PINNED_VERSION="==2.1.0" NUMPY_PINNED_VERSION="==2.1.0"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
RENAME_WHEEL=false RENAME_WHEEL=false
;; ;;
3.13t) 3.13t)
echo "Using 3.13 deps" echo "Using 3.13 deps"
NUMPY_PINNED_VERSION="==2.1.0" NUMPY_PINNED_VERSION="==2.1.0"
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge"
desired_python="3.13"
RENAME_WHEEL=false RENAME_WHEEL=false
;; ;;
3.13) 3.13)
@ -176,17 +169,12 @@ case $desired_python in
;; ;;
esac esac
# Install into a fresh env
tmp_env_name="wheel_py$python_nodot"
conda create ${EXTRA_CONDA_INSTALL_FLAGS} -yn "$tmp_env_name" python="$desired_python" ${CONDA_ENV_CREATE_FLAGS}
source activate "$tmp_env_name"
PINNED_PACKAGES=( PINNED_PACKAGES=(
"numpy${NUMPY_PINNED_VERSION}" "numpy${NUMPY_PINNED_VERSION}"
) )
retry pip install "${PINNED_PACKAGES[@]}" -r "${pytorch_rootdir}/requirements-build.txt" python -mvenv ~/${desired_python}-build
pip install requests ninja typing-extensions source ~/${desired_python}-build/bin/activate
retry pip install -r "${pytorch_rootdir}/requirements.txt" || true retry pip install "${PINNED_PACKAGES[@]}" -r "${pytorch_rootdir}/requirements.txt"
retry brew install libomp retry brew install libomp
# For USE_DISTRIBUTED=1 on macOS, need libuv, which is build as part of tensorpipe submodule # For USE_DISTRIBUTED=1 on macOS, need libuv, which is build as part of tensorpipe submodule
@ -199,7 +187,7 @@ export BUILD_TEST=OFF
pushd "$pytorch_rootdir" pushd "$pytorch_rootdir"
echo "Calling setup.py bdist_wheel at $(date)" echo "Calling setup.py bdist_wheel at $(date)"
python setup.py bdist_wheel -d "$whl_tmp_dir" --plat-name ${mac_version} _PYTHON_HOST_PLATFORM=${mac_version} ARCHFLAGS="-arch arm64" python setup.py bdist_wheel -d "$whl_tmp_dir" --plat-name "${mac_version//[-.]/_}"
echo "Finished setup.py bdist_wheel at $(date)" echo "Finished setup.py bdist_wheel at $(date)"

View File

@ -22,6 +22,16 @@ name: !{{ build_environment }}
echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}" echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}"
{%- endmacro %} {%- endmacro %}
{%- macro setup_python(py_ver) -%}
- name: Setup Python
uses: actions/setup-python@v6
with:
# TODO: Removeme once 3.14 is out
# .4 version is min minor for 3.10, and also no-gil version of 3.13 needs at least 3.13.3
python-version: "!{{ (py_ver.strip('t') + '.4') if '3.14' not in py_ver else '3.14.0-rc.2' }}"
freethreaded: !{{ "true" if py_ver.endswith('t') else "false" }}
{%- endmacro %}
on: on:
# TODO: Migrate to new ciflow trigger, reference https://github.com/pytorch/pytorch/pull/70321 # TODO: Migrate to new ciflow trigger, reference https://github.com/pytorch/pytorch/pull/70321
push: push:
@ -61,23 +71,13 @@ jobs:
{%- endif %} {%- endif %}
steps: steps:
!{{ set_runner_specific_vars() }} !{{ set_runner_specific_vars() }}
- name: Install conda and dependencies !{{ setup_python(config.get("python_version", "3.10")) }}
run: |
# Install conda, setup-miniconda messes with the path that messes with the ruby stuff we do later on
curl --retry 3 --retry-all-errors -o "${RUNNER_TEMP}/conda.sh" "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-$(uname -m).sh"
chmod +x "${RUNNER_TEMP}/conda.sh"
/bin/bash "${RUNNER_TEMP}/conda.sh" -b -p "${RUNNER_TEMP}/anaconda"
echo "${RUNNER_TEMP}/anaconda/bin" >> "${GITHUB_PATH}"
!{{ common.checkout(deep_clone=False, directory="pytorch") }} !{{ common.checkout(deep_clone=False, directory="pytorch") }}
- name: Populate binary env - name: Populate binary env
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
"${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh" "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
- name: Build PyTorch binary - name: Build PyTorch binary
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -94,8 +94,6 @@ jobs:
{%- if config["package_type"] == "wheel" %} {%- if config["package_type"] == "wheel" %}
- name: Test PyTorch wheel - name: Test PyTorch wheel
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -106,33 +104,9 @@ jobs:
SMOKE_TEST_PARAMS="" SMOKE_TEST_PARAMS=""
EXTRA_CONDA_INSTALL_FLAGS=""
CONDA_ENV_CREATE_FLAGS=""
# shellcheck disable=SC2153
case $DESIRED_PYTHON in
3.14t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.14)
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.13t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge"
desired_python="3.13"
;;
*)
# shellcheck disable=SC2153
desired_python=${DESIRED_PYTHON}
;;
esac
# shellcheck disable=SC2086 # shellcheck disable=SC2086
conda create -yn "test_conda_env" python="$desired_python" ${CONDA_ENV_CREATE_FLAGS} ${EXTRA_CONDA_INSTALL_FLAGS} python -mvenv test_venv
conda activate test_conda_env source test_venv/bin/activate
pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v
# shellcheck disable=SC2086 # shellcheck disable=SC2086

View File

@ -60,13 +60,13 @@ jobs:
echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}" echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
# shellcheck disable=SC2129 # shellcheck disable=SC2129
echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}" echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}"
- name: Install conda and dependencies - name: Setup Python
run: | uses: actions/setup-python@v6
# Install conda, setup-miniconda messes with the path that messes with the ruby stuff we do later on with:
curl --retry 3 --retry-all-errors -o "${RUNNER_TEMP}/conda.sh" "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-$(uname -m).sh" # TODO: Removeme once 3.14 is out
chmod +x "${RUNNER_TEMP}/conda.sh" # .4 version is min minor for 3.10, and also no-gil version of 3.13 needs at least 3.13.3
/bin/bash "${RUNNER_TEMP}/conda.sh" -b -p "${RUNNER_TEMP}/anaconda" python-version: "3.10.4"
echo "${RUNNER_TEMP}/anaconda/bin" >> "${GITHUB_PATH}" freethreaded: false
- name: Checkout PyTorch - name: Checkout PyTorch
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
@ -81,13 +81,9 @@ jobs:
working-directory: pytorch working-directory: pytorch
- name: Populate binary env - name: Populate binary env
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
"${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh" "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
- name: Build PyTorch binary - name: Build PyTorch binary
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"

View File

@ -56,13 +56,13 @@ jobs:
echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}" echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
# shellcheck disable=SC2129 # shellcheck disable=SC2129
echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}" echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}"
- name: Install conda and dependencies - name: Setup Python
run: | uses: actions/setup-python@v6
# Install conda, setup-miniconda messes with the path that messes with the ruby stuff we do later on with:
curl --retry 3 --retry-all-errors -o "${RUNNER_TEMP}/conda.sh" "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-$(uname -m).sh" # TODO: Removeme once 3.14 is out
chmod +x "${RUNNER_TEMP}/conda.sh" # .4 version is min minor for 3.10, and also no-gil version of 3.13 needs at least 3.13.3
/bin/bash "${RUNNER_TEMP}/conda.sh" -b -p "${RUNNER_TEMP}/anaconda" python-version: "3.10.4"
echo "${RUNNER_TEMP}/anaconda/bin" >> "${GITHUB_PATH}" freethreaded: false
- name: Checkout PyTorch - name: Checkout PyTorch
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
@ -77,13 +77,9 @@ jobs:
working-directory: pytorch working-directory: pytorch
- name: Populate binary env - name: Populate binary env
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
"${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh" "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
- name: Build PyTorch binary - name: Build PyTorch binary
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -99,8 +95,6 @@ jobs:
"${PYTORCH_ROOT}/.ci/wheel/build_wheel.sh" "${PYTORCH_ROOT}/.ci/wheel/build_wheel.sh"
- name: Test PyTorch wheel - name: Test PyTorch wheel
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -111,33 +105,9 @@ jobs:
SMOKE_TEST_PARAMS="" SMOKE_TEST_PARAMS=""
EXTRA_CONDA_INSTALL_FLAGS=""
CONDA_ENV_CREATE_FLAGS=""
# shellcheck disable=SC2153
case $DESIRED_PYTHON in
3.14t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.14)
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.13t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge"
desired_python="3.13"
;;
*)
# shellcheck disable=SC2153
desired_python=${DESIRED_PYTHON}
;;
esac
# shellcheck disable=SC2086 # shellcheck disable=SC2086
conda create -yn "test_conda_env" python="$desired_python" ${CONDA_ENV_CREATE_FLAGS} ${EXTRA_CONDA_INSTALL_FLAGS} python -mvenv test_venv
conda activate test_conda_env source test_venv/bin/activate
pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v
# shellcheck disable=SC2086 # shellcheck disable=SC2086
@ -196,13 +166,13 @@ jobs:
echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}" echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
# shellcheck disable=SC2129 # shellcheck disable=SC2129
echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}" echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}"
- name: Install conda and dependencies - name: Setup Python
run: | uses: actions/setup-python@v6
# Install conda, setup-miniconda messes with the path that messes with the ruby stuff we do later on with:
curl --retry 3 --retry-all-errors -o "${RUNNER_TEMP}/conda.sh" "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-$(uname -m).sh" # TODO: Removeme once 3.14 is out
chmod +x "${RUNNER_TEMP}/conda.sh" # .4 version is min minor for 3.10, and also no-gil version of 3.13 needs at least 3.13.3
/bin/bash "${RUNNER_TEMP}/conda.sh" -b -p "${RUNNER_TEMP}/anaconda" python-version: "3.11.4"
echo "${RUNNER_TEMP}/anaconda/bin" >> "${GITHUB_PATH}" freethreaded: false
- name: Checkout PyTorch - name: Checkout PyTorch
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
@ -217,13 +187,9 @@ jobs:
working-directory: pytorch working-directory: pytorch
- name: Populate binary env - name: Populate binary env
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
"${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh" "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
- name: Build PyTorch binary - name: Build PyTorch binary
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -239,8 +205,6 @@ jobs:
"${PYTORCH_ROOT}/.ci/wheel/build_wheel.sh" "${PYTORCH_ROOT}/.ci/wheel/build_wheel.sh"
- name: Test PyTorch wheel - name: Test PyTorch wheel
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -251,33 +215,9 @@ jobs:
SMOKE_TEST_PARAMS="" SMOKE_TEST_PARAMS=""
EXTRA_CONDA_INSTALL_FLAGS=""
CONDA_ENV_CREATE_FLAGS=""
# shellcheck disable=SC2153
case $DESIRED_PYTHON in
3.14t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.14)
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.13t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge"
desired_python="3.13"
;;
*)
# shellcheck disable=SC2153
desired_python=${DESIRED_PYTHON}
;;
esac
# shellcheck disable=SC2086 # shellcheck disable=SC2086
conda create -yn "test_conda_env" python="$desired_python" ${CONDA_ENV_CREATE_FLAGS} ${EXTRA_CONDA_INSTALL_FLAGS} python -mvenv test_venv
conda activate test_conda_env source test_venv/bin/activate
pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v
# shellcheck disable=SC2086 # shellcheck disable=SC2086
@ -336,13 +276,13 @@ jobs:
echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}" echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
# shellcheck disable=SC2129 # shellcheck disable=SC2129
echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}" echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}"
- name: Install conda and dependencies - name: Setup Python
run: | uses: actions/setup-python@v6
# Install conda, setup-miniconda messes with the path that messes with the ruby stuff we do later on with:
curl --retry 3 --retry-all-errors -o "${RUNNER_TEMP}/conda.sh" "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-$(uname -m).sh" # TODO: Removeme once 3.14 is out
chmod +x "${RUNNER_TEMP}/conda.sh" # .4 version is min minor for 3.10, and also no-gil version of 3.13 needs at least 3.13.3
/bin/bash "${RUNNER_TEMP}/conda.sh" -b -p "${RUNNER_TEMP}/anaconda" python-version: "3.12.4"
echo "${RUNNER_TEMP}/anaconda/bin" >> "${GITHUB_PATH}" freethreaded: false
- name: Checkout PyTorch - name: Checkout PyTorch
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
@ -357,13 +297,9 @@ jobs:
working-directory: pytorch working-directory: pytorch
- name: Populate binary env - name: Populate binary env
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
"${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh" "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
- name: Build PyTorch binary - name: Build PyTorch binary
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -379,8 +315,6 @@ jobs:
"${PYTORCH_ROOT}/.ci/wheel/build_wheel.sh" "${PYTORCH_ROOT}/.ci/wheel/build_wheel.sh"
- name: Test PyTorch wheel - name: Test PyTorch wheel
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -391,33 +325,9 @@ jobs:
SMOKE_TEST_PARAMS="" SMOKE_TEST_PARAMS=""
EXTRA_CONDA_INSTALL_FLAGS=""
CONDA_ENV_CREATE_FLAGS=""
# shellcheck disable=SC2153
case $DESIRED_PYTHON in
3.14t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.14)
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.13t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge"
desired_python="3.13"
;;
*)
# shellcheck disable=SC2153
desired_python=${DESIRED_PYTHON}
;;
esac
# shellcheck disable=SC2086 # shellcheck disable=SC2086
conda create -yn "test_conda_env" python="$desired_python" ${CONDA_ENV_CREATE_FLAGS} ${EXTRA_CONDA_INSTALL_FLAGS} python -mvenv test_venv
conda activate test_conda_env source test_venv/bin/activate
pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v
# shellcheck disable=SC2086 # shellcheck disable=SC2086
@ -476,13 +386,13 @@ jobs:
echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}" echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
# shellcheck disable=SC2129 # shellcheck disable=SC2129
echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}" echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}"
- name: Install conda and dependencies - name: Setup Python
run: | uses: actions/setup-python@v6
# Install conda, setup-miniconda messes with the path that messes with the ruby stuff we do later on with:
curl --retry 3 --retry-all-errors -o "${RUNNER_TEMP}/conda.sh" "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-$(uname -m).sh" # TODO: Removeme once 3.14 is out
chmod +x "${RUNNER_TEMP}/conda.sh" # .4 version is min minor for 3.10, and also no-gil version of 3.13 needs at least 3.13.3
/bin/bash "${RUNNER_TEMP}/conda.sh" -b -p "${RUNNER_TEMP}/anaconda" python-version: "3.13.4"
echo "${RUNNER_TEMP}/anaconda/bin" >> "${GITHUB_PATH}" freethreaded: false
- name: Checkout PyTorch - name: Checkout PyTorch
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
@ -497,13 +407,9 @@ jobs:
working-directory: pytorch working-directory: pytorch
- name: Populate binary env - name: Populate binary env
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
"${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh" "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
- name: Build PyTorch binary - name: Build PyTorch binary
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -519,8 +425,6 @@ jobs:
"${PYTORCH_ROOT}/.ci/wheel/build_wheel.sh" "${PYTORCH_ROOT}/.ci/wheel/build_wheel.sh"
- name: Test PyTorch wheel - name: Test PyTorch wheel
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -531,33 +435,9 @@ jobs:
SMOKE_TEST_PARAMS="" SMOKE_TEST_PARAMS=""
EXTRA_CONDA_INSTALL_FLAGS=""
CONDA_ENV_CREATE_FLAGS=""
# shellcheck disable=SC2153
case $DESIRED_PYTHON in
3.14t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.14)
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.13t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge"
desired_python="3.13"
;;
*)
# shellcheck disable=SC2153
desired_python=${DESIRED_PYTHON}
;;
esac
# shellcheck disable=SC2086 # shellcheck disable=SC2086
conda create -yn "test_conda_env" python="$desired_python" ${CONDA_ENV_CREATE_FLAGS} ${EXTRA_CONDA_INSTALL_FLAGS} python -mvenv test_venv
conda activate test_conda_env source test_venv/bin/activate
pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v
# shellcheck disable=SC2086 # shellcheck disable=SC2086
@ -616,13 +496,13 @@ jobs:
echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}" echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
# shellcheck disable=SC2129 # shellcheck disable=SC2129
echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}" echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}"
- name: Install conda and dependencies - name: Setup Python
run: | uses: actions/setup-python@v6
# Install conda, setup-miniconda messes with the path that messes with the ruby stuff we do later on with:
curl --retry 3 --retry-all-errors -o "${RUNNER_TEMP}/conda.sh" "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-$(uname -m).sh" # TODO: Removeme once 3.14 is out
chmod +x "${RUNNER_TEMP}/conda.sh" # .4 version is min minor for 3.10, and also no-gil version of 3.13 needs at least 3.13.3
/bin/bash "${RUNNER_TEMP}/conda.sh" -b -p "${RUNNER_TEMP}/anaconda" python-version: "3.13.4"
echo "${RUNNER_TEMP}/anaconda/bin" >> "${GITHUB_PATH}" freethreaded: true
- name: Checkout PyTorch - name: Checkout PyTorch
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
@ -637,13 +517,9 @@ jobs:
working-directory: pytorch working-directory: pytorch
- name: Populate binary env - name: Populate binary env
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
"${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh" "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
- name: Build PyTorch binary - name: Build PyTorch binary
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -659,8 +535,6 @@ jobs:
"${PYTORCH_ROOT}/.ci/wheel/build_wheel.sh" "${PYTORCH_ROOT}/.ci/wheel/build_wheel.sh"
- name: Test PyTorch wheel - name: Test PyTorch wheel
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -671,33 +545,9 @@ jobs:
SMOKE_TEST_PARAMS="" SMOKE_TEST_PARAMS=""
EXTRA_CONDA_INSTALL_FLAGS=""
CONDA_ENV_CREATE_FLAGS=""
# shellcheck disable=SC2153
case $DESIRED_PYTHON in
3.14t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.14)
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.13t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge"
desired_python="3.13"
;;
*)
# shellcheck disable=SC2153
desired_python=${DESIRED_PYTHON}
;;
esac
# shellcheck disable=SC2086 # shellcheck disable=SC2086
conda create -yn "test_conda_env" python="$desired_python" ${CONDA_ENV_CREATE_FLAGS} ${EXTRA_CONDA_INSTALL_FLAGS} python -mvenv test_venv
conda activate test_conda_env source test_venv/bin/activate
pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v
# shellcheck disable=SC2086 # shellcheck disable=SC2086
@ -756,13 +606,13 @@ jobs:
echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}" echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
# shellcheck disable=SC2129 # shellcheck disable=SC2129
echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}" echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}"
- name: Install conda and dependencies - name: Setup Python
run: | uses: actions/setup-python@v6
# Install conda, setup-miniconda messes with the path that messes with the ruby stuff we do later on with:
curl --retry 3 --retry-all-errors -o "${RUNNER_TEMP}/conda.sh" "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-$(uname -m).sh" # TODO: Removeme once 3.14 is out
chmod +x "${RUNNER_TEMP}/conda.sh" # .4 version is min minor for 3.10, and also no-gil version of 3.13 needs at least 3.13.3
/bin/bash "${RUNNER_TEMP}/conda.sh" -b -p "${RUNNER_TEMP}/anaconda" python-version: "3.14.0-rc.2"
echo "${RUNNER_TEMP}/anaconda/bin" >> "${GITHUB_PATH}" freethreaded: false
- name: Checkout PyTorch - name: Checkout PyTorch
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
@ -777,13 +627,9 @@ jobs:
working-directory: pytorch working-directory: pytorch
- name: Populate binary env - name: Populate binary env
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
"${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh" "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
- name: Build PyTorch binary - name: Build PyTorch binary
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -799,8 +645,6 @@ jobs:
"${PYTORCH_ROOT}/.ci/wheel/build_wheel.sh" "${PYTORCH_ROOT}/.ci/wheel/build_wheel.sh"
- name: Test PyTorch wheel - name: Test PyTorch wheel
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -811,33 +655,9 @@ jobs:
SMOKE_TEST_PARAMS="" SMOKE_TEST_PARAMS=""
EXTRA_CONDA_INSTALL_FLAGS=""
CONDA_ENV_CREATE_FLAGS=""
# shellcheck disable=SC2153
case $DESIRED_PYTHON in
3.14t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.14)
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.13t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge"
desired_python="3.13"
;;
*)
# shellcheck disable=SC2153
desired_python=${DESIRED_PYTHON}
;;
esac
# shellcheck disable=SC2086 # shellcheck disable=SC2086
conda create -yn "test_conda_env" python="$desired_python" ${CONDA_ENV_CREATE_FLAGS} ${EXTRA_CONDA_INSTALL_FLAGS} python -mvenv test_venv
conda activate test_conda_env source test_venv/bin/activate
pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v
# shellcheck disable=SC2086 # shellcheck disable=SC2086
@ -896,13 +716,13 @@ jobs:
echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}" echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
# shellcheck disable=SC2129 # shellcheck disable=SC2129
echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}" echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}"
- name: Install conda and dependencies - name: Setup Python
run: | uses: actions/setup-python@v6
# Install conda, setup-miniconda messes with the path that messes with the ruby stuff we do later on with:
curl --retry 3 --retry-all-errors -o "${RUNNER_TEMP}/conda.sh" "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-$(uname -m).sh" # TODO: Removeme once 3.14 is out
chmod +x "${RUNNER_TEMP}/conda.sh" # .4 version is min minor for 3.10, and also no-gil version of 3.13 needs at least 3.13.3
/bin/bash "${RUNNER_TEMP}/conda.sh" -b -p "${RUNNER_TEMP}/anaconda" python-version: "3.14.0-rc.2"
echo "${RUNNER_TEMP}/anaconda/bin" >> "${GITHUB_PATH}" freethreaded: true
- name: Checkout PyTorch - name: Checkout PyTorch
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
@ -917,13 +737,9 @@ jobs:
working-directory: pytorch working-directory: pytorch
- name: Populate binary env - name: Populate binary env
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
"${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh" "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
- name: Build PyTorch binary - name: Build PyTorch binary
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -939,8 +755,6 @@ jobs:
"${PYTORCH_ROOT}/.ci/wheel/build_wheel.sh" "${PYTORCH_ROOT}/.ci/wheel/build_wheel.sh"
- name: Test PyTorch wheel - name: Test PyTorch wheel
run: | run: |
# shellcheck disable=SC1091
source "${RUNNER_TEMP}/anaconda/bin/activate"
set -eux -o pipefail set -eux -o pipefail
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BINARY_ENV_FILE:-/Users/distiller/project/env}" source "${BINARY_ENV_FILE:-/Users/distiller/project/env}"
@ -951,33 +765,9 @@ jobs:
SMOKE_TEST_PARAMS="" SMOKE_TEST_PARAMS=""
EXTRA_CONDA_INSTALL_FLAGS=""
CONDA_ENV_CREATE_FLAGS=""
# shellcheck disable=SC2153
case $DESIRED_PYTHON in
3.14t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.14)
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge/label/python_rc -c conda-forge"
desired_python="3.14.0rc1"
;;
3.13t)
CONDA_ENV_CREATE_FLAGS="python-freethreading"
EXTRA_CONDA_INSTALL_FLAGS="-c conda-forge"
desired_python="3.13"
;;
*)
# shellcheck disable=SC2153
desired_python=${DESIRED_PYTHON}
;;
esac
# shellcheck disable=SC2086 # shellcheck disable=SC2086
conda create -yn "test_conda_env" python="$desired_python" ${CONDA_ENV_CREATE_FLAGS} ${EXTRA_CONDA_INSTALL_FLAGS} python -mvenv test_venv
conda activate test_conda_env source test_venv/bin/activate
pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v pip install "$PYTORCH_FINAL_PACKAGE_DIR"/*.whl numpy -v
# shellcheck disable=SC2086 # shellcheck disable=SC2086

View File

@ -73,6 +73,8 @@ def check_file(
binary, binary,
"-ignore", "-ignore",
'"runs-on" section must be sequence node but got mapping node with "!!map" tag', '"runs-on" section must be sequence node but got mapping node with "!!map" tag',
"-ignore",
'input "freethreaded" is not defined in action "actions/setup-python@v',
file, file,
] ]
) )