Skip to content

Commit

Permalink
Add make requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
seanh committed Aug 1, 2022
1 parent 52578e6 commit b4a0966
Show file tree
Hide file tree
Showing 18 changed files with 313 additions and 25 deletions.
47 changes: 47 additions & 0 deletions HACKING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Changing the Project's Python Dependencies
------------------------------------------

### To Add a New Dependency

Add the dependency to the appropriate [`requirements/*.in`](requirements/)
file(s) and then run:

```terminal
make requirements
```

### To Remove a Dependency

Remove the dependency from the appropriate [`requirements/*.in`](requirements)
file(s) and then run:

```terminal
make requirements
```

### To Upgrade or Downgrade a Dependency

We rely on [Dependabot](https://github.com/dependabot) to keep all our
dependencies up to date by sending automated pull requests to all our repos.
But if you need to upgrade or downgrade a dependency manually you can do that
locally.

To upgrade a package to the latest version in all `requirements/*.txt` files:

```terminal
make requirements --always-make args='--upgrade-package <FOO>'
```

To upgrade or downgrade a package to a specific version:

```terminal
make requirements --always-make args='--upgrade-package <FOO>==<X.Y.Z>'
```

To upgrade **all** dependencies to their latest versions:

```terminal
make requirements --always-make args=--upgrade
```


37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,43 @@ frontend-test: node_modules/.uptodate
coverage: python
@tox -qe coverage

# Tell make how to compile requirements/*.txt files.
#
# `touch` is used to pre-create an empty requirements/%.txt file if none
# exists, otherwise tox crashes.
#
# $(subst) is used because in the special case of making requirements.txt we
# actually need to touch dev.txt not requirements.txt and we need to run
# `tox -e dev ...` not `tox -e requirements ...`
#
# $(basename $(notdir $@))) gets just the environment name from the
# requirements/%.txt filename, for example requirements/foo.txt -> foo.
requirements/%.txt: requirements/%.in
@touch -a $(subst requirements.txt,dev.txt,$@)
@tox -qe $(subst requirements,dev,$(basename $(notdir $@))) --run-command 'pip --quiet --disable-pip-version-check install pip-tools'
@tox -qe $(subst requirements,dev,$(basename $(notdir $@))) --run-command 'pip-compile --allow-unsafe --quiet $(args) $<'

# Inform make of the dependencies between our requirements files so that it
# knows what order to re-compile them in and knows to re-compile a file if a
# file that it depends on has been changed.
requirements/dev.txt: requirements/requirements.txt
requirements/tests.txt: requirements/requirements.txt
requirements/functests.txt: requirements/requirements.txt
requirements/lint.txt: requirements/tests.txt requirements/functests.txt

# Add a requirements target so you can just run `make requirements` to
# re-compile *all* the requirements files at once.
#
# This needs to be able to re-create requirements/*.txt files that don't exist
# yet or that have been deleted so it can't just depend on all the
# requirements/*.txt files that exist on disk $(wildcard requirements/*.txt).
#
# Instead we generate the list of requirements/*.txt files by getting all the
# requirements/*.in files from disk ($(wildcard requirements/*.in)) and replace
# the .in's with .txt's.
.PHONY: requirements requirements/
requirements requirements/: $(foreach file,$(wildcard requirements/*.in),$(basename $(file)).txt)

.PHONY: sure
sure: checkformatting lint test coverage functests

Expand Down
3 changes: 3 additions & 0 deletions requirements/checkformatting.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pip-tools
black
isort
45 changes: 45 additions & 0 deletions requirements/checkformatting.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# This file is autogenerated by pip-compile with python 3.8
# To update, run:
#
# pip-compile --allow-unsafe requirements/checkformatting.in
#
black==22.6.0
# via -r requirements/checkformatting.in
build==0.8.0
# via pip-tools
click==8.1.3
# via
# black
# pip-tools
isort==5.10.1
# via -r requirements/checkformatting.in
mypy-extensions==0.4.3
# via black
packaging==21.3
# via build
pathspec==0.9.0
# via black
pep517==0.13.0
# via build
pip-tools==6.8.0
# via -r requirements/checkformatting.in
platformdirs==2.5.2
# via black
pyparsing==3.0.9
# via packaging
tomli==2.0.1
# via
# black
# build
# pep517
typing-extensions==4.3.0
# via black
wheel==0.37.1
# via pip-tools

# The following packages are considered to be unsafe in a requirements file:
pip==22.2.1
# via pip-tools
setuptools==63.2.0
# via pip-tools
1 change: 1 addition & 0 deletions requirements/coverage.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pip-tools
coverage
26 changes: 25 additions & 1 deletion requirements/coverage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,31 @@
# This file is autogenerated by pip-compile with python 3.8
# To update, run:
#
# pip-compile requirements/coverage.in
# pip-compile --allow-unsafe requirements/coverage.in
#
build==0.8.0
# via pip-tools
click==8.1.3
# via pip-tools
coverage==6.4.2
# via -r requirements/coverage.in
packaging==21.3
# via build
pep517==0.13.0
# via build
pip-tools==6.8.0
# via -r requirements/coverage.in
pyparsing==3.0.9
# via packaging
tomli==2.0.1
# via
# build
# pep517
wheel==0.37.1
# via pip-tools

# The following packages are considered to be unsafe in a requirements file:
pip==22.2.1
# via pip-tools
setuptools==63.2.0
# via pip-tools
1 change: 1 addition & 0 deletions requirements/dev.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pip-tools
ipython
ipdb
-r requirements.txt
34 changes: 32 additions & 2 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
# This file is autogenerated by pip-compile with python 3.8
# To update, run:
#
# pip-compile requirements/dev.in
# pip-compile --allow-unsafe requirements/dev.in
#
asttokens==2.0.5
# via stack-data
backcall==0.2.0
# via ipython
build==0.8.0
# via pip-tools
certifi==2022.6.15
# via
# -r requirements/requirements.txt
Expand All @@ -17,6 +19,8 @@ charset-normalizer==2.0.1
# via
# -r requirements/requirements.txt
# requests
click==8.1.3
# via pip-tools
decorator==5.0.7
# via
# ipdb
Expand Down Expand Up @@ -58,16 +62,22 @@ markupsafe==1.1.1
# pyramid-jinja2
matplotlib-inline==0.1.2
# via ipython
packaging==21.3
# via build
parso==0.8.2
# via jedi
pastedeploy==2.1.0
# via
# -r requirements/requirements.txt
# plaster-pastedeploy
pep517==0.13.0
# via build
pexpect==4.8.0
# via ipython
pickleshare==0.7.5
# via ipython
pip-tools==6.8.0
# via -r requirements/dev.in
plaster==1.0
# via
# -r requirements/requirements.txt
Expand All @@ -85,6 +95,8 @@ pure-eval==0.2.1
# via stack-data
pygments==2.9.0
# via ipython
pyparsing==3.0.9
# via packaging
pyramid==2.0
# via
# -r requirements/requirements.txt
Expand All @@ -104,6 +116,10 @@ stack-data==0.1.3
# via ipython
toml==0.10.2
# via ipdb
tomli==2.0.1
# via
# build
# pep517
traitlets==5.0.5
# via
# ipython
Expand All @@ -128,6 +144,8 @@ webob==1.8.6
# via
# -r requirements/requirements.txt
# pyramid
wheel==0.37.1
# via pip-tools
zope-deprecation==4.4.0
# via
# -r requirements/requirements.txt
Expand All @@ -139,4 +157,16 @@ zope-interface==4.7.2
# pyramid

# The following packages are considered to be unsafe in a requirements file:
# setuptools
pip==22.2.1
# via pip-tools
setuptools==63.2.0
# via
# -r requirements/requirements.txt
# gunicorn
# ipdb
# ipython
# pip-tools
# plaster
# pyramid
# zope-deprecation
# zope-interface
1 change: 1 addition & 0 deletions requirements/format.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pip-tools
black
isort
29 changes: 26 additions & 3 deletions requirements/format.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,44 @@
# This file is autogenerated by pip-compile with python 3.8
# To update, run:
#
# pip-compile requirements/format.in
# pip-compile --allow-unsafe requirements/format.in
#
black==22.6.0
# via -r requirements/format.in
build==0.8.0
# via pip-tools
click==8.0.3
# via black
# via
# black
# pip-tools
isort==5.10.1
# via -r requirements/format.in
mypy-extensions==0.4.3
# via black
packaging==21.3
# via build
pathspec==0.9.0
# via black
pep517==0.13.0
# via build
pip-tools==6.8.0
# via -r requirements/format.in
platformdirs==2.2.0
# via black
pyparsing==3.0.9
# via packaging
tomli==2.0.0
# via black
# via
# black
# build
# pep517
typing-extensions==3.10.0.1
# via black
wheel==0.37.1
# via pip-tools

# The following packages are considered to be unsafe in a requirements file:
pip==22.2.1
# via pip-tools
setuptools==63.2.0
# via pip-tools
1 change: 1 addition & 0 deletions requirements/functests.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-r requirements.txt

pip-tools
pytest
webtest
h_matchers
Loading

0 comments on commit b4a0966

Please sign in to comment.