mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -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 ""
|
PREFIX ""
|
||||||
SUFFIX "${PYTHON_EXTENSION_SUFFIX}")
|
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()
|
else()
|
||||||
set_target_properties(${target} PROPERTIES
|
set_target_properties(${target} PROPERTIES
|
||||||
OUTPUT_NAME "${basename}"
|
OUTPUT_NAME "${basename}"
|
||||||
|
@ -7,10 +7,9 @@ set(WANT_PYTHON_VERSION ""
|
|||||||
|
|
||||||
find_package(PythonInterp ${WANT_PYTHON_VERSION} QUIET)
|
find_package(PythonInterp ${WANT_PYTHON_VERSION} QUIET)
|
||||||
find_package(PythonLibs ${PYTHON_VERSION_STRING} QUIET)
|
find_package(PythonLibs ${PYTHON_VERSION_STRING} QUIET)
|
||||||
if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
|
|
||||||
|
if(PYTHONLIBS_FOUND)
|
||||||
set(PYTHON_FOUND ON)
|
set(PYTHON_FOUND ON)
|
||||||
else()
|
|
||||||
set(PYTHON_FOUND OFF)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
package_option(PYTHON DEFAULT ON
|
package_option(PYTHON DEFAULT ON
|
||||||
@ -19,16 +18,26 @@ is also enabled, Python bindings will be generated.")
|
|||||||
|
|
||||||
# Also detect the optimal install paths:
|
# Also detect the optimal install paths:
|
||||||
if(HAVE_PYTHON)
|
if(HAVE_PYTHON)
|
||||||
execute_process(
|
if(WIN32 AND NOT CYGWIN)
|
||||||
COMMAND ${PYTHON_EXECUTABLE}
|
set(_LIB_DIR ".")
|
||||||
-c "from distutils.sysconfig import get_python_lib; print(get_python_lib(False))"
|
set(_ARCH_DIR ".")
|
||||||
OUTPUT_VARIABLE _LIB_DIR
|
elseif(PYTHON_EXECUTABLE)
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
execute_process(
|
||||||
execute_process(
|
COMMAND ${PYTHON_EXECUTABLE}
|
||||||
COMMAND ${PYTHON_EXECUTABLE}
|
-c "from distutils.sysconfig import get_python_lib; print(get_python_lib(False))"
|
||||||
-c "from distutils.sysconfig import get_python_lib; print(get_python_lib(True))"
|
OUTPUT_VARIABLE _LIB_DIR
|
||||||
OUTPUT_VARIABLE _ARCH_DIR
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
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(
|
execute_process(
|
||||||
COMMAND ${PYTHON_EXECUTABLE}
|
COMMAND ${PYTHON_EXECUTABLE}
|
||||||
-c "from sysconfig import get_config_var as g; print((g('EXT_SUFFIX') or g('SO'))[:])"
|
-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