about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/torchvision/prefetch.sh
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/python-modules/torchvision/prefetch.sh')
-rwxr-xr-xnixpkgs/pkgs/development/python-modules/torchvision/prefetch.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/python-modules/torchvision/prefetch.sh b/nixpkgs/pkgs/development/python-modules/torchvision/prefetch.sh
new file mode 100755
index 000000000000..686d1b3e6200
--- /dev/null
+++ b/nixpkgs/pkgs/development/python-modules/torchvision/prefetch.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p nix-prefetch-scripts
+
+set -eou pipefail
+
+version=$1
+
+bucket="https://download.pytorch.org/whl/cu113"
+
+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"
+)
+
+hashfile="binary-hashes-$version.nix"
+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}..."
+  hash=$(nix hash to-sri --type sha256 `nix-prefetch-url "$url" --name "$name"`)
+
+  echo "    $key = {" >> $hashfile
+  echo "      name = \"$name\";" >> $hashfile
+  echo "      url = \"$url\";" >> $hashfile
+  echo "      hash = \"$hash\";" >> $hashfile
+  echo "    };" >> $hashfile
+
+  echo
+done
+
+echo "  };" >> $hashfile
+echo "done."