26 """Configure Python library loader to support LSST shared libraries.""" 38 SHARED_LIB_EXTENSION_LIST = (
'.so',
'.dylib')
39 LIB_EXCEPTION_LIST = (
'_lsstcppimport.so',)
47 options = (
'os',
'DLFCN',
'ctypes')
50 m = importlib.import_module(mod)
51 if RTLD_GLOBAL
is None and hasattr(m,
"RTLD_GLOBAL"):
52 RTLD_GLOBAL = m.RTLD_GLOBAL
53 if RTLD_NOW
is None and hasattr(m,
"RTLD_NOW"):
57 if RTLD_GLOBAL
is not None and RTLD_NOW
is not None:
61 if RTLD_GLOBAL
is None:
62 raise NameError(
"RTLD_GLOBAL constant can not be determined")
71 DLFLAGS = RTLD_GLOBAL | RTLD_NOW
84 if 'orig_imp_load_module' not in locals():
85 orig_imp_load_module = imp.load_module
87 @functools.wraps(orig_imp_load_module)
89 pathParts = args[1].split(os.path.sep)
90 extension = os.path.splitext(pathParts[-1])[-1]
97 lsstIdx = [i
for i, el
in enumerate(pathParts)
if el ==
'python']
98 if pathParts[-1]
in LIB_EXCEPTION_LIST
or (extension
in SHARED_LIB_EXTENSION_LIST
and 99 pathParts[-1].startswith(
'_')
and 100 'lsst' in [pathParts[i + 1]
for i
in lsstIdx]):
102 originalDLFlags = sys.getdlopenflags()
104 sys.setdlopenflags(DLFLAGS)
109 sys.setdlopenflags(originalDLFlags)
113 imp.load_module = imp_load_module
128 "Could not import lsstcppimport;" 129 " please ensure the base package has been built (not just setup).\n",
def imp_load_module(name, args)