Skip to content

Commit

Permalink
[BE] Unify version computation (pytorch#6117)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
malfet authored and atalman committed Jun 14, 2022
1 parent 99f36bc commit f081cf9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/build-m1-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ jobs:
run: |
. ~/miniconda3/etc/profile.d/conda.sh
set -ex
export BUILD_VERSION=0.14.0.dev$(date "+%Y%m%d")
. packaging/pkg_helpers.bash
setup_build_version
WHL_NAME=torchvision-${BUILD_VERSION}-cp${PY_VERS/.}-cp${PY_VERS/.}-macosx_11_0_arm64.whl
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy libpng openjpeg wheel pkg-config
conda run -p ${ENV_NAME} python3 -mpip install torch --extra-index-url=https://download.pytorch.org/whl/nightly
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/nightly
conda run -p ${ENV_NAME} python3 -mpip install delocate
conda run -p ${ENV_NAME} python3 setup.py bdist_wheel
export PYTORCH_VERSION="$(conda run -p ${ENV_NAME} python3 -mpip show torch | grep ^Version: | sed 's/Version: *//')"
conda run -p ${ENV_NAME} DYLD_FALLBACK_LIBRARY_PATH="${ENV_NAME}/lib" delocate-wheel -v --ignore-missing-dependencies dist/${WHL_NAME}
conda env remove -p ${ENV_NAME}
- name: Test wheel
Expand All @@ -42,7 +44,7 @@ jobs:
. ~/miniconda3/etc/profile.d/conda.sh
set -ex
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy
conda run -p ${ENV_NAME} python3 -mpip install torch --extra-index-url=https://download.pytorch.org/whl/nightly
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/nightly
conda run -p ${ENV_NAME} python3 -mpip install dist/*.whl
# Test torch is importable, by changing cwd and running import commands
conda run --cwd /tmp -p ${ENV_NAME} python3 -c "import torchvision;print('torchvision version is ', torchvision.__version__)"
Expand Down
2 changes: 1 addition & 1 deletion packaging/build_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
. "$script_dir/pkg_helpers.bash"

export BUILD_TYPE=conda
setup_env 0.13.0
setup_env
export SOURCE_ROOT_DIR="$PWD"
setup_conda_pytorch_constraint
setup_conda_cudatoolkit_plain_constraint
Expand Down
2 changes: 1 addition & 1 deletion packaging/build_conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
. "$script_dir/pkg_helpers.bash"

export BUILD_TYPE=conda
setup_env 0.13.0
setup_env
export SOURCE_ROOT_DIR="$PWD"
setup_conda_pytorch_constraint
setup_conda_cudatoolkit_constraint
Expand Down
2 changes: 1 addition & 1 deletion packaging/build_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
. "$script_dir/pkg_helpers.bash"

export BUILD_TYPE=wheel
setup_env 0.13.0
setup_env
setup_wheel_python
pip_install numpy pyyaml future ninja
pip_install --upgrade setuptools
Expand Down
10 changes: 9 additions & 1 deletion packaging/pkg_helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,15 @@ setup_cuda() {
# Usage: setup_build_version 0.2.0
setup_build_version() {
if [[ -z "$BUILD_VERSION" ]]; then
export BUILD_VERSION="$1.dev$(date "+%Y%m%d")$VERSION_SUFFIX"
if [[ -z "$1" ]]; then
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# version.txt for some reason has `a` character after major.minor.rev
# command below yields 0.10.0 from version.txt containing 0.10.0a0
_VERSION_BASE=$( cut -f 1 -d a "$SCRIPT_DIR/../version.txt" )
else
_VERSION_BASE="$1"
fi
export BUILD_VERSION="$_VERSION_BASE.dev$(date "+%Y%m%d")$VERSION_SUFFIX"
else
export BUILD_VERSION="$BUILD_VERSION$VERSION_SUFFIX"
fi
Expand Down

0 comments on commit f081cf9

Please sign in to comment.