Commit c1ed1839 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fall back to ctypes if the DLFCN or dl modules are not available

parent d874dec6
...@@ -21,10 +21,16 @@ ...@@ -21,10 +21,16 @@
import sys import sys
try: try:
from DLFCN import RTLD_LAZY, RTLD_GLOBAL from DLFCN import RTLD_LAZY, RTLD_GLOBAL
dl_flags = RTLD_LAZY | RTLD_GLOBAL
except ImportError: except ImportError:
# handle strange python installations, by importing from the deprecated dl # handle strange python installations, by importing from the deprecated dl
# module # module, otherwise from ctypes
from dl import RTLD_LAZY, RTLD_GLOBAL try:
from dl import RTLD_LAZY, RTLD_GLOBAL
dl_flags = RTLD_LAZY | RTLD_GLOBAL
except ImportError:
from ctypes import RTLD_GLOBAL
dl_flags = RTLD_GLOBAL
__all__ = ["dl_import"] __all__ = ["dl_import"]
...@@ -41,7 +47,7 @@ def dl_import(import_expr): ...@@ -41,7 +47,7 @@ def dl_import(import_expr):
# work properly across DSO boundaries. See http://gcc.gnu.org/faq.html#dso # work properly across DSO boundaries. See http://gcc.gnu.org/faq.html#dso
orig_dlopen_flags = sys.getdlopenflags() orig_dlopen_flags = sys.getdlopenflags()
sys.setdlopenflags(RTLD_LAZY | RTLD_GLOBAL) sys.setdlopenflags(dl_flags)
exec import_expr in local_dict, global_dict exec import_expr in local_dict, global_dict
......
...@@ -21,7 +21,7 @@ import sys, string, hashlib, os.path, re, glob ...@@ -21,7 +21,7 @@ import sys, string, hashlib, os.path, re, glob
from .. import * from .. import *
from .. import libgraph_tool_core from .. import libgraph_tool_core
import numpy import numpy
from .. dl_import import RTLD_LAZY, RTLD_GLOBAL from .. dl_import import dl_flags
try: try:
import scipy.weave import scipy.weave
...@@ -251,7 +251,7 @@ def inline(code, arg_names=None, local_dict=None, ...@@ -251,7 +251,7 @@ def inline(code, arg_names=None, local_dict=None,
# friends to work properly across DSO boundaries. See # friends to work properly across DSO boundaries. See
# http://gcc.gnu.org/faq.html#dso # http://gcc.gnu.org/faq.html#dso
orig_dlopen_flags = sys.getdlopenflags() orig_dlopen_flags = sys.getdlopenflags()
sys.setdlopenflags(RTLD_LAZY | RTLD_GLOBAL) sys.setdlopenflags(dl_flags)
# call weave and pass all the updated kw arguments # call weave and pass all the updated kw arguments
ret_vals = \ ret_vals = \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment