You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by GitBox <gi...@apache.org> on 2021/02/04 09:11:21 UTC

[GitHub] [qpid-proton] jiridanek commented on a change in pull request #294: PROTON-2217 Prefer first working Python on PATH, prefer Py3 over Py2

jiridanek commented on a change in pull request #294:
URL: https://github.com/apache/qpid-proton/pull/294#discussion_r570058120



##########
File path: CMakeLists.txt
##########
@@ -32,7 +32,27 @@ include (CheckPythonModule)
 
 find_package (OpenSSL)
 find_package (Threads)
-find_package (PythonInterp REQUIRED)
+# FindPython was added in CMake 3.12, but there it always returned
+#  newest Python on the entire PATH. We want to use the first one.
+if (CMAKE_VERSION VERSION_LESS "3.15.0")
+  find_package (PythonInterp REQUIRED)
+  # forward compatibility with FindPython
+  set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}")
+  set(Python_LIBRARIES "${PYTHON_LIBRARIES}")
+  set(Python_INCLUDE_DIRS "${PYTHON_INCLUDE_PATH}")
+  set(Python_VERSION_STRING "${PYTHON_VERSION_STRING}")
+  # for completeness, these are not actually used now
+  set(Python_VERSION_MAJOR "${PYTHON_VERSION_MAJOR}")
+  set(Python_VERSION_MINOR "${PYTHON_VERSION_MINOR}")
+  set(Python_VERSION_PATCH "${PYTHON_VERSION_PATCH}")
+else ()
+  if (POLICY CMP0094)  # https://cmake.org/cmake/help/latest/policy/CMP0094.html
+    cmake_policy(SET CMP0094 NEW)  # FindPython should return the first matching Python on PATH
+  endif ()
+
+  find_package(Python REQUIRED COMPONENTS Interpreter
+          OPTIONAL_COMPONENTS Development)
+endif()

Review comment:
       Is this going to work? Because my own FindPython.cmake will end up shadowing the CMake3's find_package(Python), I think. Not sure, I'll have to try that.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org