Browse Source

HPCC-23640 Force failure if Python development libs not found

Signed-off-by: Michael Gardner <michael.gardner@lexisnexisrisk.com>
Michael Gardner 5 years ago
parent
commit
ba97c5b344
3 changed files with 81 additions and 114 deletions
  1. 2 2
      plugins/CMakeLists.txt
  2. 34 51
      plugins/py3embed/CMakeLists.txt
  3. 45 61
      plugins/pyembed/CMakeLists.txt

+ 2 - 2
plugins/CMakeLists.txt

@@ -29,8 +29,8 @@ add_subdirectory (proxies)
 add_subdirectory (sqlite3)
 add_subdirectory (mysql)
 add_subdirectory (v8embed)
-add_subdirectory (py3embed)
-add_subdirectory (pyembed)
+HPCC_ADD_SUBDIRECTORY (py3embed "USE_PYTHON3")
+HPCC_ADD_SUBDIRECTORY (pyembed "USE_PYTHON2")
 add_subdirectory (javaembed)
 add_subdirectory (Rembed)
 add_subdirectory (cassandra)

+ 34 - 51
plugins/py3embed/CMakeLists.txt

@@ -24,64 +24,47 @@
 #####################################################
 
 project(py3embed)
-if(USE_PYTHON3)
-    unset(PYTHONLIBS_FOUND CACHE)
-    unset(PYTHON_LIBRARY CACHE)
-    unset(PYTHON_LIBRARIES CACHE)
-    unset(PYTHON_INCLUDE_PATH CACHE)
-    unset(PYTHON_INCLUDE_DIR CACHE)
-    unset(PYTHON_DEBUG_LIBRARIES CACHE)
-    unset(PYTHONLIBS_VERSION_STRING CACHE)
-    ADD_PLUGIN(py3embed PACKAGES PythonLibs MINVERSION 3.3)
-    set(PYTHON3LIBS_FOUND ${PYTHONLIBS_FOUND} CACHE BOOL "Found Python3 Libraries")
-    set(PYTHON3_LIBRARY ${PYTHON_LIBRARY} CACHE PATH "Library")
-    set(PYTHON3_LIBRARIES ${PYTHON_LIBRARIES} CACHE PATH "Libraries")
-    set(PYTHON3_INCLUDE_PATH ${PYTHON_INCLUDE_PATH} CACHE PATH "Include path")
-    set(PYTHON3_INCLUDE_DIR ${PYTHON_INCLUDE_DIR} CACHE PATH "Include dir")
-    set(PYTHON3_DEBUG_LIBRARIES ${PYTHON_DEBUG_LIBRARIES} CACHE PATH "Include Debug Libraries")
-    set(PYTHON3LIBS_VERSION_STRING ${PYTHONLIBS_VERSION_STRING} CACHE STRING "Version")
-    message("Python3 library is ${PYTHON3_LIBRARY}")
 
-    if(MAKE_PY3EMBED)
-        set(
-            SRCS
-            py3embed.cpp)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter Development)
 
-        include_directories(
-            "${PYTHON3_INCLUDE_DIR}"
-            ./../../system/include
-            ./../../rtl/eclrtl
-            ./../../rtl/include
-            ./../../rtl/nbcd
-            ./../../common/deftype
-            ./../../common/thorhelper
-            ./../../dali/base
-            ./../../system/mp
-            ./../../roxie/roxiemem
-            ./../../system/jlib)
+set(
+    SRCS
+    py3embed.cpp)
 
-        add_definitions(-D_USRDLL -DPY3EMBED_EXPORTS)
+include_directories(
+    "${Python3_INCLUDE_DIRS}"
+    ./../../system/include
+    ./../../rtl/eclrtl
+    ./../../rtl/include
+    ./../../rtl/nbcd
+    ./../../common/deftype
+    ./../../common/thorhelper
+    ./../../dali/base
+    ./../../system/mp
+    ./../../roxie/roxiemem
+    ./../../system/jlib)
 
-        HPCC_ADD_LIBRARY(py3embed SHARED ${SRCS})
-        if(${CMAKE_VERSION} VERSION_LESS "2.8.9")
-            message(WARNING "Cannot set NO_SONAME. shlibdeps will give warnings when package is installed")
-        elseif(NOT APPLE)
-            set_target_properties(py3embed PROPERTIES NO_SONAME 1)
-        endif()
+add_definitions(-D_USRDLL -DPY3EMBED_EXPORTS)
 
-        install(
-            TARGETS py3embed
-            DESTINATION versioned/python3)
+HPCC_ADD_LIBRARY(py3embed SHARED ${SRCS})
+if(${CMAKE_VERSION} VERSION_LESS "2.8.9")
+    message(WARNING "Cannot set NO_SONAME. shlibdeps will give warnings when package is installed")
+elseif(NOT APPLE)
+    set_target_properties(py3embed PROPERTIES NO_SONAME 1)
+endif()
 
-        target_link_libraries(py3embed ${PYTHON3_LIBRARY})
+install(
+    TARGETS py3embed
+    DESTINATION versioned/python3)
+
+target_link_libraries(py3embed ${Python3_LIBRARIES})
+
+target_link_libraries(
+    py3embed
+    eclrtl
+    roxiemem
+    jlib)
 
-        target_link_libraries(
-            py3embed
-            eclrtl
-            roxiemem
-            jlib)
-    endif()
-endif()
 if(PLATFORM OR CLIENTTOOLS_ONLY)
     install(
         FILES ${CMAKE_CURRENT_SOURCE_DIR}/python3.ecllib

+ 45 - 61
plugins/pyembed/CMakeLists.txt

@@ -28,73 +28,57 @@ set(DEBUG_PYTHON_LIBRARY "/usr/lib/libpython2.7_d.so")
 
 project(py2embed)
 
-if(USE_PYTHON2)
-    unset(PYTHONLIBS_FOUND CACHE)
-    unset(PYTHON_LIBRARY CACHE)
-    unset(PYTHON_LIBRARIES CACHE)
-    unset(PYTHON_INCLUDE_PATH CACHE)
-    unset(PYTHON_INCLUDE_DIR CACHE)
-    unset(PYTHON_DEBUG_LIBRARIES CACHE)
-    unset(PYTHONLIBS_VERSION_STRING CACHE)
-    ADD_PLUGIN(py2embed PACKAGES PythonLibs MINVERSION 2.6 MAXVERSION 2.7)
-    set(PYTHON2LIBS_FOUND ${PYTHONLIBS_FOUND} CACHE BOOL "Found Python2 Libraries")
-    set(PYTHON2_LIBRARY ${PYTHON_LIBRARY} CACHE PATH "Library")
-    set(PYTHON2_LIBRARIES ${PYTHON_LIBRARIES} CACHE PATH "Libraries")
-    set(PYTHON2_INCLUDE_PATH ${PYTHON_INCLUDE_PATH} CACHE PATH "Include path")
-    set(PYTHON2_INCLUDE_DIR ${PYTHON_INCLUDE_DIR} CACHE PATH "Include dir")
-    set(PYTHON2_DEBUG_LIBRARIES ${PYTHON_DEBUG_LIBRARIES} CACHE PATH "Include Debug Libraries")
-    set(PYTHON2LIBS_VERSION_STRING ${PYTHONLIBS_VERSION_STRING} CACHE STRING "Version")
-    message("Python2 library is ${PYTHON2_LIBRARY}")
-    if(MAKE_PY2EMBED)
-        set(
-            SRCS
-            pyembed.cpp)
+find_package(Python2 2.6 REQUIRED COMPONENTS Interpreter Development)
 
-        include_directories(
-            "${PYTHON2_INCLUDE_DIR}"
-            ./../../system/include
-            ./../../rtl/eclrtl
-            ./../../rtl/include
-            ./../../rtl/nbcd
-            ./../../common/deftype
-            ./../../common/thorhelper
-            ./../../dali/base
-            ./../../system/mp
-            ./../../roxie/roxiemem
-            ./../../system/jlib)
+set(
+    SRCS
+    pyembed.cpp)
 
-        add_definitions(-D_USRDLL -DPY2EMBED_EXPORTS)
-        if(debug_python)
-            add_definitions(-DPy_DEBUG)
-        endif()
+include_directories(
+    "${Python2_INCLUDE_DIRS}"
+    ./../../system/include
+    ./../../rtl/eclrtl
+    ./../../rtl/include
+    ./../../rtl/nbcd
+    ./../../common/deftype
+    ./../../common/thorhelper
+    ./../../dali/base
+    ./../../system/mp
+    ./../../roxie/roxiemem
+    ./../../system/jlib)
 
-        HPCC_ADD_LIBRARY(py2embed SHARED ${SRCS})
-        if(${CMAKE_VERSION} VERSION_LESS "2.8.9")
-            message(WARNING "Cannot set NO_SONAME. shlibdeps will give warnings when package is installed")
-        elseif(NOT APPLE)
-            set_target_properties(py2embed PROPERTIES NO_SONAME 1)
-        endif()
+add_definitions(-D_USRDLL -DPY2EMBED_EXPORTS)
+if(debug_python)
+    add_definitions(-DPy_DEBUG)
+endif()
+
+HPCC_ADD_LIBRARY(py2embed SHARED ${SRCS})
+if(${CMAKE_VERSION} VERSION_LESS "2.8.9")
+    message(WARNING "Cannot set NO_SONAME. shlibdeps will give warnings when package is installed")
+elseif(NOT APPLE)
+    set_target_properties(py2embed PROPERTIES NO_SONAME 1)
+endif()
 
-        install(
-            TARGETS py2embed
-            DESTINATION versioned/python2)
-        if(debug_python)
-            target_link_libraries(py2embed ${DEBUG_PYTHON2_LIBRARY})
-        else()
-            target_link_libraries(py2embed ${PYTHON2_LIBRARY})
-        endif()
+install(
+    TARGETS py2embed
+    DESTINATION versioned/python2)
+if(debug_python)
+    target_link_libraries(py2embed ${DEBUG_PYTHON2_LIBRARY})
+else()
+    target_link_libraries(py2embed ${Python2_LIBRARIES})
+endif()
+
+target_link_libraries(
+    py2embed
+    eclrtl
+    roxiemem
+    jlib)
 
-        target_link_libraries(
-            py2embed
-            eclrtl
-            roxiemem
-            jlib)
-    endif()
-    if ( PLATFORM )
-        install ( PROGRAMS pyembed.install DESTINATION etc/init.d/install COMPONENT Runtime )
-        install ( PROGRAMS pyembed.uninstall DESTINATION etc/init.d/uninstall COMPONENT Runtime )
-    endif()
+if ( PLATFORM )
+    install ( PROGRAMS pyembed.install DESTINATION etc/init.d/install COMPONENT Runtime )
+    install ( PROGRAMS pyembed.uninstall DESTINATION etc/init.d/uninstall COMPONENT Runtime )
 endif()
+
 if(PLATFORM OR CLIENTTOOLS_ONLY)
     install(
         FILES ${CMAKE_CURRENT_SOURCE_DIR}/python.ecllib