mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
CMake: Don't depend on Python interpreter
This allows building against the Python libraries even when the Python interpreter/executable is missing. The correct extensions for the binary modules will be guessed, the tests will fail, and the bytecode for any pure-Python modules will not be precompiled.
This commit is contained in:
parent
53920e7aee
commit
0997c6b19c
@ -39,7 +39,9 @@ function(add_python_target target)
|
||||
PREFIX ""
|
||||
SUFFIX "${PYTHON_EXTENSION_SUFFIX}")
|
||||
|
||||
install(TARGETS ${target} DESTINATION "${PYTHON_ARCH_INSTALL_DIR}/${slash_namespace}")
|
||||
if(PYTHON_ARCH_INSTALL_DIR)
|
||||
install(TARGETS ${target} DESTINATION "${PYTHON_ARCH_INSTALL_DIR}/${slash_namespace}")
|
||||
endif()
|
||||
else()
|
||||
set_target_properties(${target} PROPERTIES
|
||||
OUTPUT_NAME "${basename}"
|
||||
|
@ -7,10 +7,9 @@ set(WANT_PYTHON_VERSION ""
|
||||
|
||||
find_package(PythonInterp ${WANT_PYTHON_VERSION} QUIET)
|
||||
find_package(PythonLibs ${PYTHON_VERSION_STRING} QUIET)
|
||||
if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
|
||||
|
||||
if(PYTHONLIBS_FOUND)
|
||||
set(PYTHON_FOUND ON)
|
||||
else()
|
||||
set(PYTHON_FOUND OFF)
|
||||
endif()
|
||||
|
||||
package_option(PYTHON DEFAULT ON
|
||||
@ -19,16 +18,26 @@ is also enabled, Python bindings will be generated.")
|
||||
|
||||
# Also detect the optimal install paths:
|
||||
if(HAVE_PYTHON)
|
||||
execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE}
|
||||
-c "from distutils.sysconfig import get_python_lib; print(get_python_lib(False))"
|
||||
OUTPUT_VARIABLE _LIB_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE}
|
||||
-c "from distutils.sysconfig import get_python_lib; print(get_python_lib(True))"
|
||||
OUTPUT_VARIABLE _ARCH_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
set(_LIB_DIR ".")
|
||||
set(_ARCH_DIR ".")
|
||||
elseif(PYTHON_EXECUTABLE)
|
||||
execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE}
|
||||
-c "from distutils.sysconfig import get_python_lib; print(get_python_lib(False))"
|
||||
OUTPUT_VARIABLE _LIB_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE}
|
||||
-c "from distutils.sysconfig import get_python_lib; print(get_python_lib(True))"
|
||||
OUTPUT_VARIABLE _ARCH_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
else()
|
||||
set(_LIB_DIR "")
|
||||
set(_ARCH_DIR "")
|
||||
endif()
|
||||
|
||||
|
||||
execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE}
|
||||
-c "from sysconfig import get_config_var as g; print((g('EXT_SUFFIX') or g('SO'))[:])"
|
||||
|
Loading…
x
Reference in New Issue
Block a user