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 c42c894 commit 49f1b1d
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions .devcontainer/tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,34 @@ 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 -o $(BIN)/pipx.pyz https://github.com/pypa/pipx/releases/download/$(PIPX_VERSION)/pipx.pyz

echo -e '#!/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 49f1b1d

Please sign in to comment.