Skip to content

Instantly share code, notes, and snippets.

@Fedalto
Created December 28, 2017 20:52
Show Gist options
  • Save Fedalto/a71ac6eed2af8b4d3856523c880c114d to your computer and use it in GitHub Desktop.
Save Fedalto/a71ac6eed2af8b4d3856523c880c114d to your computer and use it in GitHub Desktop.
Modify the requirements.txt file and upgrade all Python libraries to the latest version.
#!/bin/bash
pip list --format=columns --outdated | \
sed -n '3,$p' | \
while IFS=" " read -r package old_version new_version extra
do
for requirements_file in "$@"
do
if grep -q ${package} ${requirements_file}; then
echo "${package}: ${old_version} -> ${new_version}"
fi
sed -i "s#${package}==${old_version}#${package}==${new_version}#" $requirements_file
done
done
@Fedalto
Copy link
Author

Fedalto commented Dec 28, 2017

Usage:

$ ./upgrade-requirements.sh requirements-test.txt requirements.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment