From 8b77da64dfe429712a1ce78bf47412ec97b603e8 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 28 Aug 2009 02:52:24 +0000 Subject: [PATCH] preload libpandaexpress --- direct/src/p3d/Packager.py | 2 ++ direct/src/plugin/p3dPythonRun.cxx | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/direct/src/p3d/Packager.py b/direct/src/p3d/Packager.py index 6766105e1e..9fb9bfe26c 100644 --- a/direct/src/p3d/Packager.py +++ b/direct/src/p3d/Packager.py @@ -2158,6 +2158,8 @@ class Packager: self.do_module('VFSImporter', filename = filename) self.do_freeze('_vfsimporter', compileToExe = False) + self.do_file('libpandaexpress.dll'); + # Now that we're done freezing, explicitly add 'direct' to # counteract the previous explicit excludeModule(). self.do_module('direct') diff --git a/direct/src/plugin/p3dPythonRun.cxx b/direct/src/plugin/p3dPythonRun.cxx index 0ebf0aaddc..c1ef9a8c66 100755 --- a/direct/src/plugin/p3dPythonRun.cxx +++ b/direct/src/plugin/p3dPythonRun.cxx @@ -128,8 +128,23 @@ run_python() { #endif - // First, load _vfsimporter.pyd. Since this is a magic frozen pyd, - // importing it automatically makes all of its frozen contents + // We'll need libpandaexpress to be imported before we can load + // _vfsimporter. So, find it and load it. + Filename libpandaexpress(_archive_file.get_dirname(), + Filename::dso_filename("libpandaexpress.so")); + if (!libpandaexpress.exists()) { + nout << "Can't find " << libpandaexpress << "\n"; + return false; + } + + string startup; + startup = "import imp; imp.load_dynamic('libpandaexpress', \""; + startup += libpandaexpress.to_os_specific(); + startup += "\");"; + PyRun_SimpleString(startup.c_str()); + + // Now we can load _vfsimporter.pyd. Since this is a magic frozen + // pyd, importing it automatically makes all of its frozen contents // available to import as well. PyObject *vfsimporter = PyImport_ImportModule("_vfsimporter"); if (vfsimporter == NULL) {