Skip to content

Commit

Permalink
python3 only when available
Browse files Browse the repository at this point in the history
Signed-off-by: Eli Uriegas <eliuriegas@fb.com>
  • Loading branch information
seemethere committed Jul 26, 2022
1 parent 6e2edb1 commit bf7e6a6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packaging/pkg_helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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'\\+.*$', '', \
Expand Down

0 comments on commit bf7e6a6

Please sign in to comment.