Merge branch 'master' into devel

This commit is contained in:
John Evans 2013-10-29 08:26:14 -04:00
commit b3d20fb4ef
4 changed files with 50 additions and 54 deletions

View file

@ -1,3 +1,9 @@
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.
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.

View file

@ -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.7'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View file

@ -43,37 +43,62 @@ 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.
if libopenjpeg_path is None:
# If we could not find it, then look in some likely locations on mac
# and win.
if path is None:
if platform.system() == 'Darwin':
# MacPorts
path = '/opt/local/lib/libopenjpeg.dylib'
if os.path.exists(path):
libopenjpeg_path = path
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
return load_library_handle(path)
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.
path = find_library('openjp2')
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')
return load_library_handle(path)
def load_library_handle(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():
@ -98,41 +123,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.
"""

View file

@ -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.7"
_sv = LooseVersion(version)
version_tuple = _sv.version