len(pip freeze > requirements.txt) > len(upreq)
Upreq is a simple CLI tool that provides shortcuts and feedback for updating your Python project's requirements.txt
file.
It's written in Go and uses Cobra as the CLI framework.
It started as a bash script, after I found myself typing pip freeze > etc
one too many times and well, here we are.
- Comparing your
requirements.txt
file to your current environment - Reduces carpel tunnel by turning
pip freeze > requirements.txt
intoupreq
- Provides feedback on what packages were added/removed
- Flag for automatically adding new requirements to git
Since Upreq is a binary executable, you can download the latest release from the releases page and copy it to your PATH
.
Below is an example of how to do this on each major OS.
curl -s https://api.github.com/repos/robswc/upreq/releases/latest | grep "browser_download_url.*upreq-linux" | cut -d : -f 2,3 | tr -d \" | wget -qi -
chmod +x upreq-linux
sudo mv upreq-linux /usr/local/bin/upreq
curl -s https://api.github.com/repos/robswc/upreq/releases/latest | grep "browser_download_url.*upreq-darwin" | cut -d : -f 2,3 | tr -d \" | wget -qi -
chmod +x upreq-darwin
sudo mv upreq-darwin /usr/local/bin/upreq
Invoke-WebRequest -Uri
"
https://api.github.com/repos/robswc/upreq/releases/latest
" | Select-Object -ExpandProperty content | ConvertFrom-Json | Select-Object -ExpandProperty assets | Select-Object -ExpandProperty browser_download_url | Select-String -Pattern "upreq-windows" | Invoke-WebRequest -OutFile upreq-windows.exe
mkdir "C:\Program Files\upreq"
mv .\upreq-windows.exe "C:\Program Files\upreq\upreq.exe"
$env:Path += ";C:\Program Files\upreq"
Usage is pretty simple. Just run upreq
in your project's root directory.
Note: Be sure to activate your virtual environment before running.
Running just upreq will run pip freeze
and compare it to your current requirements.txt
file.
If there are any differences, it will print them out with a +
or -
to indicate if it was added or removed.
Finally, it will write any new requirements to your requirements.txt
file.
upreq
upreq --git # Automatically add new requirements to git
upreq --help