mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
CMake: Move pandac compatibility-shim generation to a more sensible place.
This commit is contained in:
parent
1f83a54524
commit
7f9e25fb84
@ -49,3 +49,33 @@ endif()
|
||||
if(BUILD_PANDATOOL)
|
||||
add_subdirectory(pandatool)
|
||||
endif()
|
||||
|
||||
# This bit is to generate the 'pandac' compatibility shim. It's deprecated now,
|
||||
# but in older versions of Panda3D, one would use
|
||||
# from pandac.PandaModules import *
|
||||
# instead of
|
||||
# from panda3d.FOO import *
|
||||
if(HAVE_PYTHON)
|
||||
# Generate PandaModules:
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pandac/PandaModules.py"
|
||||
"\"This module is deprecated. Import from panda3d.core and other panda3d.* modules instead.\"
|
||||
|
||||
print(\"Warning: pandac.PandaModules is deprecated, import from panda3d.core instead\")\n")
|
||||
|
||||
foreach(module ${ALL_INTERROGATE_MODULES})
|
||||
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/PandaModules.py" "
|
||||
try:
|
||||
from panda3d.${module} import *
|
||||
except ImportError as err:
|
||||
if \"No module named %s\" not in str(err):
|
||||
raise
|
||||
")
|
||||
endforeach()
|
||||
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pandac/__init__.py" "")
|
||||
|
||||
# Now install ourselves:
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/pandac/__init__.py" "${CMAKE_CURRENT_BINARY_DIR}/pandac/PandaModules.py"
|
||||
DESTINATION "${PYTHON_LIB_INSTALL_DIR}/pandac")
|
||||
endif()
|
||||
|
@ -40,6 +40,3 @@ if(HAVE_PYTHON)
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/__init__.py"
|
||||
DESTINATION "${PYTHON_LIB_INSTALL_DIR}/direct")
|
||||
endif()
|
||||
|
||||
# pandac has its own installation steps necessary:
|
||||
add_subdirectory(src/pandac)
|
||||
|
@ -1,15 +0,0 @@
|
||||
if(HAVE_PYTHON)
|
||||
# Generate PandaModules:
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/PandaModules.py"
|
||||
"# Generated by CMake; edits not preserved\n")
|
||||
foreach(module ${ALL_INTERROGATE_MODULES})
|
||||
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/PandaModules.py"
|
||||
"from panda3d.${module} import *\n")
|
||||
endforeach()
|
||||
|
||||
# Now install ourselves:
|
||||
file(GLOB python_sources "${CMAKE_CURRENT_SOURCE_DIR}/*.py")
|
||||
install(
|
||||
FILES ${python_sources} "${CMAKE_CURRENT_BINARY_DIR}/PandaModules.py"
|
||||
DESTINATION "${PYTHON_LIB_INSTALL_DIR}/pandac")
|
||||
endif()
|
@ -1,30 +0,0 @@
|
||||
# N.B. PandaModules is generated at build time by CMake
|
||||
from PandaModules import *
|
||||
import __builtin__
|
||||
|
||||
# Now import all extensions:
|
||||
from direct.extensions_native.extension_native_helpers import *
|
||||
extensions = [
|
||||
'CInterval', 'HTTPChannel', 'Mat3', 'NodePath', 'VBase3', 'VBase4'
|
||||
]
|
||||
|
||||
# Prior to importing, we need to make the Dtool_funcToMethod function and
|
||||
# the extended class available globally. This is hacky, but tacking it on
|
||||
# __builtin__ works just fine:
|
||||
import __builtin__
|
||||
__builtin__.Dtool_funcToMethod = Dtool_funcToMethod
|
||||
__builtin__.Dtool_ObjectToDict = Dtool_ObjectToDict
|
||||
|
||||
for extension in extensions:
|
||||
if extension not in locals():
|
||||
# Not a class we have compiled in, skip it!
|
||||
continue
|
||||
|
||||
module = 'direct.extensions_native.%s_extensions' % extension
|
||||
|
||||
setattr(__builtin__, extension, locals()[extension])
|
||||
__import__(module)
|
||||
del __builtin__.__dict__[extension]
|
||||
|
||||
del __builtin__.Dtool_funcToMethod
|
||||
del __builtin__.Dtool_ObjectToDict
|
Loading…
x
Reference in New Issue
Block a user