Skip to content

Commit a30b258

Browse files
committed
python3 only when available
Signed-off-by: Eli Uriegas <[email protected]>
1 parent 6e2edb1 commit a30b258

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packaging/pkg_helpers.bash

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,13 @@ setup_pip_pytorch_version() {
221221
setup_conda_pytorch_constraint() {
222222
if [[ -z "$PYTORCH_VERSION" ]]; then
223223
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c pytorch-nightly -c pytorch"
224+
PYTHON="python"
225+
# Check if we have python 3 instead and prefer that
226+
if python3 --version >/dev/null 2>/dev/null; then
227+
PYTHON="python3"
228+
fi
224229
export PYTORCH_VERSION="$(conda search --json 'pytorch[channel=pytorch-nightly]' | \
225-
python3 -c "import os, sys, json, re; cuver = os.environ.get('CU_VERSION'); \
230+
${PYTHON} -c "import os, sys, json, re; cuver = os.environ.get('CU_VERSION'); \
226231
cuver_1 = cuver.replace('cu', 'cuda') if cuver != 'cpu' else cuver; \
227232
cuver_2 = (cuver[:-1] + '.' + cuver[-1]).replace('cu', 'cuda') if cuver != 'cpu' else cuver; \
228233
print(re.sub(r'\\+.*$', '', \

0 commit comments

Comments
 (0)