Skip to content

Instantly share code, notes, and snippets.

@thomaswilley
Created September 19, 2023 22:04
Show Gist options
  • Save thomaswilley/d15aa6c65fbaa130b8e46c6d247df7c3 to your computer and use it in GitHub Desktop.
Save thomaswilley/d15aa6c65fbaa130b8e46c6d247df7c3 to your computer and use it in GitHub Desktop.
One-liner to get python root packages from pip, for a cleaner requirements.txt
pip freeze | cut -d= -f1 | while read pkg; do pip show "$pkg" | grep "Required-by:" | awk -v pkgname="$pkg" -F': ' '!$2 {print pkgname}'; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment