Skip to content

Commit f081cf9

Browse files
malfetatalman
authored andcommitted
[BE] Unify version computation (pytorch#6117)
* [BE] Unify version computation Instead of hardcoding dev version in various script, use one from `version.txt` if `setup_build_version` is called without arguments Also, pass `--pre` option to M1 build/test pip install commands to build TorchVision against nightly pytorch * Pin torchvision dependency to a specific pytorch version
1 parent 99f36bc commit f081cf9

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

.github/workflows/build-m1-binaries.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ jobs:
2525
run: |
2626
. ~/miniconda3/etc/profile.d/conda.sh
2727
set -ex
28-
export BUILD_VERSION=0.14.0.dev$(date "+%Y%m%d")
28+
. packaging/pkg_helpers.bash
29+
setup_build_version
2930
WHL_NAME=torchvision-${BUILD_VERSION}-cp${PY_VERS/.}-cp${PY_VERS/.}-macosx_11_0_arm64.whl
3031
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy libpng openjpeg wheel pkg-config
31-
conda run -p ${ENV_NAME} python3 -mpip install torch --extra-index-url=https://download.pytorch.org/whl/nightly
32+
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/nightly
3233
conda run -p ${ENV_NAME} python3 -mpip install delocate
3334
conda run -p ${ENV_NAME} python3 setup.py bdist_wheel
35+
export PYTORCH_VERSION="$(conda run -p ${ENV_NAME} python3 -mpip show torch | grep ^Version: | sed 's/Version: *//')"
3436
conda run -p ${ENV_NAME} DYLD_FALLBACK_LIBRARY_PATH="${ENV_NAME}/lib" delocate-wheel -v --ignore-missing-dependencies dist/${WHL_NAME}
3537
conda env remove -p ${ENV_NAME}
3638
- name: Test wheel
@@ -42,7 +44,7 @@ jobs:
4244
. ~/miniconda3/etc/profile.d/conda.sh
4345
set -ex
4446
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy
45-
conda run -p ${ENV_NAME} python3 -mpip install torch --extra-index-url=https://download.pytorch.org/whl/nightly
47+
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/nightly
4648
conda run -p ${ENV_NAME} python3 -mpip install dist/*.whl
4749
# Test torch is importable, by changing cwd and running import commands
4850
conda run --cwd /tmp -p ${ENV_NAME} python3 -c "import torchvision;print('torchvision version is ', torchvision.__version__)"

packaging/build_cmake.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1515
. "$script_dir/pkg_helpers.bash"
1616

1717
export BUILD_TYPE=conda
18-
setup_env 0.13.0
18+
setup_env
1919
export SOURCE_ROOT_DIR="$PWD"
2020
setup_conda_pytorch_constraint
2121
setup_conda_cudatoolkit_plain_constraint

packaging/build_conda.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
55
. "$script_dir/pkg_helpers.bash"
66

77
export BUILD_TYPE=conda
8-
setup_env 0.13.0
8+
setup_env
99
export SOURCE_ROOT_DIR="$PWD"
1010
setup_conda_pytorch_constraint
1111
setup_conda_cudatoolkit_constraint

packaging/build_wheel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
55
. "$script_dir/pkg_helpers.bash"
66

77
export BUILD_TYPE=wheel
8-
setup_env 0.13.0
8+
setup_env
99
setup_wheel_python
1010
pip_install numpy pyyaml future ninja
1111
pip_install --upgrade setuptools

packaging/pkg_helpers.bash

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,15 @@ setup_cuda() {
100100
# Usage: setup_build_version 0.2.0
101101
setup_build_version() {
102102
if [[ -z "$BUILD_VERSION" ]]; then
103-
export BUILD_VERSION="$1.dev$(date "+%Y%m%d")$VERSION_SUFFIX"
103+
if [[ -z "$1" ]]; then
104+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
105+
# version.txt for some reason has `a` character after major.minor.rev
106+
# command below yields 0.10.0 from version.txt containing 0.10.0a0
107+
_VERSION_BASE=$( cut -f 1 -d a "$SCRIPT_DIR/../version.txt" )
108+
else
109+
_VERSION_BASE="$1"
110+
fi
111+
export BUILD_VERSION="$_VERSION_BASE.dev$(date "+%Y%m%d")$VERSION_SUFFIX"
104112
else
105113
export BUILD_VERSION="$BUILD_VERSION$VERSION_SUFFIX"
106114
fi

0 commit comments

Comments
 (0)