Florents Tselai Think, Code, Read, Sleep, Repeat

One-liner to keep you requirements.txt up-to-date

18 Jan 2019

This one-liner iterates through your requirements.txt and for every packages fetches and prints the latest version available in PyPi.

cat requirements.txt | grep -v '^\-e' | cut -d= -f1 | xargs -I {} -n1 -P1 sh -c "echo \`curl -s https://pypi.org/project/{}/ | sed -e 's/^[[:space:]]*//' | grep '{} [0-9]' | sed -e 's/ /==/g'\`"

You can use it to keep your requirements.txt updated. Use with caution! Complex dependencies can break your code. Always try it in a fresh virtual environment first.

Tags #projects #code #python #pip #unix