diff options
Diffstat (limited to 'setuptools')
-rwxr-xr-x | setuptools/archive_util.py | 4 | ||||
-rwxr-xr-x | setuptools/command/egg_info.py | 4 | ||||
-rwxr-xr-x | setuptools/command/sdist.py | 7 | ||||
-rw-r--r-- | setuptools/command/test.py | 7 | ||||
-rw-r--r-- | setuptools/config.py | 2 | ||||
-rw-r--r-- | setuptools/monkey.py | 2 | ||||
-rwxr-xr-x | setuptools/package_index.py | 3 | ||||
-rw-r--r-- | setuptools/py26compat.py | 31 | ||||
-rw-r--r-- | setuptools/py31compat.py | 15 | ||||
-rwxr-xr-x | setuptools/sandbox.py | 4 | ||||
-rw-r--r-- | setuptools/tests/py26compat.py | 16 | ||||
-rw-r--r-- | setuptools/tests/test_easy_install.py | 7 | ||||
-rw-r--r-- | setuptools/tests/test_egg_info.py | 8 |
13 files changed, 12 insertions, 98 deletions
diff --git a/setuptools/archive_util.py b/setuptools/archive_util.py index cc82b3da..81436044 100755 --- a/setuptools/archive_util.py +++ b/setuptools/archive_util.py @@ -8,7 +8,7 @@ import posixpath import contextlib from distutils.errors import DistutilsError -from pkg_resources import ensure_directory, ContextualZipFile +from pkg_resources import ensure_directory __all__ = [ "unpack_archive", "unpack_zipfile", "unpack_tarfile", "default_filter", @@ -98,7 +98,7 @@ def unpack_zipfile(filename, extract_dir, progress_filter=default_filter): if not zipfile.is_zipfile(filename): raise UnrecognizedFormat("%s is not a zip file" % (filename,)) - with ContextualZipFile(filename) as z: + with zipfile.ZipFile(filename) as z: for info in z.infolist(): name = info.filename diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 8a06e496..40cea9bf 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -158,9 +158,7 @@ class egg_info(Command): build tag. Install these keys in a deterministic order to avoid arbitrary reordering on subsequent builds. """ - # python 2.6 compatibility - odict = getattr(collections, 'OrderedDict', dict) - egg_info = odict() + egg_info = collections.OrderedDict() # follow the order these keys would have been added # when PYTHONHASHSEED=0 egg_info['tag_build'] = self.tags() diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 84e29a1b..39e29d73 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -50,13 +50,6 @@ class sdist(sdist_add_defaults, orig.sdist): for cmd_name in self.get_sub_commands(): self.run_command(cmd_name) - # Call check_metadata only if no 'check' command - # (distutils <= 2.6) - import distutils.command - - if 'check' not in distutils.command.__all__: - self.check_metadata() - self.make_distribution() dist_files = getattr(self.distribution, 'dist_files', []) diff --git a/setuptools/command/test.py b/setuptools/command/test.py index 9a5117be..9931565b 100644 --- a/setuptools/command/test.py +++ b/setuptools/command/test.py @@ -3,6 +3,7 @@ import operator import sys import contextlib import itertools +import unittest from distutils.errors import DistutilsOptionError from unittest import TestLoader @@ -13,7 +14,6 @@ from pkg_resources import (resource_listdir, resource_exists, normalize_path, working_set, _namespace_packages, add_activation_listener, require, EntryPoint) from setuptools import Command -from setuptools.py31compat import unittest_main class ScanningLoader(TestLoader): @@ -225,12 +225,11 @@ class test(Command): del_modules.append(name) list(map(sys.modules.__delitem__, del_modules)) - exit_kwarg = {} if sys.version_info < (2, 7) else {"exit": False} - unittest_main( + unittest.main( None, None, self._argv, testLoader=self._resolve_as_ep(self.test_loader), testRunner=self._resolve_as_ep(self.test_runner), - **exit_kwarg + exit=False, ) @property diff --git a/setuptools/config.py b/setuptools/config.py index 889dc683..eb19c895 100644 --- a/setuptools/config.py +++ b/setuptools/config.py @@ -4,9 +4,9 @@ import os import sys from collections import defaultdict from functools import partial +from importlib import import_module from distutils.errors import DistutilsOptionError, DistutilsFileError -from setuptools.py26compat import import_module from setuptools.extern.six import string_types diff --git a/setuptools/monkey.py b/setuptools/monkey.py index aabc280f..09f208b1 100644 --- a/setuptools/monkey.py +++ b/setuptools/monkey.py @@ -7,8 +7,8 @@ import distutils.filelist import platform import types import functools +from importlib import import_module -from .py26compat import import_module from setuptools.extern import six import setuptools diff --git a/setuptools/package_index.py b/setuptools/package_index.py index d80d43bc..d2f27ca6 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -27,7 +27,6 @@ from setuptools import ssl_support from distutils import log from distutils.errors import DistutilsError from fnmatch import translate -from setuptools.py26compat import strip_fragment from setuptools.py27compat import get_all_headers EGG_FRAGMENT = re.compile(r'^egg=([-A-Za-z0-9_.]+)$') @@ -707,7 +706,7 @@ class PackageIndex(Environment): fp, info = None, None try: checker = HashChecker.from_url(url) - fp = self.open_url(strip_fragment(url)) + fp = self.open_url(url) if isinstance(fp, urllib.error.HTTPError): raise DistutilsError( "Can't download %s: %s %s" % (url, fp.code, fp.msg) diff --git a/setuptools/py26compat.py b/setuptools/py26compat.py deleted file mode 100644 index 4d3add8c..00000000 --- a/setuptools/py26compat.py +++ /dev/null @@ -1,31 +0,0 @@ -""" -Compatibility Support for Python 2.6 and earlier -""" - -import sys - -try: - from urllib.parse import splittag -except ImportError: - from urllib import splittag - - -def strip_fragment(url): - """ - In `Python 8280 <http://bugs.python.org/issue8280>`_, Python 2.7 and - later was patched to disregard the fragment when making URL requests. - Do the same for Python 2.6 and earlier. - """ - url, fragment = splittag(url) - return url - - -if sys.version_info >= (2, 7): - strip_fragment = lambda x: x - -try: - from importlib import import_module -except ImportError: - - def import_module(module_name): - return __import__(module_name, fromlist=['__name__']) diff --git a/setuptools/py31compat.py b/setuptools/py31compat.py index 44b025d4..4ea95320 100644 --- a/setuptools/py31compat.py +++ b/setuptools/py31compat.py @@ -1,6 +1,3 @@ -import sys -import unittest - __all__ = ['get_config_vars', 'get_path'] try: @@ -42,15 +39,3 @@ except ImportError: except OSError: # removal errors are not the only possible pass self.name = None - - -unittest_main = unittest.main - -_PY31 = (3, 1) <= sys.version_info[:2] < (3, 2) -if _PY31: - # on Python 3.1, translate testRunner==None to TextTestRunner - # for compatibility with Python 2.6, 2.7, and 3.2+ - def unittest_main(*args, **kwargs): - if 'testRunner' in kwargs and kwargs['testRunner'] is None: - kwargs['testRunner'] = unittest.TextTestRunner - return unittest.main(*args, **kwargs) diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py index d882d715..640691d8 100755 --- a/setuptools/sandbox.py +++ b/setuptools/sandbox.py @@ -37,10 +37,6 @@ def _execfile(filename, globals, locals=None): mode = 'rb' with open(filename, mode) as stream: script = stream.read() - # compile() function in Python 2.6 and 3.1 requires LF line endings. - if sys.version_info[:2] < (2, 7) or sys.version_info[:2] >= (3, 0) and sys.version_info[:2] < (3, 2): - script = script.replace(b'\r\n', b'\n') - script = script.replace(b'\r', b'\n') if locals is None: locals = globals code = compile(script, filename, 'exec') diff --git a/setuptools/tests/py26compat.py b/setuptools/tests/py26compat.py deleted file mode 100644 index 18cece05..00000000 --- a/setuptools/tests/py26compat.py +++ /dev/null @@ -1,16 +0,0 @@ -import sys -import tarfile -import contextlib - - -def _tarfile_open_ex(*args, **kwargs): - """ - Extend result as a context manager. - """ - return contextlib.closing(tarfile.open(*args, **kwargs)) - - -if sys.version_info[:2] < (2, 7) or (3, 0) <= sys.version_info[:2] < (3, 2): - tarfile_open = _tarfile_open_ex -else: - tarfile_open = tarfile.open diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 209e6b78..6f9bc8e1 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -35,7 +35,6 @@ from pkg_resources import Distribution as PRDistribution import setuptools.tests.server import pkg_resources -from .py26compat import tarfile_open from . import contexts from .textwrap import DALS @@ -428,7 +427,7 @@ class TestSetupRequires: # extracted path to sys.path so foo.bar v0.1 is importable foobar_1_dir = os.path.join(temp_dir, 'foo.bar-0.1') os.mkdir(foobar_1_dir) - with tarfile_open(foobar_1_archive) as tf: + with tarfile.open(foobar_1_archive) as tf: tf.extractall(foobar_1_dir) sys.path.insert(1, foobar_1_dir) @@ -526,7 +525,7 @@ def make_sdist(dist_path, files): listed in ``files`` as ``(filename, content)`` tuples. """ - with tarfile_open(dist_path, 'w:gz') as dist: + with tarfile.open(dist_path, 'w:gz') as dist: for filename, content in files: file_bytes = io.BytesIO(content.encode('utf-8')) file_info = tarfile.TarInfo(name=filename) @@ -580,7 +579,7 @@ def make_trivial_sdist(dist_path, setup_py): setup_py_file = tarfile.TarInfo(name='setup.py') setup_py_bytes = io.BytesIO(setup_py.encode('utf-8')) setup_py_file.size = len(setup_py_bytes.getvalue()) - with tarfile_open(dist_path, 'w:gz') as dist: + with tarfile.open(dist_path, 'w:gz') as dist: dist.addfile(setup_py_file, fileobj=setup_py_bytes) diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 75ae18df..7bf6b68a 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -2,7 +2,6 @@ import os import glob import re import stat -import sys from setuptools.command.egg_info import egg_info, manifest_maker from setuptools.dist import Distribution @@ -63,12 +62,6 @@ class TestEggInfo(object): }) yield env - dict_order_fails = pytest.mark.skipif( - sys.version_info < (2,7), - reason="Intermittent failures on Python 2.6", - ) - - @dict_order_fails def test_egg_info_save_version_info_setup_empty(self, tmpdir_cwd, env): """ When the egg_info section is empty or not present, running @@ -104,7 +97,6 @@ class TestEggInfo(object): flags = re.MULTILINE | re.DOTALL assert re.search(pattern, content, flags) - @dict_order_fails def test_egg_info_save_version_info_setup_defaults(self, tmpdir_cwd, env): """ When running save_version_info on an existing setup.cfg |