daml/dev-env/bin/da-update-python-srcs
Digital Asset GmbH 05e691f558 open-sourcing daml
2019-04-04 09:33:38 +01:00

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 ']'