diff --git a/bin/pip-install-deps b/bin/pip-install-deps new file mode 100755 index 0000000..806ffec --- /dev/null +++ b/bin/pip-install-deps @@ -0,0 +1,22 @@ +#!/bin/bash + +LS_DEPS="bin/pip-ls-deps" +if ! [ -x "$LS_DEPS" ] ; then + echo "pip-install-deps should be run from the root of swh-environment. Bye." + exit 2 +fi + +if [ "$1" = '-h' -o "$1" = '--help' ] ; then + echo "Usage: bin/pip-install-deps [PIP3_INSTALL_OPTION]..." + echo + echo "Tip: you can use bin/pip-ls-deps to list the dependencies that will be installed." + exit 2 +fi + +set -x + +requirements=$(mktemp tmp.swh-requirements.txt.XXXXXXXXXX) +trap "rm -f ${requirements}" EXIT +"$LS_DEPS" > "$requirements" + +pip3 install --requirement "$requirements" "$@" diff --git a/bin/pip-ls-deps b/bin/pip-ls-deps new file mode 100755 index 0000000..899e119 --- /dev/null +++ b/bin/pip-ls-deps @@ -0,0 +1,27 @@ +#!/bin/bash + +LS_MODS="bin/ls-py-modules" +if ! [ -x "$LS_MODS" ] ; then + echo "pip-ls-deps should be run from the root of swh-environment. Bye." + exit 2 +fi + +for pymod in $(${LS_MODS}) ; do + reqs="${pymod}/requirements.txt" + if [ -f "$reqs" ] ; then + cat "$reqs" + fi +done \ +| egrep -v '^#|^[[:blank:]]*$' \ +| tr '[:upper:]_' '[:lower:]-' \ +| sort -ru \ +| awk '!seen[$1]++' \ +| tac + +# WARNING: CRUDE HACK in the pipeline above. 'pip3 install' will fail if the +# same package name appears multiple times, e.g., as both "django" and "django +# >= 1.10.7" rather than trying to determine (when possible) a comprehensive +# constraint. So we deduplicate here, by first sorting alphabetically which +# will (generally...) put higher dependency constraints last and then +# deduplicate using the sole package name as key. In the example above this +# should only keep "django >= 1.10.7" and get rid of "django".