Skip to content

Instantly share code, notes, and snippets.

@yrps
Created January 7, 2017 22:49
Show Gist options
  • Save yrps/e801d30b048e0d2737b69f512239b61f to your computer and use it in GitHub Desktop.
Save yrps/e801d30b048e0d2737b69f512239b61f to your computer and use it in GitHub Desktop.
Determine module requirements of uninstalled PyPI packages.
#!/bin/sh
set -eu
# Determine module requirements of uninstalled PyPI packages.
# For installed modules, use `pip show package1 [ package2 ... ]`
script="$(basename "$0")"
[ $# -eq 0 ] && {
>&2 echo "Usage: $script package1 [ package2 ... ]"
exit 1
}
tmpdir="/run/user/$(id -u)"
[ -w "$tmpdir" ] || tmpdir=/tmp
tmpdir="$tmpdir/$script"
[ -e "$tmpdir" ] && rm -r "$tmpdir"
pip download "$@" --dest "$tmpdir" --no-binary :all: |
sed -n 's/^Collecting \(.*\) (from \(.*\))/\2: \1/p'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment