Updated ERT to 946e512ac17c1e2469892072a925428c0a012fa1

This commit is contained in:
Magne Sjaastad
2014-10-09 20:13:04 +02:00
parent a8ce90e404
commit b93053b089
1188 changed files with 49680 additions and 11622 deletions

View File

@@ -17,13 +17,20 @@
Convenience module for loading shared library.
"""
import platform
import ctypes
import os
ert_lib_path = None
so_extension = {"linux" : "so",
"linux2" : "so",
"linux3" : "so",
"win32" : "dll",
"win64" : "dll",
"darwin" : "dylib" }
def __load__( lib_list, ert_prefix):
def __load( lib_list, ert_prefix):
"""
Thin wrapper around the ctypes.CDLL function for loading shared library.
@@ -38,12 +45,14 @@ def __load__( lib_list, ert_prefix):
Will return a handle to the first successfull load, and raise
ImportError if none of the loads succeed.
"""
error_list = {}
dll = None
platform_key = platform.system().lower()
for lib in lib_list:
try:
if ert_prefix:
ert_lib = os.path.join(ert_lib_path, lib)
ert_lib = os.path.join(ert_lib_path , "%s.%s" % (lib , so_extension[ platform_key ]))
dll = ctypes.CDLL(ert_lib, ctypes.RTLD_GLOBAL)
else:
dll = ctypes.CDLL(lib, ctypes.RTLD_GLOBAL)
@@ -78,7 +87,7 @@ def load( *lib_list ):
"""
Will try to load shared library with normal load semantics.
"""
return __load__(lib_list, False)
return __load(lib_list , False)
def ert_load( *lib_list ):
@@ -87,12 +96,16 @@ def ert_load( *lib_list ):
load shared library from that path; if that fails the loader will
try again without imposing any path restrictions.
"""
if ert_lib_path:
try:
return __load__(lib_list, True)
return __load(lib_list , True)
except ImportError:
# Try again - ignoring the ert_lib_path setting.
return load(*lib_list)
else:
# The ert_lib_path variable has not been set; just try a normal load.
return load(*lib_list)