From 41bce73a379d70307cd8fa77785056f01e87ffd0 Mon Sep 17 00:00:00 2001 From: Christophe Nanteuil Date: Sat, 30 Apr 2022 23:46:37 +0200 Subject: [PATCH 1/5] Must use python from venv as default --- Makefile | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index a51a8315f..457746a54 100644 --- a/Makefile +++ b/Makefile @@ -58,14 +58,15 @@ EXCLUDED := \ library/xdrlib.po # Internal variables - UPSTREAM := https://github.com/python/cpython - -PYTHON := $(shell which python3) -MODE := html POSPELL_TMP_DIR := .pospell/ -JOBS := auto -SERVE_PORT := + +# You can set these variables from the command line. +VENVDIR = ./venv +PYTHON = $(VENVDIR)/bin/python3 +MODE = html +JOBS = auto +SERVE_PORT = # Detect OS @@ -90,6 +91,8 @@ all: ensure_prerequisites mkdir -p locales/$(LANGUAGE)/LC_MESSAGES/ $(CP_CMD) -u --parents *.po */*.po locales/$(LANGUAGE)/LC_MESSAGES/ $(MAKE) -C venv/cpython/Doc/ \ + PYTHON=../../../$(VENVDIR)/bin/python \ + VENVDIR=../../../$(VENVDIR) \ SPHINXOPTS='-j$(JOBS) \ -D locale_dirs=$(abspath locales) \ -D language=$(LANGUAGE) \ @@ -109,11 +112,11 @@ venv/cpython/.git/HEAD: .PHONY: ensure_prerequisites ensure_prerequisites: venv/cpython/.git/HEAD - @if ! (blurb help >/dev/null 2>&1 && sphinx-build --version >/dev/null 2>&1); then \ + @if ! ($(VENVDIR)/bin/blurb help >/dev/null 2>&1 && $(VENVDIR)/bin/sphinx-build --version >/dev/null 2>&1); then \ git -C venv/cpython/ checkout $(BRANCH); \ echo "You're missing dependencies please install:"; \ echo ""; \ - echo " python -m pip install -r requirements.txt -r venv/cpython/Doc/requirements.txt"; \ + echo $(VENVDIR)"/bin/python -m pip install -r requirements.txt -r venv/cpython/Doc/requirements.txt"; \ exit 1; \ fi From 86b9b4c1d7f48e87cad885067b889183c5863c0f Mon Sep 17 00:00:00 2001 From: Christophe Nanteuil Date: Sat, 7 May 2022 14:21:00 +0200 Subject: [PATCH 2/5] Easier venv update --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 457746a54..9d132da9f 100644 --- a/Makefile +++ b/Makefile @@ -114,12 +114,15 @@ venv/cpython/.git/HEAD: ensure_prerequisites: venv/cpython/.git/HEAD @if ! ($(VENVDIR)/bin/blurb help >/dev/null 2>&1 && $(VENVDIR)/bin/sphinx-build --version >/dev/null 2>&1); then \ git -C venv/cpython/ checkout $(BRANCH); \ - echo "You're missing dependencies please install:"; \ + echo "You're missing dependencies please install using:"; \ echo ""; \ - echo $(VENVDIR)"/bin/python -m pip install -r requirements.txt -r venv/cpython/Doc/requirements.txt"; \ + echo "make update_venv"; \ exit 1; \ fi +.PHONY: update_venv +update_venv: ensure_prerequisites + $(VENVDIR)/bin/python -m pip install -r requirements.txt -r venv/cpython/Doc/requirements.txt .PHONY: serve serve: From eef6a859c0df3e5abd6e30392caa0a63ee5ec3a4 Mon Sep 17 00:00:00 2001 From: Christophe Nanteuil Date: Sat, 7 May 2022 15:43:14 +0200 Subject: [PATCH 3/5] =?UTF-8?q?Extension=20du=20venv=20par=20d=C3=A9faut?= =?UTF-8?q?=20aux=20autres=20r=C3=A8gles=20du=20Makefile=20-=20Utilisation?= =?UTF-8?q?=20de=20la=20variable=20PYTHON=20plut=C3=B4t=20que=20VENVDIR=20?= =?UTF-8?q?(afin=20de=20n'avoir=20=C3=A0=20red=C3=A9finir=20que=20PYTHON)?= =?UTF-8?q?=20-=20extension=20aux=20r=C3=A8gles=20serve,=20todo,=20wrap,?= =?UTF-8?q?=20spell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 9d132da9f..f7f4e47e5 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ all: ensure_prerequisites mkdir -p locales/$(LANGUAGE)/LC_MESSAGES/ $(CP_CMD) -u --parents *.po */*.po locales/$(LANGUAGE)/LC_MESSAGES/ $(MAKE) -C venv/cpython/Doc/ \ - PYTHON=../../../$(VENVDIR)/bin/python \ + PYTHON=../../../$(PYTHON) \ VENVDIR=../../../$(VENVDIR) \ SPHINXOPTS='-j$(JOBS) \ -D locale_dirs=$(abspath locales) \ @@ -122,24 +122,27 @@ ensure_prerequisites: venv/cpython/.git/HEAD .PHONY: update_venv update_venv: ensure_prerequisites - $(VENVDIR)/bin/python -m pip install -r requirements.txt -r venv/cpython/Doc/requirements.txt + $(PYTHON) -m pip install -r requirements.txt -r venv/cpython/Doc/requirements.txt -.PHONY: serve +#.PHONY: serve serve: ifdef SERVE_PORT - $(MAKE) -C venv/cpython/Doc/ serve SERVE_PORT=$(SERVE_PORT) + $(MAKE) -C venv/cpython/Doc/ \ + PYTHON=../../../$(PYTHON) \ + SERVE_PORT=$(SERVE_PORT) \ + serve else - $(MAKE) -C venv/cpython/Doc/ serve + $(MAKE) -C venv/cpython/Doc/ PYTHON=../../../$(PYTHON) serve endif .PHONY: todo todo: ensure_prerequisites - potodo --exclude venv .venv $(EXCLUDED) + $(VENVDIR)/bin/potodo --exclude venv .venv $(EXCLUDED) .PHONY: wrap wrap: ensure_prerequisites @echo "Re wrapping modified files" - powrap -m + $(VENVDIR)/bin/powrap -m SRCS = $(shell git diff --name-only $(BRANCH) | grep '.po$$') # foo/bar.po => $(POSPELL_TMP_DIR)/foo/bar.po.out @@ -151,15 +154,15 @@ spell: ensure_prerequisites $(DESTS) $(POSPELL_TMP_DIR)/%.po.out: %.po dict @echo "Pospell checking $<..." mkdir -p $(@D) - pospell -p dict -l fr_FR $< && touch $@ + $(VENVDIR)/bin/pospell -p dict -l fr_FR $< && touch $@ .PHONY: fuzzy fuzzy: ensure_prerequisites - potodo -f --exclude venv .venv $(EXCLUDED) + $(VENVDIR)/bin/potodo -f --exclude venv .venv $(EXCLUDED) .PHONY: verifs verifs: spell - powrap --check --quiet *.po */*.po + $(VENVDIR)/bin/powrap --check --quiet *.po */*.po .PHONY: clean clean: From 4e5cebb5a9505bd9ef819e00bd206b9cd8076a2a Mon Sep 17 00:00:00 2001 From: Christophe Nanteuil Date: Sat, 7 May 2022 15:53:16 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Remet=20la=20r=C3=A8gle=20en=20silencieuse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f7f4e47e5..724a06531 100644 --- a/Makefile +++ b/Makefile @@ -124,7 +124,7 @@ ensure_prerequisites: venv/cpython/.git/HEAD update_venv: ensure_prerequisites $(PYTHON) -m pip install -r requirements.txt -r venv/cpython/Doc/requirements.txt -#.PHONY: serve +.PHONY: serve serve: ifdef SERVE_PORT $(MAKE) -C venv/cpython/Doc/ \ From 5f4097fc3f274601c0d820b61fe5cebc95b71410 Mon Sep 17 00:00:00 2001 From: Christophe Nanteuil Date: Sun, 8 May 2022 23:20:12 +0200 Subject: [PATCH 5/5] Prise en compte des remarques de Julien --- Makefile | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 724a06531..7b412c88c 100644 --- a/Makefile +++ b/Makefile @@ -91,8 +91,8 @@ all: ensure_prerequisites mkdir -p locales/$(LANGUAGE)/LC_MESSAGES/ $(CP_CMD) -u --parents *.po */*.po locales/$(LANGUAGE)/LC_MESSAGES/ $(MAKE) -C venv/cpython/Doc/ \ - PYTHON=../../../$(PYTHON) \ - VENVDIR=../../../$(VENVDIR) \ + PYTHON=$(abspath $(PYTHON)) \ + VENVDIR=$(abspath $(VENVDIR)) \ SPHINXOPTS='-j$(JOBS) \ -D locale_dirs=$(abspath locales) \ -D language=$(LANGUAGE) \ @@ -120,19 +120,46 @@ ensure_prerequisites: venv/cpython/.git/HEAD exit 1; \ fi +.PHONY: $(PYTHON) +$(PYTHON): + @if [ ! -x $(PYTHON) ] || \ + [ "`$(PYTHON) --version | cut --fields=1 --delimiter='.'`" != "Python 3" ] ; then \ + echo "You don't have a suitable Python in: " $(abspath $(dir $(PYTHON))); \ + echo "The recommended way to proceed is to install a virtual env in: "$(abspath $(VENVDIR)); \ + echo "You can achieve this with:"; \ + echo "make install_venv PYTHON_BASE=/your/version/of/python"; \ + echo ""; \ + echo "or you can customize the variable PYTHON of the Makefile"; \ + exit 1; \ + fi + +PYTHON_BASE = $(shell which python) +PYTHON_BASE_VERSION = $(shell $(PYTHON_BASE) --version | cut --fields=1 --delimiter='.') + +.PHONY: install_venv +install_venv: +ifneq ($(PYTHON_BASE_VERSION), Python 3) + @echo $(PYTHON_BASE) " is not a Python executable" ; \ + echo $(PYTHON_BASE_VERSION) ; \ + exit 1 +endif + $(PYTHON_BASE) -m venv $(VENVDIR) + @echo "Python virtual env installed in $(abspath $(VENVDIR))" + make update_venv + .PHONY: update_venv -update_venv: ensure_prerequisites +update_venv: $(PYTHON) venv/cpython/.git/HEAD $(PYTHON) -m pip install -r requirements.txt -r venv/cpython/Doc/requirements.txt .PHONY: serve serve: ifdef SERVE_PORT $(MAKE) -C venv/cpython/Doc/ \ - PYTHON=../../../$(PYTHON) \ + PYTHON=$(abspath $(PYTHON)) \ SERVE_PORT=$(SERVE_PORT) \ serve else - $(MAKE) -C venv/cpython/Doc/ PYTHON=../../../$(PYTHON) serve + $(MAKE) -C venv/cpython/Doc/ PYTHON=$(abspath $(PYTHON)) serve endif .PHONY: todo