diff --git a/.travis.yml b/.travis.yml index 9434d04..e55be64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,13 +12,11 @@ before_install: # command to install dependencies install: - - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install --use-mirrors contextlib2 mock ordereddict unittest2; fi - if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pip install --use-mirrors contextlib2 mock; fi - if [[ $TRAVIS_PYTHON_VERSION == '3.3' ]]; then pip install --use-mirrors numpy; fi # command to run tests script: - - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then unit2 discover; fi - if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then python -m unittest discover; fi - if [[ $TRAVIS_PYTHON_VERSION == '3.3' ]]; then python -m unittest discover; fi diff --git a/docs/source/detailed_installation.rst b/docs/source/detailed_installation.rst index 92810b7..4e17c4f 100644 --- a/docs/source/detailed_installation.rst +++ b/docs/source/detailed_installation.rst @@ -95,18 +95,16 @@ documentation or use pip. * setuptools * matplotlib * pillow - * contextlib2 (python 2.6, 2.7 only) - * mock (python 2.6, 2.7 only) - * ordereddict (python 2.6 only) + * contextlib2 (2.7 only) + * mock (2.7 only) -Glymur's been tested on the following linux platforms without any unexpected +Glymur 0.6 been tested on the following linux platforms without any unexpected difficulties: - * OpenSUSE 12.3 - * Fedora 17, 18, 19 + * OpenSUSE 13.1 + * Fedora 19 * Raspian * Travis CI (currently Ubuntu 12.04?) - * CentOS 6.4 Windows ------- diff --git a/docs/source/introduction.rst b/docs/source/introduction.rst index e1a3b3b..75cdbfa 100644 --- a/docs/source/introduction.rst +++ b/docs/source/introduction.rst @@ -13,7 +13,8 @@ some very limited support for reading JPX metadata. For instance, **asoc** and **labl** boxes are recognized, so GMLJP2 metadata can be retrieved from such JPX files. -Glymur works on Python 2.6, 2.7, and 3.3. +Glymur 0.6 works on Python versions 2.7, 3.3 and 3.4. If you have 2.6, you should +use the 0.5 series. OpenJPEG Installation ===================== diff --git a/docs/source/roadmap.rst b/docs/source/roadmap.rst index 1e336f1..c29d4f4 100644 --- a/docs/source/roadmap.rst +++ b/docs/source/roadmap.rst @@ -8,5 +8,3 @@ Here's an incomplete list of what I'd like to focus on in the future. * investigate using CFFI or cython instead of ctypes to wrap openjp2 * investigate adding write support for UUID/XMP boxes (potentially a big project) * investigate JPIP (likely to be an even bigger project) - -Support for Python 2.6 will be dropped with the 0.6.0 release. diff --git a/glymur/__init__.py b/glymur/__init__.py index bf2f625..ba17727 100644 --- a/glymur/__init__.py +++ b/glymur/__init__.py @@ -1,6 +1,7 @@ """glymur - read, write, and interrogate JPEG 2000 files """ import sys +import unittest from glymur import version __version__ = version.version @@ -10,15 +11,8 @@ from .jp2dump import jp2dump from . import data - -# unittest2 only in python-2.6 (pylint/python2.7 issue) -# pylint: disable=F0401 def runtests(): """Discover and run all tests for the glymur package. """ - if sys.hexversion <= 0x02070000: - import unittest2 as unittest - else: - import unittest suite = unittest.defaultTestLoader.discover(__path__[0]) unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/glymur/jp2box.py b/glymur/jp2box.py index 7960c8d..c51dd1b 100644 --- a/glymur/jp2box.py +++ b/glymur/jp2box.py @@ -13,6 +13,7 @@ References # pylint: disable=C0302,R0903,R0913 +from collections import OrderedDict import copy import datetime import io @@ -23,16 +24,9 @@ import struct import sys import uuid import warnings +import xml import xml.etree.cElementTree as ET -if sys.hexversion < 0x02070000: - # pylint: disable=F0401,E0611 - from ordereddict import OrderedDict - from xml.etree.cElementTree import XMLParserError as ParseError -else: - from xml.etree.cElementTree import ParseError - from collections import OrderedDict - import numpy as np from .codestream import Codestream @@ -2330,10 +2324,10 @@ class XMLBox(Jp2kBox): try: elt = ET.fromstring(text.encode('utf-8')) xml = ET.ElementTree(elt) - except ParseError as parse_error: + except ET.ParseError as err: msg = 'A problem was encountered while parsing an XML box:' msg += '\n\n\t"{0}"\n\nNo XML was retrieved.' - msg = msg.format(str(parse_error)) + msg = msg.format(str(err)) warnings.warn(msg, UserWarning) xml = None diff --git a/glymur/lib/test/test_openjp2.py b/glymur/lib/test/test_openjp2.py index 54d8254..3ca6f55 100644 --- a/glymur/lib/test/test_openjp2.py +++ b/glymur/lib/test/test_openjp2.py @@ -5,17 +5,10 @@ Tests for libopenjp2 wrapping functions. # W0142: using kwargs is ok in this context # pylint: disable=R0904,W0142 -# unittest2 is python-2.6 only (pylint/python-2.7) -# pylint: disable=F0401 - import os import sys import tempfile - -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest +import unittest import numpy as np diff --git a/glymur/lib/test/test_openjpeg.py b/glymur/lib/test/test_openjpeg.py index 91e6d84..f28656c 100644 --- a/glymur/lib/test/test_openjpeg.py +++ b/glymur/lib/test/test_openjpeg.py @@ -1,19 +1,12 @@ """ Tests for OpenJPEG module. """ -# unittest2 is python2.6 only (pylint/python-2.7) -# pylint: disable=F0401 - # pylint: disable=E1101,R0904 import ctypes import re import sys - -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest +import unittest import glymur diff --git a/glymur/test/test_callbacks.py b/glymur/test/test_callbacks.py index 722c5da..5b6bd74 100644 --- a/glymur/test/test_callbacks.py +++ b/glymur/test/test_callbacks.py @@ -13,10 +13,7 @@ import sys import tempfile import warnings -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest +import unittest if sys.hexversion <= 0x03030000: from mock import patch diff --git a/glymur/test/test_codestream.py b/glymur/test/test_codestream.py index 768bf7f..5edd144 100644 --- a/glymur/test/test_codestream.py +++ b/glymur/test/test_codestream.py @@ -8,18 +8,11 @@ Test suite for codestream parsing. # tempfile.TemporaryDirectory, unittest.assertWarns introduced in 3.2 # pylint: disable=E1101 -# unittest2 is python2.6 only (pylint/python-2.7) -# pylint: disable=F0401 - import os import struct import sys import tempfile - -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest +import unittest from glymur import Jp2k import glymur diff --git a/glymur/test/test_config.py b/glymur/test/test_config.py index 32f067a..6884d2c 100644 --- a/glymur/test/test_config.py +++ b/glymur/test/test_config.py @@ -15,11 +15,7 @@ import imp import os import sys import tempfile - -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest +import unittest if sys.hexversion <= 0x03030000: from mock import patch diff --git a/glymur/test/test_conformance.py b/glymur/test/test_conformance.py index 5f53b5f..8f4496d 100644 --- a/glymur/test/test_conformance.py +++ b/glymur/test/test_conformance.py @@ -7,18 +7,11 @@ These tests deal with JPX/JP2/J2K images in the format-corpus repository. # E1101: assertWarns introduced in python 3.2 # pylint: disable=E1101 -# unittest2 is python2.6 only (pylint/python-2.7) -# pylint: disable=F0401 - import os from os.path import join import re import sys - -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest +import unittest import glymur from glymur import Jp2k diff --git a/glymur/test/test_icc.py b/glymur/test/test_icc.py index 8668999..46d4345 100644 --- a/glymur/test/test_icc.py +++ b/glymur/test/test_icc.py @@ -5,17 +5,10 @@ ICC profile tests. # unittest doesn't work well with R0904. # pylint: disable=R0904 -# unittest2 is python2.6 only (pylint/python-2.7) -# pylint: disable=F0401 - import datetime import os import sys - -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest +import unittest import numpy as np diff --git a/glymur/test/test_jp2box.py b/glymur/test/test_jp2box.py index 83d656f..d632de8 100644 --- a/glymur/test/test_jp2box.py +++ b/glymur/test/test_jp2box.py @@ -4,9 +4,6 @@ Test suite specifically targeting JP2 box layout. # E1103: return value from read may be list or np array # pylint: disable=E1103 -# F0401: unittest2 is needed on python-2.6 (pylint on 2.7) -# pylint: disable=F0401 - # R0902: More than 7 instance attributes are just fine for testing. # pylint: disable=R0902 @@ -26,13 +23,9 @@ import tempfile import uuid from uuid import UUID import xml.etree.cElementTree as ET +import unittest import warnings -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest - import numpy as np import glymur @@ -917,7 +910,6 @@ class TestRepr(unittest.TestCase): self.assertEqual(newbox.bits_per_component, (8, 8, 16)) self.assertEqual(newbox.signed, (True, False, True)) - @unittest.skipIf(sys.hexversion < 0x02070000, "Requires 2.7+") def test_xml_box(self): """Verify xml box repr.""" elt = ET.fromstring('0') @@ -948,7 +940,6 @@ class TestRepr(unittest.TestCase): self.assertEqual(box.vendor_feature, newbox.vendor_feature) self.assertEqual(box.vendor_mask, newbox.vendor_mask) - @unittest.skipIf(sys.hexversion < 0x02070000, "Requires 2.7+") def test_uuid_box(self): """Verify uuid repr method.""" uuid_instance = uuid.UUID('00000000-0000-0000-0000-000000000000') @@ -966,7 +957,6 @@ class TestRepr(unittest.TestCase): else: self.assertRegex(repr(box), regexp) - @unittest.skipIf(sys.hexversion < 0x02070000, "Requires 2.7+") def test_contiguous_codestream_box(self): """Verify contiguous codestream box repr method.""" jp2file = glymur.data.nemo() diff --git a/glymur/test/test_jp2box_jpx.py b/glymur/test/test_jp2box_jpx.py index 0436c95..8c33be6 100644 --- a/glymur/test/test_jp2box_jpx.py +++ b/glymur/test/test_jp2box_jpx.py @@ -7,13 +7,9 @@ import os import struct import sys import tempfile +import unittest import warnings -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest - import glymur from glymur import Jp2k diff --git a/glymur/test/test_jp2box_xml.py b/glymur/test/test_jp2box_xml.py index b875188..4950da4 100644 --- a/glymur/test/test_jp2box_xml.py +++ b/glymur/test/test_jp2box_xml.py @@ -5,9 +5,6 @@ Test suite specifically targeting JP2 box layout. # E1103: return value from read may be list or np array # pylint: disable=E1103 -# F0401: unittest2 is needed on python-2.6 (pylint on 2.7) -# pylint: disable=F0401 - # R0902: More than 7 instance attributes are just fine for testing. # pylint: disable=R0902 @@ -21,6 +18,7 @@ import os import struct import sys import tempfile +import unittest import warnings import xml.etree.cElementTree as ET @@ -34,11 +32,6 @@ if sys.hexversion <= 0x03030000: else: from unittest.mock import patch -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest - import glymur from glymur import Jp2k from glymur.jp2box import ColourSpecificationBox, ContiguousCodestreamBox diff --git a/glymur/test/test_jp2k.py b/glymur/test/test_jp2k.py index c664de9..b3704ed 100644 --- a/glymur/test/test_jp2k.py +++ b/glymur/test/test_jp2k.py @@ -17,14 +17,10 @@ import shutil import struct import sys import tempfile +import unittest import uuid from xml.etree import cElementTree as ET -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest - import warnings import numpy as np @@ -47,9 +43,6 @@ def load_tests(loader, tests, ignore): if os.name == "nt": # Can't do it on windows, temporary file issue. return tests - if sys.hexversion < 0x02070000: - # Don't bother with doctests on 2.6 for the time being. - return tests if glymur.lib.openjp2.OPENJP2 is not None: tests.addTests(doctest.DocTestSuite('glymur.jp2k')) return tests diff --git a/glymur/test/test_opj_suite.py b/glymur/test/test_opj_suite.py index 97b68e1..abe271a 100644 --- a/glymur/test/test_opj_suite.py +++ b/glymur/test/test_opj_suite.py @@ -27,16 +27,9 @@ suite. # asserWarns introduced in python 3.2 (python2.7/pylint issue) # pylint: disable=E1101 -# unittest2 is python2.6 only (pylint/python-2.7) -# pylint: disable=F0401 - import re import sys - -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest +import unittest import warnings diff --git a/glymur/test/test_opj_suite_neg.py b/glymur/test/test_opj_suite_neg.py index 3785af9..4b14f4d 100644 --- a/glymur/test/test_opj_suite_neg.py +++ b/glymur/test/test_opj_suite_neg.py @@ -8,18 +8,11 @@ seem like logical negative tests to add. # R0904: Not too many methods in unittest. # pylint: disable=R0904 -# unittest2 is python2.6 only (pylint/python-2.7) -# pylint: disable=F0401 - import os import re import sys import tempfile - -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest +import unittest import numpy as np diff --git a/glymur/test/test_opj_suite_write.py b/glymur/test/test_opj_suite_write.py index 2f699e6..22a99e3 100644 --- a/glymur/test/test_opj_suite_write.py +++ b/glymur/test/test_opj_suite_write.py @@ -6,18 +6,11 @@ suite. # R0904: Seems like pylint is fooled in this situation # pylint: disable=R0904,C0103 -# unittest2 is python2.6 only (pylint/python-2.7) -# pylint: disable=F0401 - import os import re import sys import tempfile - -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest +import unittest from .fixtures import read_image, NO_READ_BACKEND, NO_READ_BACKEND_MSG from .fixtures import OPJ_DATA_ROOT, opj_data_file diff --git a/glymur/test/test_printing.py b/glymur/test/test_printing.py index bb7da3e..77b5bb2 100644 --- a/glymur/test/test_printing.py +++ b/glymur/test/test_printing.py @@ -17,11 +17,7 @@ import sys import tempfile import warnings from xml.etree import cElementTree as ET - -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest +import unittest if sys.hexversion < 0x03000000: from StringIO import StringIO @@ -626,8 +622,6 @@ class TestPrinting(unittest.TestCase): expected = '\n'.join(lines) self.assertEqual(actual, expected) - @unittest.skipIf(sys.hexversion < 0x02070000, - "Differences in XML printing between 2.6 and 2.7") def test_xmp(self): """Verify the printing of a UUID/XMP box.""" j = glymur.Jp2k(self.jp2file) @@ -699,8 +693,6 @@ class TestPrinting(unittest.TestCase): expected = '\n'.join(lst) self.assertEqual(actual, expected) - @unittest.skipIf(sys.hexversion < 0x02070000, - "Differences in XML printing between 2.6 and 2.7") @unittest.skipIf(OPJ_DATA_ROOT is None, "OPJ_DATA_ROOT environment variable not set") def test_xml(self): diff --git a/setup.py b/setup.py index 2228943..92dcb27 100644 --- a/setup.py +++ b/setup.py @@ -20,13 +20,9 @@ instllrqrs = ['numpy>=1.4.1'] if sys.hexversion < 0x03030000: instllrqrs.append('contextlib2>=0.4') instllrqrs.append('mock>=1.0.1') -if sys.hexversion < 0x02070000: - instllrqrs.append('ordereddict>=1.1') - instllrqrs.append('unittest2>=0.5.1') kwargs['install_requires'] = instllrqrs clssfrs = ["Programming Language :: Python", - "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: Implementation :: CPython",