Hi Kai suggested, that it may be possible to set the path to python modules from the program itself, like it's done for user data directory. I've looked into that, but it's only partially possible, I think. I've managed to get it working for tests that call the engine from C++ (like worldtest), but not from Python scripts - those scripts obviously already need to know where to find adonthell module before they call a single function from it, so it already needs to be on PYTHONPATH.
I'm not sure if it's worth to implement such partial solution, but anyway, here's what I've done: CMakeLists.txt: ---- @@ -177,6 +177,8 @@ include(config/PythonExtraLibs.cmake) message(STATUS "\tSITEPKG: ${PYTHON_SITE_PACKAGE_DIR}") +add_definitions(-DPYTHONSPDIR="${ESCAPE}${PYTHON_SITE_PACKAGE_DIR}${ESCAPE}") + ####################### # libZ ####################### ---- src/main/Makefile.am: ---- @@ -14,7 +14,7 @@ libadonthell_main_la_SOURCES = \ adonthell.cc \ main.cc -libadonthell_main_la_CXXFLAGS = $(PY_CFLAGS) $(AM_CXXFLAGS) +libadonthell_main_la_CXXFLAGS = $(PY_CFLAGS) -DPYTHONSPDIR=\"$(pyexecdir)\" $(AM_CXXFLAGS) libadonthell_main_la_LIBADD = $(PY_LIBS) -lltdl \ $(top_builddir)/src/base/libadonthell_base.la \ $(top_builddir)/src/gfx/libadonthell_gfx.la \ ---- src/main/adonthell.cc: ---- @@ -86,6 +86,11 @@ bool app::init_modules (const u_int16 & modules) { python::init (); PySys_SetArgv (Argc, Argv); + + // add location of adonthell modules, + // to allow not setting PYTHONPATH + // if we're called from Python, it's already too late for that + python::add_search_path (PYTHONSPDIR); } // avoid shutting down Python in that case else ---- I mostly mimicked how PKGLIBDIR is set. I don't think this requires anything more sophisticated then a macro, since the location should not normally change after installation. Michal _______________________________________________ Adonthell-devel mailing list Adonthell-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/adonthell-devel