@@ -60,39 +60,44 @@ install_pytorch_and_domains() {
60
60
# Fetch the target commit
61
61
pushd pytorch || return
62
62
git checkout " ${TORCH_VERSION} "
63
- git submodule update --init --recursive
64
63
65
- SYSTEM_NAME =$( uname)
66
- if [[ " ${SYSTEM_NAME } " == " Darwin" ]]; then
67
- PLATFORM =$( python -c ' import sysconfig; import platform; v=platform.mac_ver()[0].split(".")[0]; platform=sysconfig.get_platform().split("-"); platform[1]=f"{v}_0"; print("_".join(platform))' )
64
+ local system_name =$( uname)
65
+ if [[ " ${system_name } " == " Darwin" ]]; then
66
+ local platform =$( python -c ' import sysconfig; import platform; v=platform.mac_ver()[0].split(".")[0]; platform=sysconfig.get_platform().split("-"); platform[1]=f"{v}_0"; print("_".join(platform))' )
68
67
fi
69
- PYTHON_VERSION =$( python -c ' import platform; v=platform.python_version_tuple(); print(f"{v[0]}{v[1]}")' )
70
- TORCH_RELEASE =$( cat version.txt)
71
- TORCH_SHORT_HASH =${TORCH_VERSION: 0: 7}
72
- TORCH_WHEEL_PATH =" cached_artifacts/pytorch/executorch/pytorch_wheels/${SYSTEM_NAME } /${PYTHON_VERSION } "
73
- TORCH_WHEEL_NAME =" torch-${TORCH_RELEASE } %2Bgit${TORCH_SHORT_HASH } -cp${PYTHON_VERSION } -cp${PYTHON_VERSION } -${PLATFORM :- } .whl"
68
+ local python_version =$( python -c ' import platform; v=platform.python_version_tuple(); print(f"{v[0]}{v[1]}")' )
69
+ local torch_release =$( cat version.txt)
70
+ local torch_short_hash =${TORCH_VERSION: 0: 7}
71
+ local torch_wheel_path =" cached_artifacts/pytorch/executorch/pytorch_wheels/${system_name } /${python_version } "
72
+ local torch_wheel_name =" torch-${torch_release } %2Bgit${torch_short_hash } -cp${python_version } -cp${python_version } -${platform :- } .whl"
74
73
75
- CACHE_TORCH_WHEEL =" https://gha-artifacts.s3.us-east-1.amazonaws.com/${TORCH_WHEEL_PATH } /${TORCH_WHEEL_NAME } "
74
+ local cached_torch_wheel =" https://gha-artifacts.s3.us-east-1.amazonaws.com/${torch_wheel_path } /${torch_wheel_name } "
76
75
# Cache PyTorch wheel is only needed on MacOS, Linux CI already has this as part
77
76
# of the Docker image
78
- if [[ " ${SYSTEM_NAME} " == " Darwin" ]]; then
79
- pip install " ${CACHE_TORCH_WHEEL} " || TORCH_WHEEL_NOT_FOUND=1
77
+ if [[ " ${system_name} " == " Darwin" ]]; then
78
+ pip install " ${cached_torch_wheel} " || TORCH_WHEEL_NOT_FOUND=1
79
+ else
80
+ TORCH_WHEEL_NOT_FOUND=1
80
81
fi
81
82
82
83
# Found no such wheel, we will build it from source then
83
84
if [[ " ${TORCH_WHEEL_NOT_FOUND:- 0} " == " 1" ]]; then
85
+ echo " No cached wheel found, continue with building PyTorch at ${TORCH_VERSION} "
86
+
87
+ git submodule update --init --recursive
84
88
USE_DISTRIBUTED=1 python setup.py bdist_wheel
85
89
pip install " $( echo dist/* .whl) "
86
90
87
91
# Only AWS runners have access to S3
88
92
if command -v aws && [[ -z " ${GITHUB_RUNNER:- } " ]]; then
89
- for WHEEL_PATH in dist/* .whl; do
90
- WHEEL_NAME=$( basename " ${WHEEL_PATH} " )
91
- aws s3 cp " ${WHEEL_PATH} " " s3://gha-artifacts/${TORCH_WHEEL_PATH} /${WHEEL_NAME} "
93
+ for wheel_path in dist/* .whl; do
94
+ local wheel_name=$( basename " ${wheel_path} " )
95
+ echo " Caching ${wheel_name} "
96
+ aws s3 cp " ${wheel_path} " " s3://gha-artifacts/${torch_wheel_path} /${wheel_name} "
92
97
done
93
98
fi
94
99
else
95
- echo " Use cached wheel at ${CACHE_TORCH_WHEEL } "
100
+ echo " Use cached wheel at ${cached_torch_wheel } "
96
101
fi
97
102
98
103
# Grab the pinned audio and vision commits from PyTorch
0 commit comments