3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/python-modules/torchvision/prefetch.sh

38 lines
1.2 KiB
Bash
Raw Normal View History

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix-prefetch-scripts
2021-08-27 08:52:40 +01:00
set -eou pipefail
2021-08-27 08:52:40 +01:00
version=$1
bucket="https://download.pytorch.org/whl/cu113"
2021-08-27 08:52:40 +01:00
url_and_key_list=(
"x86_64-linux-37 $bucket/torchvision-${version}%2Bcu113-cp37-cp37m-linux_x86_64.whl torchvision-${version}-cp37-cp37m-linux_x86_64.whl"
"x86_64-linux-38 $bucket/torchvision-${version}%2Bcu113-cp38-cp38-linux_x86_64.whl torchvision-${version}-cp38-cp38-linux_x86_64.whl"
"x86_64-linux-39 $bucket/torchvision-${version}%2Bcu113-cp39-cp39-linux_x86_64.whl torchvision-${version}-cp39-cp39-linux_x86_64.whl"
2021-08-27 08:52:40 +01:00
)
hashfile="binary-hashes-$version.nix"
2021-08-27 08:52:40 +01:00
echo " \"$version\" = {" >> $hashfile
for url_and_key in "${url_and_key_list[@]}"; do
key=$(echo "$url_and_key" | cut -d' ' -f1)
url=$(echo "$url_and_key" | cut -d' ' -f2)
name=$(echo "$url_and_key" | cut -d' ' -f3)
echo "prefetching ${url}..."
2021-09-14 05:33:32 +01:00
hash=$(nix hash to-sri --type sha256 `nix-prefetch-url "$url" --name "$name"`)
2021-08-27 08:52:40 +01:00
echo " $key = {" >> $hashfile
echo " name = \"$name\";" >> $hashfile
echo " url = \"$url\";" >> $hashfile
2021-09-14 05:33:32 +01:00
echo " hash = \"$hash\";" >> $hashfile
2021-08-27 08:52:40 +01:00
echo " };" >> $hashfile
echo
done
echo " };" >> $hashfile
echo "done."