From 7424cb3b298e2b80adeb93952fa6c3d653c12a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Mon, 20 Jan 2025 16:34:59 +0000 Subject: [PATCH 1/5] doc: add social cards generation support in sphinxext-opengraph MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Filipe Laíns --- Doc/requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Doc/requirements.txt b/Doc/requirements.txt index 32ff8f74d05bb6..efc6352312a53c 100644 --- a/Doc/requirements.txt +++ b/Doc/requirements.txt @@ -18,4 +18,7 @@ sphinx-notfound-page~=1.0.0 # to install that as well. python-docs-theme>=2023.3.1,!=2023.7 +# Needed to support generating social cards in sphinxext-opengraph. +matplotlib + -c constraints.txt From 05084a8d041eac981cf433d94ef2e852e013cb7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Mon, 20 Jan 2025 18:29:17 +0000 Subject: [PATCH 2/5] Fix when using the local Python MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Filipe Laíns --- Doc/Makefile | 8 ++++++++ Doc/requirements-no-build.txt | 7 +++++++ Doc/requirements.txt | 3 --- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 Doc/requirements-no-build.txt diff --git a/Doc/Makefile b/Doc/Makefile index 1a66642a4a03ed..2727de25f8e1fa 100644 --- a/Doc/Makefile +++ b/Doc/Makefile @@ -13,7 +13,9 @@ JOBS = auto PAPER = SOURCES = DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py) +IS_PYTHON_BUILD = $(if $(shell $(PYTHON) -c 'import sys, sysconfig; sys.exit(sysconfig.is_python_build())'), true, false) REQUIREMENTS = requirements.txt +REQUIREMENTS_NO_BUILD = requirements-no-build.txt SPHINXERRORHANDLING = --fail-on-warning # Internal variables. @@ -174,10 +176,16 @@ venv: if $(UV) --version >/dev/null 2>&1; then \ $(UV) venv $(VENVDIR); \ VIRTUAL_ENV=$(VENVDIR) $(UV) pip install -r $(REQUIREMENTS); \ + if ! $(IS_PYTHON_BUILD); then \ + VIRTUAL_ENV=$(VENVDIR) $(UV) pip install -r $(REQUIREMENTS_NO_BUILD); \ + fi; \ else \ $(PYTHON) -m venv $(VENVDIR); \ $(VENVDIR)/bin/python3 -m pip install --upgrade pip; \ $(VENVDIR)/bin/python3 -m pip install -r $(REQUIREMENTS); \ + if ! $(IS_PYTHON_BUILD); then \ + $(VENVDIR)/bin/python3 -m pip install -r $(REQUIREMENTS_NO_BUILD); \ + fi; \ fi; \ echo "The venv has been created in the $(VENVDIR) directory"; \ fi diff --git a/Doc/requirements-no-build.txt b/Doc/requirements-no-build.txt new file mode 100644 index 00000000000000..eb55fa4f876539 --- /dev/null +++ b/Doc/requirements-no-build.txt @@ -0,0 +1,7 @@ +# Requirements when not running the build Python, +# such as optional native extensions. + +--only-binary + +# Needed to support generating social cards in sphinxext-opengraph. +matplotlib diff --git a/Doc/requirements.txt b/Doc/requirements.txt index efc6352312a53c..32ff8f74d05bb6 100644 --- a/Doc/requirements.txt +++ b/Doc/requirements.txt @@ -18,7 +18,4 @@ sphinx-notfound-page~=1.0.0 # to install that as well. python-docs-theme>=2023.3.1,!=2023.7 -# Needed to support generating social cards in sphinxext-opengraph. -matplotlib - -c constraints.txt From 209b5b1e7997ea99a06a30d3f441742c77d3dc29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Mon, 20 Jan 2025 19:57:35 +0000 Subject: [PATCH 3/5] Simplify requirement install command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Filipe Laíns --- Doc/Makefile | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Doc/Makefile b/Doc/Makefile index 2727de25f8e1fa..ab098899dcd73d 100644 --- a/Doc/Makefile +++ b/Doc/Makefile @@ -13,7 +13,7 @@ JOBS = auto PAPER = SOURCES = DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py) -IS_PYTHON_BUILD = $(if $(shell $(PYTHON) -c 'import sys, sysconfig; sys.exit(sysconfig.is_python_build())'), true, false) +IS_PYTHON_BUILD = $(shell $(PYTHON) -c 'import sysconfig; print("true") if sysconfig.is_python_build() else None') REQUIREMENTS = requirements.txt REQUIREMENTS_NO_BUILD = requirements-no-build.txt SPHINXERRORHANDLING = --fail-on-warning @@ -168,6 +168,7 @@ clean-venv: .PHONY: venv venv: + requirements = -r $(REQUIREMENTS) $(if $(IS_PYTHON_BUILD),,-r $(REQUIREMENTS_NO_BUILD)) @if [ -d $(VENVDIR) ] ; then \ echo "venv already exists."; \ echo "To recreate it, remove it first with \`make clean-venv'."; \ @@ -175,17 +176,11 @@ venv: echo "Creating venv in $(VENVDIR)"; \ if $(UV) --version >/dev/null 2>&1; then \ $(UV) venv $(VENVDIR); \ - VIRTUAL_ENV=$(VENVDIR) $(UV) pip install -r $(REQUIREMENTS); \ - if ! $(IS_PYTHON_BUILD); then \ - VIRTUAL_ENV=$(VENVDIR) $(UV) pip install -r $(REQUIREMENTS_NO_BUILD); \ - fi; \ + VIRTUAL_ENV=$(VENVDIR) $(UV) pip install $(requirements); \ else \ $(PYTHON) -m venv $(VENVDIR); \ $(VENVDIR)/bin/python3 -m pip install --upgrade pip; \ - $(VENVDIR)/bin/python3 -m pip install -r $(REQUIREMENTS); \ - if ! $(IS_PYTHON_BUILD); then \ - $(VENVDIR)/bin/python3 -m pip install -r $(REQUIREMENTS_NO_BUILD); \ - fi; \ + $(VENVDIR)/bin/python3 -m pip install $(requirements); \ fi; \ echo "The venv has been created in the $(VENVDIR) directory"; \ fi From f21ec5ddd893d9926254e3752758fc6d5549737e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Mon, 20 Jan 2025 20:08:43 +0000 Subject: [PATCH 4/5] Simplify the requirements setup further MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Filipe Laíns --- Doc/Makefile | 8 +++----- Doc/requirements-no-build.txt | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/Makefile b/Doc/Makefile index 971edd34ac2c64..53af6aca659cef 100644 --- a/Doc/Makefile +++ b/Doc/Makefile @@ -14,8 +14,7 @@ PAPER = SOURCES = DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py) IS_PYTHON_BUILD = $(shell $(PYTHON) -c 'import sysconfig; print("true") if sysconfig.is_python_build() else None') -REQUIREMENTS = requirements.txt -REQUIREMENTS_NO_BUILD = requirements-no-build.txt +REQUIREMENTS = $(if $(IS_PYTHON_BUILD),requirements.txt,requirements-no-build.txt) SPHINXERRORHANDLING = --fail-on-warning # Internal variables. @@ -168,7 +167,6 @@ clean-venv: .PHONY: venv venv: - requirements = -r $(REQUIREMENTS) $(if $(IS_PYTHON_BUILD),,-r $(REQUIREMENTS_NO_BUILD)) @if [ -d $(VENVDIR) ] ; then \ echo "venv already exists."; \ echo "To recreate it, remove it first with \`make clean-venv'."; \ @@ -176,11 +174,11 @@ venv: echo "Creating venv in $(VENVDIR)"; \ if $(UV) --version >/dev/null 2>&1; then \ $(UV) venv --python=$(PYTHON) $(VENVDIR); \ - VIRTUAL_ENV=$(VENVDIR) $(UV) pip install $(requirements); \ + VIRTUAL_ENV=$(VENVDIR) $(UV) pip install -r $(REQUIREMENTS); \ else \ $(PYTHON) -m venv $(VENVDIR); \ $(VENVDIR)/bin/python3 -m pip install --upgrade pip; \ - $(VENVDIR)/bin/python3 -m pip install $(requirements); \ + $(VENVDIR)/bin/python3 -m pip install -r $(REQUIREMENTS); \ fi; \ echo "The venv has been created in the $(VENVDIR) directory"; \ fi diff --git a/Doc/requirements-no-build.txt b/Doc/requirements-no-build.txt index eb55fa4f876539..ed11f187e5cf4b 100644 --- a/Doc/requirements-no-build.txt +++ b/Doc/requirements-no-build.txt @@ -1,3 +1,5 @@ +-r requirements.txt + # Requirements when not running the build Python, # such as optional native extensions. From 6900f8e2f740f953daa819587e925547fe850ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Mon, 20 Jan 2025 20:12:29 +0000 Subject: [PATCH 5/5] Fix --only-binary flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Filipe Laíns --- Doc/requirements-no-build.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Doc/requirements-no-build.txt b/Doc/requirements-no-build.txt index ed11f187e5cf4b..8b3c4d410a75a3 100644 --- a/Doc/requirements-no-build.txt +++ b/Doc/requirements-no-build.txt @@ -3,7 +3,5 @@ # Requirements when not running the build Python, # such as optional native extensions. ---only-binary - # Needed to support generating social cards in sphinxext-opengraph. -matplotlib +--only-binary matplotlib