mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
43 lines
987 B
Bash
Executable File
43 lines
987 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -Eeuo pipefail
|
|
|
|
if [[ $# -eq 0 ]]; then
|
|
>&2 cat <<EOF
|
|
usage: $(basename $0) package-name...
|
|
|
|
This script will use Pip to download wheels for the Python packages
|
|
given as command line arguments, including all dependencies.
|
|
|
|
A Nix expression is then produced on stdout. The expression will
|
|
download the same wheels as Pip downloaded.
|
|
|
|
EOF
|
|
exit 1
|
|
fi
|
|
|
|
DOWNLOAD_DIR=$(mktemp -d)
|
|
trap "rm -rf $DOWNLOAD_DIR" EXIT
|
|
|
|
for PKG in "$@"; do
|
|
>&2 echo "- downloading $PKG and its dependencies..."
|
|
>&2 pip3 download --dest $DOWNLOAD_DIR --only-binary :all: $PKG
|
|
done
|
|
|
|
echo '{ python3Packages }: ['
|
|
for whl in $DOWNLOAD_DIR/*.whl; do
|
|
>&2 echo "- processing $whl"
|
|
IFS=- read pname version python rest <<<"$(basename $whl)"
|
|
sha256=$(sha256sum $whl | cut -d ' ' -f 1)
|
|
cat <<EOF
|
|
(python3Packages.fetchPypi {
|
|
pname = "$pname";
|
|
version = "$version";
|
|
format = "wheel";
|
|
python = "$python";
|
|
sha256 = "$sha256";
|
|
})
|
|
EOF
|
|
done
|
|
echo ']'
|