From 3e291762c3971eede030ad003b17414ee15a15f8 Mon Sep 17 00:00:00 2001 From: Jens Troeger Date: Sun, 10 Jul 2022 15:33:30 +1000 Subject: [PATCH] feat: issue warning if pyproject.toml was updated without pkg update --- Makefile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index c68f075a..fdc43502 100644 --- a/Makefile +++ b/Makefile @@ -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)), \ @@ -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 @@ -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. @@ -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