]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cmake: use exact version of python if minor version is specified
authorKefu Chai <kchai@redhat.com>
Tue, 23 Jul 2019 05:57:43 +0000 (13:57 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 23 Jul 2019 16:45:22 +0000 (00:45 +0800)
`find_package(Python ${version}...)` tries to find the greater python version
which is greater than `${version}`, on fc30, at the time of writing, both
python3.8 and python3.7 are offered. but `python3-Cython` is packaged only
for python3.7. so if user installs python3.8, this will prevent user from
building Ceph. as Ceph will not be able to find Cython python module, as it
will try to run `python3.8 -m cython --version`, where python3.8 is the
greatest python version available in the system. but since cython module is
not available to python3.8, cmake will fail to find cython even if is available
to python3.7.

in this change, if user specifies a python version with minor version, we
will use the exact specified version instead of trying to use a version
greater than the specified one.

Signed-off-by: Kefu Chai <kchai@redhat.com>
CMakeLists.txt
src/CMakeLists.txt

index b533465b9c9968c4732151b5c9956570b2f0237b..ebf5cd92cdadf0ad038637c1a64002990af2c3fb 100644 (file)
@@ -499,9 +499,13 @@ if(WITH_MGR)
   # Please specify 3 or 3.[0-7] if you want to build with python3 support.
   # FindPython thinks they belong to different families.
   set(MGR_PYTHON_VERSION "2.7" CACHE
-    STRING "minimal required version of python runtime for running mgr plugins. ")
-  find_package(Python ${MGR_PYTHON_VERSION} REQUIRED
+    STRING "required version of python runtime for running mgr plugins. ")
+  if(NOT MGR_PYTHON_VERSION MATCHES "^[23]$")
+    set(find_python_exact "EXACT")
+  endif()
+  find_package(Python ${MGR_PYTHON_VERSION} ${find_python_exact} REQUIRED
     COMPONENTS Interpreter Development)
+  unset(find_python_exact)
   set(MGR_PYTHON_EXECUTABLE ${Python_EXECUTABLE})
   set(MGR_PYTHON_LIBRARIES ${Python_LIBRARIES})
   set(MGR_PYTHON_VERSION_MAJOR ${Python_VERSION_MAJOR})
index d1334bda844f17caf8ab11c2f315496211ca943b..d945268f41f018bac18fc0f8f9aedb627d521d0a 100644 (file)
@@ -240,8 +240,12 @@ if(WITH_PYTHON3)
   if(WITH_PYTHON3 MATCHES "^(1|ON|YES|TRUE|Y)$")
     set(WITH_PYTHON3 "3")
   endif()
-  find_package(Python3 ${WITH_PYTHON3} REQUIRED
+  if(NOT WITH_PYTHON3 STREQUAL "3")
+    set(find_python3_exact "EXACT")
+  endif()
+  find_package(Python3 ${WITH_PYTHON3} ${find_python3_exact} REQUIRED
     COMPONENTS Interpreter Development)
+  unset(find_python3_exact)
 endif()
 
 # the major version of the python bindings as a dependency of other