Skip to content

Commit 7811c69

Browse files
authored
Build PyTorch wheel via PEP 517 instead of setup.py (#21562)
Recent PyTorch nightlies removed `python setup.py bdist_wheel`; PyTorch now builds through scikit-build-core via the standard PEP 517 interface. Build the wheel with `python -m build --wheel --no-isolation` so the CI docker image can pick up newer nightlies. No isolation keeps the build against the image's own numpy and toolchain and lets it reuse sccache, so the build requirements are installed explicitly. The wheel still lands in dist/, so the install step is unchanged.
1 parent 35c7297 commit 7811c69

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

.ci/docker/common/install_pytorch.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,18 @@ install_pytorch_and_domains() {
4949
export MAX_JOBS="${PYTORCH_BUILD_MAX_JOBS}"
5050
fi
5151
configure_pytorch_compiler
52-
# Then build and install PyTorch
53-
conda_run python setup.py bdist_wheel
52+
# PyTorch no longer supports "python setup.py bdist_wheel"; it now builds
53+
# through scikit-build-core (PEP 517). Build the wheel with the standard
54+
# frontend and keep build isolation off, so PyTorch builds against this
55+
# environment's numpy and toolchain (avoids an ABI mismatch) and reuses
56+
# sccache. With isolation off the frontend does not fetch the PEP 517 build
57+
# requirements, so install the ones not already in the image here. Keep in
58+
# sync with pytorch/pyproject.toml [build-system].requires.
59+
# cmake stays below 4 because the wheel lands on PATH ahead of the image's
60+
# cmake 3.x, so every later build in the image would jump a major version.
61+
conda_run pip install build "scikit-build-core>=1.0" "setuptools>=77.0.0,<82" \
62+
"cmake>=3.27,<4" ninja "packaging>=24.2" "typing-extensions>=4.10.0" pyyaml six
63+
conda_run python -m build --wheel --no-isolation
5464
pip_install "$(echo dist/*.whl)"
5565

5666
# Grab the pinned audio and vision commits from PyTorch

0 commit comments

Comments
 (0)