Skip to content

Commit e43b523

Browse files
committed
Build py3.15 wheels against the manylinux python.org interpreter (not conda)
Python 3.15 is still in pre-release and its C-API/ABI is not frozen. conda-forge's python=3.15.0a* does not match the python.org alpha that the torch nightly cp315 wheels are built against, so importing torch under a conda 3.15 interpreter segfaults during module init (observed as 'python setup.py clean' crashing with SIGSEGV / exit 139 in the torchvision and torchaudio cp315 builds). For 3.15/3.15t, skip conda and build against the manylinux python.org interpreter that produced the torch wheels (/opt/python/cp315-cp315[t]). pkg-helpers already prepends that interpreter's bin to PATH via BUILD_ENV_FILE, so setting CONDA_RUN='' makes the whole build and smoke test resolve to it -- no ABI skew. Build tooling (cmake/ninja/wheel) is pip installed; libpng/libjpeg/libwebp/pkg-config come from the manylinux image's system packages. All other Python versions keep the conda path.
1 parent 13a750a commit e43b523

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

.github/actions/setup-binary-builds/action.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,56 @@ runs:
129129
set -euxo pipefail
130130
CONDA_ENV="${RUNNER_TEMP}/conda_environment_${GITHUB_RUN_ID}"
131131
export CONDA_EXTRA_PARAM=""
132+
133+
# Python 3.15 is still in pre-release and its C-API/ABI is not frozen.
134+
# conda-forge's python=3.15.0a* does not match the python.org alpha the
135+
# torch nightly cp315 wheels are built against, so importing torch under
136+
# the conda interpreter segfaults during module init. Build against the
137+
# manylinux python.org interpreter that produced the torch wheels
138+
# instead of conda. pkg-helpers already prepends /opt/python/<abi>/bin
139+
# to PATH via BUILD_ENV_FILE, so an empty CONDA_RUN makes every
140+
# `${CONDA_RUN} python|pip` in the build resolve to that interpreter --
141+
# no ABI skew. We only install the build tooling conda used to provide.
142+
case $PYTHON_VERSION in
143+
3.15) MANYLINUX_PYTHON=/opt/python/cp315-cp315/bin/python ;;
144+
3.15t) MANYLINUX_PYTHON=/opt/python/cp315-cp315t/bin/python ;;
145+
*) MANYLINUX_PYTHON="" ;;
146+
esac
147+
148+
if [ -n "${MANYLINUX_PYTHON}" ]; then
149+
if [ ! -x "${MANYLINUX_PYTHON}" ]; then
150+
echo "::error::Expected manylinux interpreter ${MANYLINUX_PYTHON} not found in build image"
151+
exit 1
152+
fi
153+
# Upgrade setuptools too: the cp315 manylinux interpreter ships an
154+
# old setuptools that can't parse PEP 639 SPDX license metadata
155+
# (e.g. license = "MIT-CMU"), which breaks building sdists such as
156+
# pillow (a torchvision smoke-test dependency with no cp315 wheel
157+
# yet, so pip falls back to building it from source).
158+
"${MANYLINUX_PYTHON}" -m pip install --upgrade pip setuptools
159+
# Build tooling that conda used to provide. PyPI's ninja versioning
160+
# differs from conda's (no 1.12.x on PyPI), so pin to the nearest
161+
# available release. (libpng/libjpeg/libwebp/pkg-config come from the
162+
# manylinux image's system packages rather than conda.)
163+
"${MANYLINUX_PYTHON}" -m pip install \
164+
"cmake==3.31.2" \
165+
"ninja==1.13.0" \
166+
"wheel==0.37.1"
167+
echo "CONDA_ENV=$(dirname "$(dirname "${MANYLINUX_PYTHON}")")" >> "${GITHUB_ENV}"
168+
echo "CONDA_RUN=" >> "${GITHUB_ENV}"
169+
# Some domains install native build deps (e.g. libheif/libavif for
170+
# torchvision-extra-decoders) via `conda install` in their pre-build
171+
# script and locate them through $CONDA_PREFIX. The conda path sets
172+
# CONDA_PREFIX by activating the build env; the manylinux path has no
173+
# such env, so those deps land in the conda *base* prefix while
174+
# CONDA_PREFIX stays unset and the build can't find the headers.
175+
# Export the base prefix so the pre-build `conda install`, setup.py's
176+
# $CONDA_PREFIX/include header search, and the post-build
177+
# $CONDA_PREFIX/lib bundling all resolve to the same place.
178+
echo "CONDA_PREFIX=$(conda info --base)" >> "${GITHUB_ENV}"
179+
exit 0
180+
fi
181+
132182
conda install -y conda=25.3.0
133183
134184
# shellcheck disable=SC2153

0 commit comments

Comments
 (0)