From b5712ab7555dde49e013b5b5597c8486637ea2a2 Mon Sep 17 00:00:00 2001 From: Colin Dean Date: Mon, 5 May 2025 12:42:52 -0400 Subject: [PATCH 1/2] Replace make does-path-have-reqs with better deps-reqs-versions This fixes this long-broken task and enables an output that shows the version at each path. --- Makefile | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 991d2a6..76891ca 100644 --- a/Makefile +++ b/Makefile @@ -172,14 +172,28 @@ install-precommit: $(GIT_HOOKS) ## Sets up pre-commit hooks $(GIT_HOOKS): .pre-commit-config.yaml $(PRECOMMIT) install -.PHONY: does-path-have-reqs -does-path-have-reqs: ## Check if shell $PATH has expected elements - @echo "$(COLOR_BLUE)Checking PATH elements for evidence of package managers…$(COLOR_RESET)" - @( (echo $${PATH} | grep -q poetry ) && echo "found poetry") || (echo "missing poetry" && false) - @( (echo $${PATH} | grep -q homebrew ) && echo "found homebrew") || (echo "missing homebrew" && false) - @( (echo $${PATH} | grep -q pyenv ) && echo "found pyenv") || (echo "missing pyenv" && false) +.PHONY: deps-reqs-versions +deps-reqs-versions: ## Check if shell $PATH has requirements and show their version + @echo "$(COLOR_BLUE)Checking PATH elements for evidence of package managers. The first in each section is what's used.$(COLOR_RESET)" + @$(MAKE) paths-version-for-cmd CMD=poetry + @$(MAKE) paths-version-for-cmd CMD=pyenv + @$(MAKE) paths-version-for-cmd CMD=brew + @$(MAKE) paths-version-for-cmd CMD=curl + @$(MAKE) paths-version-for-cmd CMD=git @echo "$(COLOR_GREEN)All expected PATH elements found$(COLOR_RESET)" +CMD_VERSION_FLAG ?= --version +.PHONY: paths-version-for-cmd +paths-version-for-cmd: ## Display version for all executable paths for an executable, set CMD & CMD_VERSION_FLAG + @( if [ -z "$$(which -a $(CMD))" ]; then \ + echo "==> $(COLOR_RED)missing $(CMD)$(COLOR_RESET)"; \ + else \ + echo "==> $(COLOR_ORANGE)$(CMD) $(COLOR_BLUE)commands' versions are:$(COLOR_RESET)"; \ + for pth in $$(which -a $(CMD)); do \ + echo "$(COLOR_BLUE)$${pth}$(COLOR_RESET) : $$("$${pth}" $(CMD_VERSION_FLAG))"; \ + done; \ + fi ) + ##@ Dependencies .PHONY: python-current From bf55d137a61bf6fcecd588a96967be3a2f0a87f2 Mon Sep 17 00:00:00 2001 From: Colin Dean Date: Mon, 5 May 2025 12:51:10 -0400 Subject: [PATCH 2/2] Adds pre-commit to deps-reqs-versions, lets which be changed which is an executable, and someone might want to replace it with `pyenv which` or `poetry run which`. --- Makefile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 76891ca..7d8b2d8 100644 --- a/Makefile +++ b/Makefile @@ -174,24 +174,26 @@ $(GIT_HOOKS): .pre-commit-config.yaml .PHONY: deps-reqs-versions deps-reqs-versions: ## Check if shell $PATH has requirements and show their version - @echo "$(COLOR_BLUE)Checking PATH elements for evidence of package managers. The first in each section is what's used.$(COLOR_RESET)" + @echo "$(COLOR_BLUE)Checking PATH elements for evidence of required tools. The first in each section is what's used.$(COLOR_RESET)" @$(MAKE) paths-version-for-cmd CMD=poetry @$(MAKE) paths-version-for-cmd CMD=pyenv @$(MAKE) paths-version-for-cmd CMD=brew @$(MAKE) paths-version-for-cmd CMD=curl @$(MAKE) paths-version-for-cmd CMD=git + @$(MAKE) paths-version-for-cmd CMD=pre-commit @echo "$(COLOR_GREEN)All expected PATH elements found$(COLOR_RESET)" CMD_VERSION_FLAG ?= --version +WHICH ?= which .PHONY: paths-version-for-cmd paths-version-for-cmd: ## Display version for all executable paths for an executable, set CMD & CMD_VERSION_FLAG @( if [ -z "$$(which -a $(CMD))" ]; then \ - echo "==> $(COLOR_RED)missing $(CMD)$(COLOR_RESET)"; \ + echo "==> $(COLOR_RED)missing $(CMD)$(COLOR_RESET)"; \ else \ - echo "==> $(COLOR_ORANGE)$(CMD) $(COLOR_BLUE)commands' versions are:$(COLOR_RESET)"; \ - for pth in $$(which -a $(CMD)); do \ - echo "$(COLOR_BLUE)$${pth}$(COLOR_RESET) : $$("$${pth}" $(CMD_VERSION_FLAG))"; \ - done; \ + echo "==> $(COLOR_ORANGE)$(CMD) $(COLOR_BLUE)commands' versions are:$(COLOR_RESET)"; \ + for pth in $$($(WHICH) -a $(CMD)); do \ + echo "$(COLOR_BLUE)$${pth}$(COLOR_RESET) : $$("$${pth}" $(CMD_VERSION_FLAG))"; \ + done; \ fi ) ##@ Dependencies