From 6b655ad231fc1a111fd3bfbe14b28303539529d8 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 10 Mar 2022 13:38:44 +0200 Subject: [PATCH 1/3] Lint: call pre-commit as a module using make's PYTHON --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 0a095abfc53..70fea121de7 100644 --- a/Makefile +++ b/Makefile @@ -28,9 +28,9 @@ venv: ./$(VENV_DIR)/bin/python -m pip install -r requirements.txt lint: - pre-commit --version > /dev/null || $(PYTHON) -m pip install pre-commit - pre-commit run --all-files + $(PYTHON) -m pre_commit --version > /dev/null || $(PYTHON) -m pip install pre-commit + $(PYTHON) -m pre_commit run --all-files spellcheck: - pre-commit --version > /dev/null || $(PYTHON) -m pip install pre-commit - pre-commit run --all-files --hook-stage manual codespell + $(PYTHON) -m pre_commit --version > /dev/null || $(PYTHON) -m pip install pre-commit + $(PYTHON) -m pre_commit run --all-files --hook-stage manual codespell From 96b66e73c3fd4b46c96033bd40a05d14eb6ffa59 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 10 Mar 2022 14:07:58 +0200 Subject: [PATCH 2/3] Call tools inside venv --- Makefile | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 70fea121de7..ae71d05349b 100644 --- a/Makefile +++ b/Makefile @@ -1,36 +1,46 @@ # Builds PEP files to HTML using sphinx PYTHON=python3 -VENV_DIR=venv +VENVDIR=venv JOBS=8 -RENDER_COMMAND=$(PYTHON) build.py -j $(JOBS) +RENDER_COMMAND=$(VENVDIR)/bin/python3 build.py -j $(JOBS) -render: +render: venv $(RENDER_COMMAND) -pages: rss +pages: venv rss $(RENDER_COMMAND) --build-dirs -fail-warning: +fail-warning: venv $(RENDER_COMMAND) --fail-on-warning -check-links: +check-links: venv $(RENDER_COMMAND) --check-links -rss: - $(PYTHON) generate_rss.py +rss: venv + $(VENVDIR)/bin/python3 generate_rss.py -clean: +clean: clean-venv -rm -rf build -venv: - $(PYTHON) -m venv $(VENV_DIR) - ./$(VENV_DIR)/bin/python -m pip install -r requirements.txt - -lint: - $(PYTHON) -m pre_commit --version > /dev/null || $(PYTHON) -m pip install pre-commit - $(PYTHON) -m pre_commit run --all-files +clean-venv: + rm -rf $(VENVDIR) -spellcheck: - $(PYTHON) -m pre_commit --version > /dev/null || $(PYTHON) -m pip install pre-commit - $(PYTHON) -m pre_commit run --all-files --hook-stage manual codespell +venv: + @if [ -d $(VENVDIR) ] ; then \ + echo "venv already exists."; \ + echo "To recreate it, remove it first with \`make clean-venv'."; \ + else \ + $(PYTHON) -m venv $(VENVDIR); \ + $(VENVDIR)/bin/python3 -m pip install -U pip setuptools; \ + $(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \ + echo "The venv has been created in the $(VENVDIR) directory"; \ + fi + +lint: venv + $(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit + $(VENVDIR)/bin/python3 -m pre_commit run --all-files + +spellcheck: venv + $(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit + $(VENVDIR)/bin/python3 -m pre_commit run --all-files --hook-stage manual codespell From e6b6b0cc5d17dc9e4c196f8c1599485a40b5baa4 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 10 Mar 2022 21:32:08 +0200 Subject: [PATCH 3/3] Use hidden .venv dir and skip upgrading setuptools Co-authored-by: Brett Cannon --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ae71d05349b..065f945806a 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # Builds PEP files to HTML using sphinx PYTHON=python3 -VENVDIR=venv +VENVDIR=.venv JOBS=8 RENDER_COMMAND=$(VENVDIR)/bin/python3 build.py -j $(JOBS) @@ -32,7 +32,6 @@ venv: echo "To recreate it, remove it first with \`make clean-venv'."; \ else \ $(PYTHON) -m venv $(VENVDIR); \ - $(VENVDIR)/bin/python3 -m pip install -U pip setuptools; \ $(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \ echo "The venv has been created in the $(VENVDIR) directory"; \ fi