CMake: install Python executable when its bundled
authorCampbell Barton <ideasman42@gmail.com>
Tue, 19 May 2015 05:56:28 +0000 (15:56 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 19 May 2015 06:44:19 +0000 (16:44 +1000)
CMakeLists.txt
build_files/cmake/Modules/FindPythonLibsUnix.cmake
source/creator/CMakeLists.txt

index 9d41c4975a4f2790f0a910ddde090da698d2c0e0..176d13b86afa6290eea1c26b6dd6a9f3266f63c8 100644 (file)
@@ -1844,14 +1844,14 @@ elseif(APPLE)
                if(NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
                        # normally cached but not since we include them with blender
                        set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}m")
-                       # set(PYTHON_BINARY "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet
+                       # set(PYTHON_EXECUTABLE "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet
                        set(PYTHON_LIBRARY python${PYTHON_VERSION}m)
                        set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}")
                        # set(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
                else()
                        # module must be compiled against Python framework
                        set(PYTHON_INCLUDE_DIR "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/include/python${PYTHON_VERSION}m")
-                       set(PYTHON_BINARY "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/bin/python${PYTHON_VERSION}")
+                       set(PYTHON_EXECUTABLE "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/bin/python${PYTHON_VERSION}")
                        #set(PYTHON_LIBRARY python${PYTHON_VERSION})
                        set(PYTHON_LIBPATH "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config-${PYTHON_VERSION}m")
                        #set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework Python")  # won't  build with this enabled
index 555ca4cf0a047742acedaa6881cc1b406409158b..e4236fb4c249094d9fe8bd408601f7d29402e9d2 100644 (file)
@@ -66,6 +66,14 @@ IF(DEFINED PYTHON_LIBPATH)
   SET(_IS_LIB_PATH_DEF ON)
 ENDIF()
 
+STRING(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
+
+SET(_python_SEARCH_DIRS
+  ${PYTHON_ROOT_DIR}
+  "$ENV{HOME}/py${_PYTHON_VERSION_NO_DOTS}"
+  "/opt/py${_PYTHON_VERSION_NO_DOTS}"
+  "/opt/lib/python-${PYTHON_VERSION}"
+)
 
 # only search for the dirs if we havn't already
 IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_LIB_PATH_DEF))
@@ -75,14 +83,7 @@ IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_
     "dm;dmu;du;d" # debug
   )
 
-  STRING(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
 
-  SET(_python_SEARCH_DIRS
-    ${PYTHON_ROOT_DIR}
-    "$ENV{HOME}/py${_PYTHON_VERSION_NO_DOTS}"
-    "/opt/py${_PYTHON_VERSION_NO_DOTS}"
-    "/opt/lib/python-${PYTHON_VERSION}"
-  )
 
   FOREACH(_CURRENT_ABI_FLAGS ${_python_ABI_FLAGS})
     #IF(CMAKE_BUILD_TYPE STREQUAL Debug)
@@ -147,6 +148,7 @@ IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_
     ENDIF()
 
     IF(PYTHON_LIBRARY AND PYTHON_LIBPATH AND PYTHON_INCLUDE_DIR AND PYTHON_INCLUDE_CONFIG_DIR)
+      SET(_PYTHON_ABI_FLAGS "${_CURRENT_ABI_FLAGS}")
       break()
     ELSE()
       # ensure we dont find values from 2 different ABI versions
@@ -169,7 +171,6 @@ IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_
   UNSET(_CURRENT_PATH)
 
   UNSET(_python_ABI_FLAGS)
-  UNSET(_python_SEARCH_DIRS)
 ENDIF()
 
 UNSET(_IS_INC_DEF)
@@ -201,14 +202,28 @@ IF(PYTHONLIBSUNIX_FOUND)
   # XXX No more valid with debian-like py3.4 packages...
 #  GET_FILENAME_COMPONENT(PYTHON_LIBPATH ${PYTHON_LIBRARY} PATH)
 
-  # not used
-  # SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
+  # not required for build, just used when bundling Python.
+  FIND_PROGRAM(
+    PYTHON_EXECUTABLE
+    NAMES
+      "python${PYTHON_VERSION}${_PYTHON_ABI_FLAGS}"
+      "python${PYTHON_VERSION}"
+      "python"
+    HINTS
+      ${_python_SEARCH_DIRS}
+    PATH_SUFFIXES bin
+  )
 ENDIF()
 
+UNSET(_PYTHON_VERSION_NO_DOTS)
+UNSET(_PYTHON_ABI_FLAGS)
+UNSET(_python_SEARCH_DIRS)
+
 MARK_AS_ADVANCED(
   PYTHON_INCLUDE_DIR
   PYTHON_INCLUDE_CONFIG_DIR
   PYTHON_LIBRARY
   PYTHON_LIBPATH
   PYTHON_SITE_PACKAGES
+  PYTHON_EXECUTABLE
 )
index ffaf6f42b189ae1505e70336369d6d3e0b2119e7..5e0288ea3d615845c53c1f6bc33964b7643327a1 100644 (file)
@@ -494,6 +494,12 @@ if(UNIX AND NOT APPLE)
 
        if(WITH_PYTHON)
                if(WITH_PYTHON_INSTALL)
+
+                       install(
+                               FILES ${PYTHON_EXECUTABLE}
+                               DESTINATION ${TARGETDIR_VER}/python/bin
+                       )
+
                        # on some platforms (like openSUSE) Python is linked
                        # to be used from lib64 folder.
                        # determine this from Python's libraries path