3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/tools/poetry2nix/poetry2nix/fetch-from-pypi.sh
2021-06-01 16:59:39 -05:00

25 lines
655 B
Bash

source $stdenv/setup
set -euo pipefail
curl="curl \
--location \
--max-redirs 20 \
--retry 2 \
--disable-epsv \
--cookie-jar cookies \
--insecure \
--speed-time 5 \
--progress-bar \
--fail \
$curlOpts \
$NIX_CURL_FLAGS"
echo "Trying to fetch with predicted URL: $predictedURL"
$curl $predictedURL --output $out && exit 0
echo "Predicted URL '$predictedURL' failed, querying pypi.org"
$curl "https://pypi.org/pypi/$pname/json" | jq -r ".releases.\"$version\"[] | select(.filename == \"$file\") | .url" > url
url=$(cat url)
$curl -k $url --output $out