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 @@
import sys
try:
from DLFCN import RTLD_LAZY, RTLD_GLOBAL
dl_flags = RTLD_LAZY | RTLD_GLOBAL
except ImportError:
# handle strange python installations, by importing from the deprecated dl
# module
from dl import RTLD_LAZY, RTLD_GLOBAL
# module, otherwise from ctypes
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"]
......@@ -41,7 +47,7 @@ def dl_import(import_expr):
# work properly across DSO boundaries. See http://gcc.gnu.org/faq.html#dso
orig_dlopen_flags = sys.getdlopenflags()
sys.setdlopenflags(RTLD_LAZY | RTLD_GLOBAL)
sys.setdlopenflags(dl_flags)
exec import_expr in local_dict, global_dict
......
......@@ -21,7 +21,7 @@ import sys, string, hashlib, os.path, re, glob
from .. import *
from .. import libgraph_tool_core
import numpy
from .. dl_import import RTLD_LAZY, RTLD_GLOBAL
from .. dl_import import dl_flags
try:
import scipy.weave
......@@ -251,7 +251,7 @@ def inline(code, arg_names=None, local_dict=None,
# friends to work properly across DSO boundaries. See
# http://gcc.gnu.org/faq.html#dso
orig_dlopen_flags = sys.getdlopenflags()
sys.setdlopenflags(RTLD_LAZY | RTLD_GLOBAL)
sys.setdlopenflags(dl_flags)
# call weave and pass all the updated kw arguments
ret_vals = \
......
Markdown is supported
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