From 75cb8957fc45453c2d91cded649c638bcb1e27ce Mon Sep 17 00:00:00 2001 From: John Evans Date: Tue, 29 Oct 2013 10:04:47 -0400 Subject: [PATCH] Have to put the check for path existance into the library default stanza. Issue #138 --- glymur/lib/config.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/glymur/lib/config.py b/glymur/lib/config.py index 69d258e..fdb5a92 100644 --- a/glymur/lib/config.py +++ b/glymur/lib/config.py @@ -59,6 +59,7 @@ def load_openjpeg(path): # If we could not find it, then look in some likely locations on mac # and win. if path is None: + # Could not find a library via ctypes if platform.system() == 'Darwin': # MacPorts path = '/opt/local/lib/libopenjpeg.dylib' @@ -66,6 +67,10 @@ def load_openjpeg(path): path = os.path.join('C:\\', 'Program files', 'OpenJPEG 1.5', 'bin', 'openjpeg.dll') + if path is not None and not os.path.exists(path): + # the mac/win default location does not exist. + return None + return load_library_handle(path) @@ -73,10 +78,11 @@ def load_openjp2(path): """Load the openjp2 library, falling back on defaults if necessary. """ if path is None: - # No help from the config file, try to find it ourselves. + # No help from the config file, try to find it via ctypes. path = find_library('openjp2') if path is None: + # Could not find a library via ctypes if platform.system() == 'Darwin': # MacPorts path = '/opt/local/lib/libopenjp2.dylib' @@ -84,15 +90,20 @@ def load_openjp2(path): path = os.path.join('C:\\', 'Program files', 'OpenJPEG 2.0', 'bin', 'openjp2.dll') + if path is not None and not os.path.exists(path): + # the mac/win default location does not exist. + return None + return load_library_handle(path) def load_library_handle(path): """Load the library, return the ctypes handle.""" - if path is None or (path is not None and not os.path.exists(path)): + if path is None: # Either could not find a library via ctypes or user-configuration-file, # or we could not find it in any of the default locations. + # This is probably a very old linux. return None try: