Skip to content

Commit

Permalink
Add Makefile entrypoint for easily upgrading packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Torres committed Jan 13, 2023
1 parent b4b2c07 commit b2e7250
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/developer/DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,12 @@ $ source venv/bin/activate
$ pip-compile --generate-hashes --allow-unsafe --upgrade-package django --upgrade-package requests==2.0.0
```

Instead of running this command manually, you can use the following make entrypoint:

```bash
$ make upgrade-dep package=requests==2.0.0 reqfile=requirements.in
```

To install the dependencies with `pip`, you simply pass the requirements file(s) to the `-r` option and all the requirements in the file will be installed, even if the file was generated by `pip-compile`!

With `pip-tools`, the command for installing dependencies is `pip-sync requirements.txt` (or any other file generated by `pip-compile`), however `pip-sync` will not only install the requirements, but it will also uninstall any packages or versions that do **not** match the one defined in the requirements file.
Expand Down
5 changes: 5 additions & 0 deletions mk/setup.mk
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ sync-deps: check-venv-active
$(ps) requirements.txt devel-requirements.txt $$([ -f local-requirements.txt ] && echo 'local-requirements.txt')


.PHONY : upgrade-dep
upgrade-dep: check-venv-active
@echo ">upgrading specified packages"
$(pc) --allow-unsafe --generate-hashes --no-emit-index-url -P $(package) $(reqfile)

#***********************************
### Update installed python packages based on requirements.txt both in local venv and in all containers
#***********************************
Expand Down

0 comments on commit b2e7250

Please sign in to comment.