From a30b258ae01cee49b1bb47cd072ef90686a92dce Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Tue, 26 Jul 2022 11:15:05 +0100 Subject: [PATCH] python3 only when available Signed-off-by: Eli Uriegas --- packaging/pkg_helpers.bash | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packaging/pkg_helpers.bash b/packaging/pkg_helpers.bash index 2ca3a067519..88b3d910270 100644 --- a/packaging/pkg_helpers.bash +++ b/packaging/pkg_helpers.bash @@ -221,8 +221,13 @@ setup_pip_pytorch_version() { setup_conda_pytorch_constraint() { if [[ -z "$PYTORCH_VERSION" ]]; then export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c pytorch-nightly -c pytorch" + PYTHON="python" + # Check if we have python 3 instead and prefer that + if python3 --version >/dev/null 2>/dev/null; then + PYTHON="python3" + fi export PYTORCH_VERSION="$(conda search --json 'pytorch[channel=pytorch-nightly]' | \ - python3 -c "import os, sys, json, re; cuver = os.environ.get('CU_VERSION'); \ + ${PYTHON} -c "import os, sys, json, re; cuver = os.environ.get('CU_VERSION'); \ cuver_1 = cuver.replace('cu', 'cuda') if cuver != 'cpu' else cuver; \ cuver_2 = (cuver[:-1] + '.' + cuver[-1]).replace('cu', 'cuda') if cuver != 'cpu' else cuver; \ print(re.sub(r'\\+.*$', '', \