[Openvpn-devel,v2] Ensure that Python3 is available

Message ID 20241227112255.11992-1-gert@greenie.muc.de
State Accepted
Headers show
Series [Openvpn-devel,v2] Ensure that Python3 is available | expand

Commit Message

Gert Doering Dec. 27, 2024, 11:22 a.m. UTC
From: Arne Schwabe <arne@openvpn.net>

Use the more standard cmake find_package to search for Python3 and make it required. This also provides
a better error message than "version.cmake" not found when python3 is missing.

Change-Id: I350fd615ed8474d34392a057a5f8bded78173949
Signed-off-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/846
This mail reflects revision 2 of this Change.

Signed-off-by line for the author was added as per our policy.

Acked-by according to Gerrit (reflected above):
Lev Stipakov <lstipakov@gmail.com>

Comments

Gert Doering Dec. 27, 2024, 11:53 a.m. UTC | #1
Whatever this python thingie is... but GHA tells me that it builds fine,
and people that do care tell me the patch is +2'ed, so, here we go :-)

Your patch has been applied to the master branch.

commit e4c68b23e26efcfa301ae4aec4f4fc65384ab9eb
Author: Arne Schwabe
Date:   Fri Dec 27 12:22:55 2024 +0100

     Ensure that Python3 is available

     Signed-off-by: Arne Schwabe <arne-openvpn@rfc2549.org>
     Acked-by: Lev Stipakov <lstipakov@gmail.com>
     Message-Id: <20241227112255.11992-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30232.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 61f0cc5..fc94a10 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -107,9 +107,9 @@ 
     endif ()
 endif ()
 
-find_program(PYTHON NAMES python3 python)
+find_package(Python3 REQUIRED COMPONENTS Interpreter)
 execute_process(
-    COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/cmake/parse-version.m4.py ${CMAKE_CURRENT_SOURCE_DIR}/version.m4
+    COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/cmake/parse-version.m4.py ${CMAKE_CURRENT_SOURCE_DIR}/version.m4
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
     )
 include(${CMAKE_CURRENT_BINARY_DIR}/version.cmake)
@@ -339,7 +339,7 @@ 
 
 add_custom_command(
     OUTPUT always_rebuild config-version.h
-    COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/cmake/git-version.py
+    COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/cmake/git-version.py
     )
 set(HAVE_CONFIG_VERSION_H YES)