From 90689ea39336334616b98e861f29a6b3e2a10caf Mon Sep 17 00:00:00 2001 From: Alex Carney Date: Thu, 9 May 2024 19:50:06 +0100 Subject: [PATCH] devenv: Use pipx to install pre-commit Hopefully, this can sidestep any issues with not having pip available in the user's default Python installation --- .devcontainer/tools.mk | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.devcontainer/tools.mk b/.devcontainer/tools.mk index 452ffbfca..4b0c4cc0a 100644 --- a/.devcontainer/tools.mk +++ b/.devcontainer/tools.mk @@ -84,18 +84,33 @@ endif PY_INTERPRETERS += $(PY) #$(info $(PY_INTERPRETERS)) +PIPX ?= $(shell command -v pipx) + +ifeq ($(strip $(PIPX)),) +PIPX := $(BIN)/pipx +PIPX_VERSION := 1.5.0 + +$(PIPX): + curl -L -o $(BIN)/pipx.pyz https://github.com/pypa/pipx/releases/download/$(PIPX_VERSION)/pipx.pyz + echo '#!/bin/bash\nexec $(PY) $(BIN)/pipx.pyz "$$@"' > $(PIPX) + + chmod +x $(PIPX) + $@ --version + touch $@ +endif + PRE_COMMIT ?= $(shell command -v pre-commit) ifeq ($(strip $(PRE_COMMIT)),) PRE_COMMIT := $(BIN)/pre-commit -$(PRE_COMMIT): $(PY) - $(PY) -m pip install --user pre-commit +$(PRE_COMMIT): $(PIPX) + $(PIPX) install pre-commit $@ --version touch $@ endif -PY_TOOLS := $(HATCH) $(PRE_COMMIT) +PY_TOOLS := $(HATCH) $(PIPX) $(PRE_COMMIT) # Node JS NPM ?= $(shell command -v npm)