From f08f1d9bb9059bf61c0faa72cf5974575c5f93ef Mon Sep 17 00:00:00 2001 From: John Evans Date: Sun, 13 Oct 2013 12:30:28 -0400 Subject: [PATCH 1/9] Finalizing 0.5.6 release. --- CHANGES.txt | 3 +++ docs/source/conf.py | 2 +- glymur/version.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 30387a6..40846e4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,6 @@ +Oct 13, 2013 - v0.5.6 Fixed handling of non-ascii chars in XML boxes. Fixed + some docstring errors in jp2box module. + Oct 03, 2013 - v0.5.5 Fixed pip install error introduced in 0.5.0. Sep 24, 2013 - v0.5.4 Fixed test error restricted to v2.0. diff --git a/docs/source/conf.py b/docs/source/conf.py index f847e68..44fc9e0 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -78,7 +78,7 @@ copyright = u'2013, John Evans' # The short X.Y version. version = '0.5' # The full version, including alpha/beta/rc tags. -release = '0.5.5' +release = '0.5.6' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/glymur/version.py b/glymur/version.py index 192859f..af7523e 100644 --- a/glymur/version.py +++ b/glymur/version.py @@ -15,7 +15,7 @@ from .lib import openjp2 as opj2 # Do not change the format of this next line! Doing so risks breaking # setup.py -version = "0.5.5" +version = "0.5.6" _sv = LooseVersion(version) version_tuple = _sv.version From 425b13a7f1eb3d748ec06723222072c87bbe4d89 Mon Sep 17 00:00:00 2001 From: John Evans Date: Mon, 28 Oct 2013 16:43:27 -0400 Subject: [PATCH 2/9] Simpler configuration check allows not-installed to be caught earlier. Issue #138 --- glymur/lib/config.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/glymur/lib/config.py b/glymur/lib/config.py index e3a5c1d..f14c3d9 100644 --- a/glymur/lib/config.py +++ b/glymur/lib/config.py @@ -50,20 +50,21 @@ def load_openjpeg(libopenjpeg_path): # Let ctypes try to find it. libopenjpeg_path = find_library('openjpeg') - # If we could not find it, then look in some likely locations. + # If we could not find it, then look in some likely locations on mac + # and win. if libopenjpeg_path is None: if platform.system() == 'Darwin': - path = '/opt/local/lib/libopenjpeg.dylib' - if os.path.exists(path): - libopenjpeg_path = path + if os.path.exists('/opt/local/lib/libopenjpeg.dylib'): + libopenjpeg_path = '/opt/local/lib/libopenjpeg.dylib' elif os.name == 'nt': path = os.path.join('C:\\', 'Program files', 'OpenJPEG 1.5', 'bin', 'openjpeg.dll') if os.path.exists(path): libopenjpeg_path = path - else: - # No sense trying further on Linux - return None + + # If still no location, then no bother going further. + if libopenjpeg_path is None: + return None try: if os.name == "nt": From 14d4b60896e3e6b668ccec8525a183ad18ba885f Mon Sep 17 00:00:00 2001 From: jevans Date: Mon, 28 Oct 2013 20:04:17 -0400 Subject: [PATCH 3/9] Abstracted out loading of openjp2, openjpeg libraries. #138 That much was common to both load_openjp2 and load_openjpeg. Reduces number of different moving parts. --- glymur/lib/config.py | 85 ++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 46 deletions(-) diff --git a/glymur/lib/config.py b/glymur/lib/config.py index f14c3d9..e0c82e6 100644 --- a/glymur/lib/config.py +++ b/glymur/lib/config.py @@ -54,27 +54,55 @@ def load_openjpeg(libopenjpeg_path): # and win. if libopenjpeg_path is None: if platform.system() == 'Darwin': - if os.path.exists('/opt/local/lib/libopenjpeg.dylib'): - libopenjpeg_path = '/opt/local/lib/libopenjpeg.dylib' + # MacPorts + path = '/opt/local/lib/libopenjpeg.dylib' elif os.name == 'nt': path = os.path.join('C:\\', 'Program files', 'OpenJPEG 1.5', 'bin', 'openjpeg.dll') - if os.path.exists(path): - libopenjpeg_path = path + if os.path.exists(path): + libopenjpeg_path = path - # If still no location, then no bother going further. - if libopenjpeg_path is None: + return load_library(libopenjpeg_path) + + +def load_openjp2(libopenjp2_path): + """Load the openjp2 library, falling back on defaults if necessary. + """ + if libopenjp2_path is None: + # No help from the config file, try to find it ourselves. + libopenjp2_path = find_library('openjp2') + + if libopenjp2_path is None: + if platform.system() == 'Darwin': + # MacPorts + path = '/opt/local/lib/libopenjp2.dylib' + elif os.name == 'nt': + path = os.path.join('C:\\', 'Program files', 'OpenJPEG 2.0', + 'bin', 'openjp2.dll') + if os.path.exists(path): + libopenjp2_path = path + + return load_library(libopenjp2_path) + + +def load_library(path): + """Load the library, return the ctypes handle.""" + + if path is None: return None try: if os.name == "nt": - openjpeg_lib = ctypes.windll.LoadLibrary(libopenjpeg_path) + opj_lib = ctypes.windll.LoadLibrary(path) else: - openjpeg_lib = ctypes.CDLL(libopenjpeg_path) - except OSError: - openjpeg_lib = None + opj_lib = ctypes.CDLL(path) + except (TypeError, OSError): + msg = '"Library {0}" could not be loaded. Operating in degraded mode.' + msg = msg.format(path) + warnings.warn(msg, UserWarning) + opj_lib = None - return openjpeg_lib + return opj_lib def read_config_file(): @@ -99,41 +127,6 @@ def read_config_file(): return lib -def load_openjp2(libopenjp2_path): - """Load the openjp2 library, falling back on defaults if necessary. - """ - if libopenjp2_path is None: - # No help from the config file, try to find it ourselves. - libopenjp2_path = find_library('openjp2') - - if libopenjp2_path is None: - if platform.system() == 'Darwin': - path = '/opt/local/lib/libopenjp2.dylib' - if os.path.exists(path): - libopenjp2_path = path - elif os.name == 'nt': - path = os.path.join('C:\\', 'Program files', 'OpenJPEG 2.0', - 'bin', 'openjp2.dll') - if os.path.exists(path): - libopenjp2_path = path - - if libopenjp2_path is None: - return None - - try: - if os.name == "nt": - openjp2_lib = ctypes.windll.LoadLibrary(libopenjp2_path) - else: - openjp2_lib = ctypes.CDLL(libopenjp2_path) - except (TypeError, OSError): - msg = '"Library {0}" could not be loaded. Operating in degraded mode.' - msg = msg.format(libopenjp2_path) - warnings.warn(msg, UserWarning) - openjp2_lib = None - - return openjp2_lib - - def glymur_config(): """Try to ascertain locations of openjp2, openjpeg libraries. """ From f321c0d29b6e2efc1d6d42a07ac5f07600f7671d Mon Sep 17 00:00:00 2001 From: jevans Date: Mon, 28 Oct 2013 21:20:52 -0400 Subject: [PATCH 4/9] More refactoring, fewer branches. #138 --- glymur/lib/config.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/glymur/lib/config.py b/glymur/lib/config.py index e0c82e6..2a85cbe 100644 --- a/glymur/lib/config.py +++ b/glymur/lib/config.py @@ -43,49 +43,45 @@ def glymurrc_fname(): return None -def load_openjpeg(libopenjpeg_path): +def load_openjpeg(path): """Load the openjpeg library, falling back on defaults if necessary. """ - if libopenjpeg_path is None: + if path is None: # Let ctypes try to find it. - libopenjpeg_path = find_library('openjpeg') + path = find_library('openjpeg') # If we could not find it, then look in some likely locations on mac # and win. - if libopenjpeg_path is None: + if path is None: if platform.system() == 'Darwin': # MacPorts path = '/opt/local/lib/libopenjpeg.dylib' elif os.name == 'nt': path = os.path.join('C:\\', 'Program files', 'OpenJPEG 1.5', 'bin', 'openjpeg.dll') - if os.path.exists(path): - libopenjpeg_path = path - return load_library(libopenjpeg_path) + return load_library_handle(path) -def load_openjp2(libopenjp2_path): +def load_openjp2(path): """Load the openjp2 library, falling back on defaults if necessary. """ - if libopenjp2_path is None: + if path is None: # No help from the config file, try to find it ourselves. - libopenjp2_path = find_library('openjp2') + path = find_library('openjp2') - if libopenjp2_path is None: + if path is None: if platform.system() == 'Darwin': # MacPorts path = '/opt/local/lib/libopenjp2.dylib' elif os.name == 'nt': path = os.path.join('C:\\', 'Program files', 'OpenJPEG 2.0', 'bin', 'openjp2.dll') - if os.path.exists(path): - libopenjp2_path = path - return load_library(libopenjp2_path) + return load_library_handle(path) -def load_library(path): +def load_library_handle(path): """Load the library, return the ctypes handle.""" if path is None: From 527f479545796d56428416e15b2458fb90862dd6 Mon Sep 17 00:00:00 2001 From: jevans Date: Mon, 28 Oct 2013 21:43:39 -0400 Subject: [PATCH 5/9] Prepping 0.5.7 release. --- CHANGES.txt | 3 +++ docs/source/conf.py | 2 +- glymur/version.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 40846e4..68fe102 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,6 @@ +Oct 28, 2013 - v0.5.7 Fixed bad import error message when libopenjpeg library + not installed on mac. + Oct 13, 2013 - v0.5.6 Fixed handling of non-ascii chars in XML boxes. Fixed some docstring errors in jp2box module. diff --git a/docs/source/conf.py b/docs/source/conf.py index 44fc9e0..90db6a3 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -78,7 +78,7 @@ copyright = u'2013, John Evans' # The short X.Y version. version = '0.5' # The full version, including alpha/beta/rc tags. -release = '0.5.6' +release = '0.5.7' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/glymur/version.py b/glymur/version.py index af7523e..6068a93 100644 --- a/glymur/version.py +++ b/glymur/version.py @@ -15,7 +15,7 @@ from .lib import openjp2 as opj2 # Do not change the format of this next line! Doing so risks breaking # setup.py -version = "0.5.6" +version = "0.5.7" _sv = LooseVersion(version) version_tuple = _sv.version From dd19340db21791edd2178cdac86cd62106cf603d Mon Sep 17 00:00:00 2001 From: John Evans Date: Tue, 29 Oct 2013 09:17:32 -0400 Subject: [PATCH 6/9] Add additional path existance check to avoid unnecessary warning. #138 The warnings would come about if running on mac or windows where the library could not be found via ctypes or the configuration file. --- glymur/lib/config.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/glymur/lib/config.py b/glymur/lib/config.py index 2a85cbe..69d258e 100644 --- a/glymur/lib/config.py +++ b/glymur/lib/config.py @@ -45,6 +45,12 @@ def glymurrc_fname(): def load_openjpeg(path): """Load the openjpeg library, falling back on defaults if necessary. + + Parameters + ---------- + path : str + Path to openjpeg 1.5 library as specified by configuration file. Will + be None if no configuration file specified. """ if path is None: # Let ctypes try to find it. @@ -84,7 +90,9 @@ def load_openjp2(path): def load_library_handle(path): """Load the library, return the ctypes handle.""" - if path is None: + if path is None or (path is not None and not os.path.exists(path)): + # Either could not find a library via ctypes or user-configuration-file, + # or we could not find it in any of the default locations. return None try: @@ -93,10 +101,10 @@ def load_library_handle(path): else: opj_lib = ctypes.CDLL(path) except (TypeError, OSError): - msg = '"Library {0}" could not be loaded. Operating in degraded mode.' - msg = msg.format(path) - warnings.warn(msg, UserWarning) - opj_lib = None + msg = '"Library {0}" could not be loaded. Operating in degraded mode.' + msg = msg.format(path) + warnings.warn(msg, UserWarning) + opj_lib = None return opj_lib From 453e00db8c1fb01191e66db0591a801ff05b8a8d Mon Sep 17 00:00:00 2001 From: John Evans Date: Tue, 29 Oct 2013 09:29:39 -0400 Subject: [PATCH 7/9] Prepping for 0.5.8 --- CHANGES.txt | 3 +++ docs/source/conf.py | 2 +- glymur/version.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 68fe102..981672d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,6 @@ +Oct 29, 2013 - v0.5.8 Fixed unnecessary warnings when default locations for + openjpeg libraries on mac do not specify the actual library. + Oct 28, 2013 - v0.5.7 Fixed bad import error message when libopenjpeg library not installed on mac. diff --git a/docs/source/conf.py b/docs/source/conf.py index 90db6a3..0338c5a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -78,7 +78,7 @@ copyright = u'2013, John Evans' # The short X.Y version. version = '0.5' # The full version, including alpha/beta/rc tags. -release = '0.5.7' +release = '0.5.8' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/glymur/version.py b/glymur/version.py index 6068a93..0fb4b86 100644 --- a/glymur/version.py +++ b/glymur/version.py @@ -15,7 +15,7 @@ from .lib import openjp2 as opj2 # Do not change the format of this next line! Doing so risks breaking # setup.py -version = "0.5.7" +version = "0.5.8" _sv = LooseVersion(version) version_tuple = _sv.version From 75cb8957fc45453c2d91cded649c638bcb1e27ce Mon Sep 17 00:00:00 2001 From: John Evans Date: Tue, 29 Oct 2013 10:04:47 -0400 Subject: [PATCH 8/9] 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: From f551646af8072037179e12cf1846c7f6ba7f8ad1 Mon Sep 17 00:00:00 2001 From: John Evans Date: Tue, 29 Oct 2013 10:15:24 -0400 Subject: [PATCH 9/9] Prepping 0.5.9 release. --- CHANGES.txt | 2 ++ docs/source/conf.py | 2 +- glymur/version.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 981672d..5e62c1c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,5 @@ +Oct 29, 2013 - v0.5.9 Fixed bad library load on linux as a result of 0.5.8 + Oct 29, 2013 - v0.5.8 Fixed unnecessary warnings when default locations for openjpeg libraries on mac do not specify the actual library. diff --git a/docs/source/conf.py b/docs/source/conf.py index 0338c5a..b14af27 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -78,7 +78,7 @@ copyright = u'2013, John Evans' # The short X.Y version. version = '0.5' # The full version, including alpha/beta/rc tags. -release = '0.5.8' +release = '0.5.9' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/glymur/version.py b/glymur/version.py index 0fb4b86..6116920 100644 --- a/glymur/version.py +++ b/glymur/version.py @@ -15,7 +15,7 @@ from .lib import openjp2 as opj2 # Do not change the format of this next line! Doing so risks breaking # setup.py -version = "0.5.8" +version = "0.5.9" _sv = LooseVersion(version) version_tuple = _sv.version