I have python project that runs on multiple machines. I am using virtualenv to sync the python modules across the multiple machines. This works great. However I am pulling in some in-house baked SWIG *.so's packages into the env as well. These c++ shared objects have some far-reaching dependency nightmares which are difficult to reproduce on some of the machines. I don't need there code-functionality on a few of the devel machines. I would like have to rest of the python code load and continue rocking on without modification.
I would like to 'fake-the-module' loading on machines that dont have the modules. I wont be calling the code that actually exercises the SWIG *.so's methods.
example:
try:
import swigpackagefoo.swigsubpackagebar
except ImportError:
# magic code that defines the fake module, I want to define a bunch of class'es with 'pass'
# so all the code deps would be happy. and I dont require the swig *.so to
# be installed on the devel system.
# something along the lines of.
__import__('swigpackagefoo.swigsubpackagebar')=class foo(object): pass
Note: I think its worth noting that when the module imports the *.so, on the prod machine the
type(swigpackagefoo)
# is 'module', also the
type(swigpackagefoo.swigsubpackagebar)
# is also 'module'
so 'How do I define a module-in-line' in python?
I do not want to create the packages on the missing devel machines
i.e.: I DO-NOT want to create these files, because of module conflicts on the systems that work.
$ tree
swigpackagefoo/__init__.py
swigpackagefoo/swigsubpackagebar/__init__.py