How to make python3 import examine .so and ...-g.so as well?

39 Views Asked by At

We expose C++ code to python via boost.python. We produce release and debug builds.

release builds produce lib.so files

debug builds produce lib-g.so files.

Our python code then

import lib<mymodule>

Is there a way to place a hook such that those import statements can explore both libmymodule.so and if not found libmymodule-g.so?

1

There are 1 best solutions below

0
Hugo Corrá On BEST ANSWER

Try the following:

import importlib

try:
    import libmymudule
except ImportError:
    libmymudule = importlib.import_module("libmymudule-g")