1#!/usr/bin/env nix-shell
2#!nix-shell -i bash -p nix-prefetch-scripts
3
4set -eou pipefail
5
6version=$1
7
8bucket="https://download.pytorch.org/whl/cu113"
9
10url_and_key_list=(
11 "x86_64-linux-37 $bucket/torchvision-${version}%2Bcu113-cp37-cp37m-linux_x86_64.whl torchvision-${version}-cp37-cp37m-linux_x86_64.whl"
12 "x86_64-linux-38 $bucket/torchvision-${version}%2Bcu113-cp38-cp38-linux_x86_64.whl torchvision-${version}-cp38-cp38-linux_x86_64.whl"
13 "x86_64-linux-39 $bucket/torchvision-${version}%2Bcu113-cp39-cp39-linux_x86_64.whl torchvision-${version}-cp39-cp39-linux_x86_64.whl"
14)
15
16hashfile="binary-hashes-$version.nix"
17echo " \"$version\" = {" >> $hashfile
18
19for url_and_key in "${url_and_key_list[@]}"; do
20 key=$(echo "$url_and_key" | cut -d' ' -f1)
21 url=$(echo "$url_and_key" | cut -d' ' -f2)
22 name=$(echo "$url_and_key" | cut -d' ' -f3)
23
24 echo "prefetching ${url}..."
25 hash=$(nix hash to-sri --type sha256 `nix-prefetch-url "$url" --name "$name"`)
26
27 echo " $key = {" >> $hashfile
28 echo " name = \"$name\";" >> $hashfile
29 echo " url = \"$url\";" >> $hashfile
30 echo " hash = \"$hash\";" >> $hashfile
31 echo " };" >> $hashfile
32
33 echo
34done
35
36echo " };" >> $hashfile
37echo "done."