-
-
Save harikt/3dc9a6c61be2d58b7a5c7e5984298b62 to your computer and use it in GitHub Desktop.
add and remove pip install/uninstall from requirements.txt automatically
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
# add pip install/uninstall to requirements.txt automatically | |
pipr() { | |
if [ "$1" == "install" ]; then | |
pip $1 $2 | |
pip freeze | grep -i $2 >> requirements.txt | |
echo ok, added $2 as: | |
tail -n1 requirements.txt | |
fi | |
if [ "$1" == "uninstall" ]; then | |
echo y | pip $1 $2 >> .pipremoved | |
grep -i "successfully uninstalled" .pipremoved | grep -o -i $2 >> requirements.removed | |
cp requirements.txt requirements.bak | |
tail -n1 requirements.removed | xargs -I{} grep -v {} requirements.bak > requirements.txt | |
echo ok, removed: | |
tail -n1 requirements.removed | |
rm .pipremoved >/dev/nul | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some more links :
http://stackoverflow.com/questions/20006000/install-a-package-and-write-to-requirements-txt-with-pip
http://codeinthehole.com/writing/using-pip-and-requirementstxt-to-install-from-the-head-of-a-github-branch/