[C++-sig] Python Packages from embedded interpreter
Joseph Lisee
jlisee at gmail.com
Wed Feb 13 18:38:14 CET 2008
I accomplish something similar that I think will solve your problem as well.
I have a vehicle package, which has vehicle.MyClass, and
vehicle.device.MyClass. The way I expose this is by creating two wrapper
modules: _vehicle and _vehicle_device. I then have my source laid out like so:
vehicle/
__init__.py (does "from _vehicle import *")
device.py (does "from _vehicle_device import *")
So I would follow the same strategy for you. Create a "sourcemod" and a
"sourcemod_console" wrapper modules. Then you could do something like this in
the namespace you run your programs:
namespace bp = boost::python
// Import sourcemod into the namespace
main_namespace["sourcemod"] = bp::import("sourcemod");
// Setup sourcemod.console to equal sourcemod_console
bp::setattr(main_namespace["sourcemod"],
"console",
bp::import("sourcemod_console"))
I hope that helps.
-Joseph Lisee
More information about the Cplusplus-sig
mailing list