mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Updated ERT to 946e512ac17c1e2469892072a925428c0a012fa1
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user