Skip to content

Commit

Permalink
devenv: Use pipx to install pre-commit
Browse files Browse the repository at this point in the history
Hopefully, this can sidestep any issues with not having pip available in
the user's default Python installation
  • Loading branch information
alcarney committed May 9, 2024
1 parent baf15ce commit 90689ea
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions .devcontainer/tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 90689ea

Please sign in to comment.