Last active
June 29, 2020 14:58
-
-
Save u8sand/41c3e15e28d9f3ca71cb9e77defe69ac to your computer and use it in GitHub Desktop.
One-liners for ensuring requirements.txt / system deps match
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Produce a unified requirements.txt (no guarantees this comparison works properly for all versioning cases) | |
cat requirements.txt <(pip freeze) | awk 'BEGIN { FS="=="; OFS="==" } { if (V[tolower($1)] != "") { if ($2 != V[tolower($1)]) { print $1, $2 } else { print $1, V[tolower($1)] } } else { V[tolower($1)]=$2 } }' | |
# Produce a diff for manual inspection | |
cat requirements.txt <(pip freeze) | awk 'BEGIN { FS="=="; OFS="==" } { if (V[tolower($1)] != "") { if ($2 != V[tolower($1)]) { print "- "$1, V[tolower($1)]; print "+ "$1, $2 } else { print " "$1, $2 } } else { V[tolower($1)]=$2 } }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment