26 from __future__
import absolute_import, division, print_function
35 SHARED_LIB_EXTENSION_LIST = (
'.so',
'.dylib')
36 LIB_EXCEPTION_LIST = (
'_lsstcppimport.so',)
44 options = (
'os',
'DLFCN',
'ctypes')
47 m = importlib.import_module(mod)
48 if RTLD_GLOBAL
is None and hasattr(m,
"RTLD_GLOBAL"):
49 RTLD_GLOBAL = m.RTLD_GLOBAL
50 if RTLD_NOW
is None and hasattr(m,
"RTLD_NOW"):
54 if RTLD_GLOBAL
is not None and RTLD_NOW
is not None:
58 if RTLD_GLOBAL
is None:
59 raise NameError(
"RTLD_GLOBAL constant can not be determined")
68 DLFLAGS = RTLD_GLOBAL | RTLD_NOW
81 if 'orig_imp_load_module' not in locals():
82 orig_imp_load_module = imp.load_module
84 @functools.wraps(orig_imp_load_module)
86 pathParts = args[1].split(os.path.sep)
87 extension = os.path.splitext(pathParts[-1])[-1]
94 lsstIdx = [i
for i, el
in enumerate(pathParts)
if el ==
'python']
95 if pathParts[-1]
in LIB_EXCEPTION_LIST
or (extension
in SHARED_LIB_EXTENSION_LIST
and
96 pathParts[-1].startswith(
'_')
and
97 'lsst' in [pathParts[i+1]
for i
in lsstIdx]):
99 originalDLFlags = sys.getdlopenflags()
101 sys.setdlopenflags(DLFLAGS)
106 sys.setdlopenflags(originalDLFlags)
110 imp.load_module = imp_load_module
116 "Could not import lsstcppimport; please ensure the base package has been built (not just setup).\n",