diff --git a/pyutilib/component/app/tests/test_simple.py b/pyutilib/component/app/tests/test_simple.py index 076f3bab..0fa6640a 100644 --- a/pyutilib/component/app/tests/test_simple.py +++ b/pyutilib/component/app/tests/test_simple.py @@ -13,14 +13,12 @@ class Test(unittest.TestCase): - @unittest.skipIf(sys.version_info[:2] < (2, 6), "Skipping tests because configuration output is not guaranteed to be sorted") # yapf: disable def test_app1a(self): pyutilib.subprocess.run(sys.executable + " " + currdir + os.sep + "app1a.py " + currdir) self.assertFileEqualsBaseline(currdir + "config1.out", currdir + "config1.txt") - @unittest.skipIf(sys.version_info[:2] < (2, 6), "Skipping tests because configuration output is not guaranteed to be sorted") # yapf: disable def test_app1b(self): pyutilib.subprocess.run(sys.executable + " " + currdir + os.sep + "app1b.py " + currdir) diff --git a/pyutilib/component/config/plugin_ConfigParser.py b/pyutilib/component/config/plugin_ConfigParser.py index a845b273..9d0fca2a 100644 --- a/pyutilib/component/config/plugin_ConfigParser.py +++ b/pyutilib/component/config/plugin_ConfigParser.py @@ -10,7 +10,6 @@ __all__ = ['Configuration_ConfigParser'] -import sys import os.path try: from ordereddict import OrderedDict @@ -58,10 +57,7 @@ def load(self, filename): def save(self, filename, config, header=None): """Save configuration information to the specified file.""" - if sys.version_info[:2] == (2, 6): - parser = _configParser(dict_type=OrderedDict) - else: - parser = _configParser() + parser = _configParser() for (section, option, value) in config: if not parser.has_section(section): parser.add_section(section) diff --git a/pyutilib/component/config/tests/test_config.py b/pyutilib/component/config/tests/test_config.py index 5691372a..a90f0682 100644 --- a/pyutilib/component/config/tests/test_config.py +++ b/pyutilib/component/config/tests/test_config.py @@ -112,7 +112,6 @@ def test_load4(self): except ConfigurationError: pass - @unittest.skipIf(sys.version_info[:2] < (2, 6), "Skipping tests because configuration output is not guaranteed to be sorted") # yapf: disable def test_load5(self): """Test load method""" PluginGlobals.add_env("testing.config_loading") @@ -149,7 +148,6 @@ def __init__(self): PluginGlobals.remove_env( "testing.config_loading", cleanup=True, singleton=False) - @unittest.skipIf(sys.version_info[:2] < (2, 6), "Skipping tests because configuration output is not guaranteed to be sorted") # yapf: disable def test_save1(self): """Test save method""" config = Configuration() diff --git a/pyutilib/math/numtypes.py b/pyutilib/math/numtypes.py index 0814b53c..9b67e4d6 100755 --- a/pyutilib/math/numtypes.py +++ b/pyutilib/math/numtypes.py @@ -12,48 +12,28 @@ Definitions of mathematical constants """ -import sys import math -if sys.version_info < (2, 6): - """ Definition of infinity """ - infinity = float(1e3000) - """ Definition of NaN """ - nan = infinity / infinity - def is_nan(x): - """ - Returns true if the argument is a float and it does not equal itself - """ - return type(x) is float and x != x - - def is_finite(val): - """ - Returns true if the argument is a float or int and it is not infinite or NaN - """ - return type(val) in (float, int) and val not in (infinity, -infinity, - nan) - -else: - """ Definition of infinity """ - infinity = float('inf') - """ Definition of NaN """ - nan = infinity / infinity - - def is_nan(x): - """ - Returns true if the argument is a float and it does not equal itself - """ - try: - return math.isnan(x) - except TypeError: - return False - - def is_finite(x): - """ - Returns true if the argument is a float or int and it is not infinite or NaN - """ - try: - return not math.isinf(x) - except TypeError: - return False +""" Definition of infinity """ +infinity = float('inf') +""" Definition of NaN """ +nan = infinity / infinity + +def is_nan(x): + """ + Returns true if the argument is a float and it does not equal itself + """ + try: + return math.isnan(x) + except TypeError: + return False + +def is_finite(x): + """ + Returns true if the argument is a float or int and it is not infinite or NaN + """ + try: + return not math.isinf(x) + except TypeError: + return False diff --git a/pyutilib/misc/archivereader.py b/pyutilib/misc/archivereader.py index 321981c9..1e73755e 100644 --- a/pyutilib/misc/archivereader.py +++ b/pyutilib/misc/archivereader.py @@ -12,7 +12,6 @@ 'GzipFileArchiveReader', 'BZ2FileArchiveReader'] import os -import sys import tempfile import shutil import posixpath @@ -23,12 +22,11 @@ tarfile_available = False gzip_available = False bz2_available = False -if sys.version_info[:2] >= (2, 6): - try: - import zipfile - zipfile_available = True - except: - pass +try: + import zipfile + zipfile_available = True +except: + pass try: import tarfile tarfile_available = True diff --git a/pyutilib/misc/comparison.py b/pyutilib/misc/comparison.py index 451d4728..db80b18e 100644 --- a/pyutilib/misc/comparison.py +++ b/pyutilib/misc/comparison.py @@ -49,22 +49,9 @@ def get_desired_chars_from_file(f, nchars, l=""): return retBuf -if sys.version_info[:2] == (3, 2): - # - # This fixes a bug in Python 3.2's implementation of GzipFile. - # - class MyGzipFile(gzip.GzipFile): - - def read1(self, n): - return self.read(n) - - def open_possibly_compressed_file(filename): if not os.path.exists(filename): raise IOError("cannot find file `" + filename + "'") - if sys.version_info[:2] < (2, 6) and zipfile.is_zipfile(filename): - raise IOError("cannot unpack a ZIP file with Python %s" % - '.'.join(map(str, sys.version_info))) try: is_zipfile = zipfile.is_zipfile(filename) except: @@ -82,9 +69,6 @@ def open_possibly_compressed_file(filename): elif filename.endswith('.gz'): if sys.version_info < (3, 0): return gzip.open(filename, "r") - elif sys.version_info[:2] == (3, 2): - return io.TextIOWrapper( - MyGzipFile(filename), encoding='utf-8', newline='') else: return io.TextIOWrapper( gzip.open(filename, 'r'), encoding='utf-8', newline='') diff --git a/pyutilib/misc/tests/test_archivereader.py b/pyutilib/misc/tests/test_archivereader.py index a3bcaba8..44cdb051 100644 --- a/pyutilib/misc/tests/test_archivereader.py +++ b/pyutilib/misc/tests/test_archivereader.py @@ -4,7 +4,6 @@ # import os -import sys import fnmatch import posixpath @@ -51,7 +50,6 @@ def test_ArchiveReaderFactory_zip(self): os.path.join(testdatadir, 'archive_flat.zip')) self.assertTrue(isinstance(archive, ZipArchiveReader)) - #@unittest.skipIf(sys.version_info[:2] < (2,7), "Skipping due to bug in python 2.5 and 2.6") def test_ArchiveReaderFactory_file(self): archive = ArchiveReaderFactory(os.path.join(testdatadir, 'fileC.txt')) self.assertTrue(isinstance(archive, FileArchiveReader)) diff --git a/pyutilib/misc/tests/test_config.py b/pyutilib/misc/tests/test_config.py index f2ce0db4..54ba062b 100644 --- a/pyutilib/misc/tests/test_config.py +++ b/pyutilib/misc/tests/test_config.py @@ -1030,11 +1030,7 @@ def test_generate_custom_documentation(self): item_end= "endItem\n", ) - # re.sub(flags=) was introduced in 2.7 - if sys.version_info[:2] < (2,7): - stripped_reference = re.sub('\{[^\}]*\}','',reference) - else: - stripped_reference = re.sub('\{[^\}]*\}','',reference,flags=re.M) + stripped_reference = re.sub('\{[^\}]*\}','',reference,flags=re.M) #print(test) self.assertEqual(test, stripped_reference) diff --git a/pyutilib/misc/tests/test_smap.py b/pyutilib/misc/tests/test_smap.py index 9fd29696..e0bd5fcb 100644 --- a/pyutilib/misc/tests/test_smap.py +++ b/pyutilib/misc/tests/test_smap.py @@ -4,7 +4,6 @@ # import os -import sys from os.path import abspath, dirname currdir = dirname(abspath(__file__)) + os.sep import pyutilib.th as unittest @@ -13,11 +12,6 @@ class Test(unittest.TestCase): - def setUp(self): - if sys.version_info[:2] < (2, 6): - self.skipTest( - "SparseMapping not fully defined for Python 2.4 and 2.5") - def test1(self): # Validate behavior for empty sparse map smap = pyutilib.misc.SparseMapping() diff --git a/pyutilib/subprocess/processmngr.py b/pyutilib/subprocess/processmngr.py index 00016463..b0edf5d4 100644 --- a/pyutilib/subprocess/processmngr.py +++ b/pyutilib/subprocess/processmngr.py @@ -22,9 +22,8 @@ _mswindows = sys.platform.startswith('win') -if sys.version_info[0:2] >= (2, 5): - if _mswindows: - import ctypes +if _mswindows: + import ctypes # Note: on many python interpreters, WindowsError is only defined on # Windows. Since we want to trap it below, we will declare a local @@ -102,14 +101,11 @@ def kill_process(process, sig=signal.SIGTERM, verbose=False): if GlobalData.debug or verbose: print("Killing process %d with signal %d" % (pid, sig)) if _mswindows: - if sys.version_info[0:2] < (2, 5): - os.system("taskkill /t /f /pid " + repr(pid)) - else: - PROCESS_TERMINATE = 1 - handle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, - False, pid) - ctypes.windll.kernel32.TerminateProcess(handle, -1) - ctypes.windll.kernel32.CloseHandle(handle) + PROCESS_TERMINATE = 1 + handle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, + False, pid) + ctypes.windll.kernel32.TerminateProcess(handle, -1) + ctypes.windll.kernel32.CloseHandle(handle) else: # # Kill process and all its children diff --git a/pyutilib/th/pyunit.py b/pyutilib/th/pyunit.py index 0b02e836..bedf7c44 100644 --- a/pyutilib/th/pyunit.py +++ b/pyutilib/th/pyunit.py @@ -16,19 +16,10 @@ import sys import filecmp import re -if sys.version_info[:2] < (2, 7): - try: - import unittest2 as unittest - main = unittest.main - using_unittest2 = True - except ImportError: - import unittest - main = unittest.main - using_unittest2 = False -else: - import unittest - using_unittest2 = True - main = unittest.main + +import unittest +using_unittest2 = True +main = unittest.main from six import iteritems, itervalues, PY2 diff --git a/pyutilib/th/tests/test_misc.py b/pyutilib/th/tests/test_misc.py index 0c824f73..5ff682f3 100644 --- a/pyutilib/th/tests/test_misc.py +++ b/pyutilib/th/tests/test_misc.py @@ -1,5 +1,4 @@ import os -import sys from os.path import abspath, dirname currdir = dirname(abspath(__file__)) + os.sep @@ -19,8 +18,6 @@ def test2(self): self.assertFileEqualsBaseline( currdir + 'file1.txt', currdir + 'file2.txt', delete=False) - @unittest.skipIf(sys.version_info[:2] < (2, 6), - "Skipping tests with ZIP files.") def test3(self): self.assertFileEqualsBaseline( currdir + 'file1.txt', currdir + 'file1.zip', delete=False) @@ -35,8 +32,6 @@ def test3(self): self.assertFileEqualsBaseline( currdir + 'file2.zip', currdir + 'file2.zip', delete=False) - @unittest.skipIf(sys.version_info[:2] >= (3, 0) and sys.version_info[:2] < - (3, 3), "Skipping tests with GZ files.") def test3gz(self): self.assertFileEqualsBaseline( currdir + 'file1.txt', currdir + 'file1.txt.gz', delete=False) @@ -52,36 +47,26 @@ def test3gz(self): currdir + 'file2.txt.gz', currdir + 'file2.txt.gz', delete=False) @unittest.expectedFailure - @unittest.skipIf(sys.version_info[:2] < (2, 6), - "Skipping tests with ZIP files.") def test4(self): self.assertFileEqualsBaseline( currdir + 'file1.txt', currdir + 'file3.zip', delete=False) @unittest.expectedFailure - @unittest.skipIf(sys.version_info[:2] < (2, 6), - "Skipping tests with ZIP files.") def test5(self): self.assertFileEqualsBaseline( currdir + 'file3.zip', currdir + 'file1.txt', delete=False) @unittest.expectedFailure - @unittest.skipIf(sys.version_info[:2] < (2, 6), - "Skipping tests with ZIP files.") def test6(self): self.assertFileEqualsBaseline( currdir + 'file1.zip', currdir + 'file3.txt', delete=False) @unittest.expectedFailure - @unittest.skipIf(sys.version_info[:2] < (2, 6), - "Skipping tests with ZIP files.") def test7(self): self.assertFileEqualsBaseline( currdir + 'file3.zip', currdir + 'file3.zip', delete=False) @unittest.expectedFailure - @unittest.skipIf(sys.version_info[:2] < (2, 6), - "Skipping tests with ZIP files.") def test8(self): self.assertFileEqualsBaseline( currdir + 'file1.zip', currdir + 'file2.zip', delete=False) @@ -91,12 +76,6 @@ def test8gz(self): self.assertFileEqualsBaseline( currdir + 'file1.txt.gz', currdir + 'file2.txt.gz', delete=False) - @unittest.expectedFailure - @unittest.skipIf(sys.version_info[:2] >= (2, 6), - "Skipping tests that don't fail.") - def test9(self): - self.assertFileEqualsBaseline( - currdir + 'file1.zip', currdir + 'file2.zip', delete=False) class TesterL(unittest.TestCase): @@ -112,8 +91,6 @@ def test2(self): self.assertFileEqualsLargeBaseline( currdir + 'file1.txt', currdir + 'file2.txt', delete=False) - @unittest.skipIf(sys.version_info[:2] < (2, 6), - "Skipping tests with ZIP files.") def test3(self): self.assertFileEqualsLargeBaseline( currdir + 'file1.txt', currdir + 'file1.zip', delete=False) @@ -128,8 +105,6 @@ def test3(self): self.assertFileEqualsLargeBaseline( currdir + 'file2.zip', currdir + 'file2.zip', delete=False) - @unittest.skipIf(sys.version_info[:2] >= (3, 0) and sys.version_info[:2] < - (3, 3), "Skipping tests with GZ files.") def test3gz(self): self.assertFileEqualsLargeBaseline( currdir + 'file1.txt', currdir + 'file1.txt.gz', delete=False) @@ -145,36 +120,26 @@ def test3gz(self): currdir + 'file2.txt.gz', currdir + 'file2.txt.gz', delete=False) @unittest.expectedFailure - @unittest.skipIf(sys.version_info[:2] < (2, 6), - "Skipping tests with ZIP files.") def test4(self): self.assertFileEqualsLargeBaseline( currdir + 'file1.txt', currdir + 'file3.zip', delete=False) @unittest.expectedFailure - @unittest.skipIf(sys.version_info[:2] < (2, 6), - "Skipping tests with ZIP files.") def test5(self): self.assertFileEqualsLargeBaseline( currdir + 'file3.zip', currdir + 'file1.txt', delete=False) @unittest.expectedFailure - @unittest.skipIf(sys.version_info[:2] < (2, 6), - "Skipping tests with ZIP files.") def test6(self): self.assertFileEqualsLargeBaseline( currdir + 'file1.zip', currdir + 'file3.txt', delete=False) @unittest.expectedFailure - @unittest.skipIf(sys.version_info[:2] < (2, 6), - "Skipping tests with ZIP files.") def test7(self): self.assertFileEqualsLargeBaseline( currdir + 'file3.zip', currdir + 'file3.zip', delete=False) @unittest.expectedFailure - @unittest.skipIf(sys.version_info[:2] < (2, 6), - "Skipping tests with ZIP files.") def test8(self): self.assertFileEqualsLargeBaseline( currdir + 'file1.zip', currdir + 'file2.zip', delete=False) diff --git a/pyutilib/workflow/functor.py b/pyutilib/workflow/functor.py index a9759b3c..99b7eb33 100644 --- a/pyutilib/workflow/functor.py +++ b/pyutilib/workflow/functor.py @@ -4,7 +4,6 @@ __all__ = ['functor_api', 'IFunctorTask', 'FunctorAPIFactory', 'FunctorAPIData'] -import sys import inspect import logging @@ -210,12 +209,6 @@ def my_decorator(fn): _name = _alias.replace('_', '.') argspec = inspect.getargspec(fn) - if sys.version_info < (2, 6): - argspec = pyutilib.misc.Bunch( - args=argspec[0], - varargs=argspec[1], - keywords=argspec[2], - defaults=argspec[3]) if not argspec.varargs is None: logger.error( "Attempting to declare Functor task with function '%s' that contains variable arguments" diff --git a/pyutilib/workflow/tests/test_core.py b/pyutilib/workflow/tests/test_core.py index 73e3579e..9639f4ff 100644 --- a/pyutilib/workflow/tests/test_core.py +++ b/pyutilib/workflow/tests/test_core.py @@ -7,10 +7,6 @@ import pyutilib.workflow import pyutilib.workflow.globals -is_python24or25 = False -if sys.version_info[0:2] < (2, 6): - is_python24or25 = True - class DummyResource(pyutilib.workflow.Resource): @@ -228,7 +224,7 @@ def test1a(self): self.assertEqual( str(w), "Workflow Task1:\nTask2 prev: [] next: [] resources: []") - @unittest.skipIf(is_python24or25 or sys.version_info >= (3, 0), "There is a slight (space) formatting differences in different Python version... Skipping test.") # yapf: disable + @unittest.skipIf(sys.version_info >= (3, 0), "There is a slight (space) formatting differences in different Python version... Skipping test.") # yapf: disable def test2(self): # Do we really want to be testing pformat output? I think we might # actually want to override __cmp__ in the workflow.Task code and instead @@ -286,7 +282,6 @@ def test2(self): 'Value': 'None'}}}""" self.assertEqual(str(A), base) - @unittest.skipIf(is_python24or25, "There is a slight (space) formatting difference from pformat from Python2.6. Skipping test.") # yapf: disable def test3(self): # Do we really want to be testing pformat output? I think we might # actually want to override __cmp__ in the workflow.Task code and instead @@ -302,7 +297,6 @@ def test3(self): self.assertFileEqualsBaseline(currdir + 'test3.out', currdir + 'test3.txt') - @unittest.skipIf(is_python24or25, "There is a slight (space) formatting difference from pformat from Python2.6. Skipping test.") # yapf: disable def test4(self): # Do we really want to be testing pformat output? I think we might # actually want to override __cmp__ in the workflow.Task code and instead @@ -354,7 +348,6 @@ def test5a(self): # in groups. The soln is to move to argparse, but I'll save that for later #w.print_help() - @unittest.skipIf(is_python24or25, "There is a slight (space) formatting difference from pformat from Python2.6. Skipping test.") # yapf: disable def test5b(self): # Do we really want to be testing pformat output? I think we might # actually want to override __cmp__ in the workflow.Task code and instead diff --git a/setup.py b/setup.py index ab991e0f..13a10ea3 100644 --- a/setup.py +++ b/setup.py @@ -11,28 +11,8 @@ Setup for PyUtilib package """ -import sys import os -from setuptools import setup - - -def _find_packages(path): - """ - Generate a list of nested packages - """ - pkg_list=[] - if not os.path.exists(path): - return [] - if not os.path.exists(path+os.sep+"__init__.py"): - return [] - else: - pkg_list.append(path) - for root, dirs, files in os.walk(path, topdown=True): - if root in pkg_list and "__init__.py" in files: - for name in dirs: - if os.path.exists(root+os.sep+name+os.sep+"__init__.py"): - pkg_list.append(root+os.sep+name) - return [pkg for pkg in map(lambda x:x.replace(os.sep,"."), pkg_list)] +from setuptools import setup, find_packages def read(*rnames): with open(os.path.join(os.path.dirname(__file__), *rnames)) as README: @@ -46,15 +26,7 @@ def read(*rnames): break return line + README.read() -packages = _find_packages('pyutilib') - requires=[ 'nose', 'six' ] -if sys.version_info < (2,7): - requires.append('pbr') - requires.append('traceback2') - requires.append('unittest2') - requires.append('argparse') - requires.append('ordereddict') setup(name="PyUtilib", version='5.8.1.dev0', @@ -90,7 +62,7 @@ def read(*rnames): 'Topic :: Scientific/Engineering :: Mathematics', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Utilities'], - packages=packages, + packages=find_packages(), keywords=['utility'], install_requires=requires, entry_points="""