Skip to content

Commit

Permalink
feat: issue warning if pyproject.toml was updated without pkg update
Browse files Browse the repository at this point in the history
  • Loading branch information
jenstroeger committed Jul 10, 2022
1 parent 846ef23 commit 3e29176
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# whether this current run of `make` requires a Python virtual environment.
NEED_VENV := $(or \
$(findstring setup,$(MAKECMDGOALS)), \
$(findstring upgrade-quiet,$(MAKECMDGOALS)), \
$(findstring upgrade,$(MAKECMDGOALS)), \
$(findstring requirements,$(MAKECMDGOALS)), \
$(findstring all,$(MAKECMDGOALS)), \
Expand All @@ -26,6 +27,13 @@ else
endif
endif

# If the project configuration file has been updated (package deps or
# otherwise) then warn the user and suggest resolving the conflict.
ifeq ($(shell test pyproject.toml -nt .venv/upgraded-on; echo $$?),0)
$(warning pyproject.toml was updated, consider `make upgrade` if your packages have changed)
$(warning If this is not correct then run `make upgrade-quiet`)
endif

# Create a virtual environment, either for Python3.10 (default) or using
# the Python interpreter specified in the PYTHON environment variable.
.PHONY: venv
Expand Down Expand Up @@ -57,10 +65,12 @@ upgrade: .venv/upgraded-on
.venv/upgraded-on: pyproject.toml
python -m pip install --upgrade pip
python -m pip install --upgrade --upgrade-strategy eager --editable .[hooks,dev,test,docs]
echo "Automatically generated by Python Package Makefile on `date --rfc-3339=seconds`." > .venv/upgraded-on
make upgrade-quiet
force-upgrade:
rm -f .venv/upgraded-on
$(MAKE) upgrade
make upgrade
upgrade-quiet:
echo "Automatically generated by Python Package Makefile on `date --rfc-3339=seconds`." > .venv/upgraded-on

# Generate a requirements.txt file containing version and integrity
# hashes for all packages currently installed in the virtual environment.
Expand Down Expand Up @@ -111,7 +121,7 @@ dist/package-$(PACKAGE_VERSION).tar.gz: check test
.PHONY: docs
docs: docs/_build/html/index.html
docs/_build/html/index.html: check test
$(MAKE) -C docs/ html
make -C docs/ html

# Clean test caches and remove build artifacts.
.PHONY: dist-clean clean
Expand Down

0 comments on commit 3e29176

Please sign in to comment.