Skip to content

Commit 4a4cab0

Browse files
committed
Fix Python 3.15 validation on Windows and macOS
Now that 3.15/3.15t are in the default matrix on every OS (#8427), the uv-based interpreter setup runs on Windows and macOS for the first time and breaks in three places: 1. Windows: uv lays a venv out as Scripts/, not bin/, so `source ${ENV_NAME}/bin/activate` failed outright with "conda-env-<id>/bin/activate: No such file or directory". 2. macOS: the macos-arm64 workaround prepends ${CONDA_PREFIX}/bin to PATH. On the uv path no conda env was activated, so CONDA_PREFIX still pointed at base (python 3.14) and shadowed the venv's python3/pip3 -- the run installed and smoke-tested torch under conda base 3.14 instead of 3.15. 3. Cleanup: ENV_NAME is a conda env name on the conda path but a venv directory on the uv path, so `conda env remove -n` fails with EnvironmentLocationNotFound and, under set -e, fails the job after the tests have already passed. The conda path for 3.10-3.14t is unchanged.
1 parent fc982f6 commit 4a4cab0

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

.github/scripts/validate_binaries.sh

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,23 @@ test_cuda_device() {
215215
fi
216216
}
217217

218-
# Cleanup conda environment
218+
# Cleanup the environment created for this run.
219+
#
220+
# ENV_NAME is a conda env name on the conda path but a venv *directory* on the
221+
# uv path, so `conda env remove -n` would fail with EnvironmentLocationNotFound
222+
# and, under `set -e`, fail the whole job after the tests had already passed.
219223
cleanup_conda_env() {
220224
if [[ ${TARGET_OS} != linux* ]]; then
221-
conda deactivate
222-
conda env remove -n "${ENV_NAME}"
225+
if [[ ${USING_UV_VENV} == 'yes' ]]; then
226+
# `deactivate` is a function defined by the venv activate script.
227+
if declare -F deactivate > /dev/null; then
228+
deactivate
229+
fi
230+
rm -rf "${ENV_NAME}"
231+
else
232+
conda deactivate
233+
conda env remove -n "${ENV_NAME}"
234+
fi
223235
fi
224236
}
225237

@@ -316,15 +328,22 @@ fi
316328
# the matching 3.15.0b1 interpreter with uv (from python-build-standalone)
317329
# instead of conda. A --seed venv provides pip so the rest of the flow (pip3
318330
# install, smoke tests) is unchanged.
331+
USING_UV_VENV="no"
319332
if [[ ${MATRIX_PYTHON_VERSION} == "3.15" || ${MATRIX_PYTHON_VERSION} == "3.15t" ]]; then
333+
USING_UV_VENV="yes"
320334
UV_PYTHON="3.15.0b1"
321335
if [[ ${MATRIX_PYTHON_VERSION} == "3.15t" ]]; then
322336
UV_PYTHON="3.15.0b1+freethreaded"
323337
fi
324338
curl -LsSf https://astral.sh/uv/install.sh | sh
325339
source "${HOME}/.local/bin/env"
326340
uv venv --seed --python "${UV_PYTHON}" "${ENV_NAME}"
327-
source "${ENV_NAME}/bin/activate"
341+
# uv lays the venv out the platform way: Scripts/ on Windows, bin/ elsewhere.
342+
if [[ ${TARGET_OS} == 'windows' ]]; then
343+
source "${ENV_NAME}/Scripts/activate"
344+
else
345+
source "${ENV_NAME}/bin/activate"
346+
fi
328347
else
329348
update_conda
330349
get_python_config
@@ -334,7 +353,11 @@ fi
334353

335354
# Save original PATH for macos-arm64 workaround
336355
export OLD_PATH=${PATH}
337-
if [[ ${TARGET_OS} == 'macos-arm64' ]]; then
356+
# This promotes the *conda* env's bin to the front of PATH. On the uv path there
357+
# is no conda env to promote: CONDA_PREFIX still points at base (python 3.14),
358+
# so prepending it shadows the venv's python3/pip3 and the run would install and
359+
# validate the wrong interpreter instead of 3.15.
360+
if [[ ${TARGET_OS} == 'macos-arm64' && ${USING_UV_VENV} == 'no' ]]; then
338361
export PATH="${CONDA_PREFIX}/bin:${PATH}"
339362
fi
340363

0 commit comments

Comments
 (0)