From fe2c03d86fb2eac2d201c6c654152e5d54c566dd Mon Sep 17 00:00:00 2001
From: Marc-Olivier Andrez <marc-olivier.andrez@desy.de>
Date: Tue, 7 May 2024 15:51:43 +0200
Subject: [PATCH] ci: use Python interpreter found by CMake when building
 sphinx doc

Rationale: using possibly different Python interpreters for the
different task can make the installation of packages required by the
different interpreters more complicated.
---
 docs/sphinx/CMakeLists.txt | 4 ++--
 docs/sphinx/Makefile       | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/docs/sphinx/CMakeLists.txt b/docs/sphinx/CMakeLists.txt
index 9da6590e7..55bfba414 100644
--- a/docs/sphinx/CMakeLists.txt
+++ b/docs/sphinx/CMakeLists.txt
@@ -1,10 +1,10 @@
 file(COPY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
 
-
+find_package(Python3 REQUIRED COMPONENTS Interpreter)
 add_custom_target(
         docs-py ALL
         COMMAND
-        make html VERBATIM
+        make html PYTHON_INTERPRETER=${Python3_EXECUTABLE} VERBATIM
         WORKING_DIRECTORY sphinx
 )
 
diff --git a/docs/sphinx/Makefile b/docs/sphinx/Makefile
index b359b1da2..41b4c40af 100644
--- a/docs/sphinx/Makefile
+++ b/docs/sphinx/Makefile
@@ -2,8 +2,9 @@
 #
 
 # You can set these variables from the command line.
+PYTHON_INTERPRETER = python3
 SPHINXOPTS    =
-SPHINXBUILD   = python3 -msphinx
+SPHINXBUILD   = ${PYTHON_INTERPRETER} -m sphinx
 SPHINXPROJ    = ASAPO
 SOURCEDIR     = source
 BUILDDIR      = build
@@ -17,4 +18,4 @@ help:
 # Catch-all target: route all unknown targets to Sphinx using the new
 # "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
 %: Makefile
-	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
\ No newline at end of file
+	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
-- 
GitLab