diff options
Diffstat (limited to 'setuptools/command')
| -rwxr-xr-x | setuptools/command/develop.py | 8 | ||||
| -rwxr-xr-x | setuptools/command/easy_install.py | 10 | ||||
| -rwxr-xr-x | setuptools/command/egg_info.py | 2 | ||||
| -rwxr-xr-x | setuptools/command/sdist.py | 3 | ||||
| -rw-r--r-- | setuptools/command/test.py | 9 |
5 files changed, 17 insertions, 15 deletions
diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 1d500040..129184ca 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -5,6 +5,8 @@ from distutils import log from distutils.errors import DistutilsError, DistutilsOptionError import os, sys, setuptools, glob +from setuptools.compat import PY3 + class develop(easy_install): """Set up package for development""" @@ -84,7 +86,7 @@ class develop(easy_install): " installation directory", p, normalize_path(os.curdir)) def install_for_development(self): - if sys.version_info >= (3,) and getattr(self.distribution, 'use_2to3', False): + if PY3 and getattr(self.distribution, 'use_2to3', False): # If we run 2to3 we can not do this inplace: # Ensure metadata is up-to-date @@ -99,7 +101,7 @@ class develop(easy_install): self.reinitialize_command('build_ext', inplace=0) self.run_command('build_ext') - + # Fixup egg-link and easy-install.pth ei_cmd = self.get_finalized_command("egg_info") self.egg_path = build_path @@ -112,7 +114,7 @@ class develop(easy_install): # Build extensions in-place self.reinitialize_command('build_ext', inplace=1) self.run_command('build_ext') - + self.install_site_py() # ensure that target dir is site-safe if setuptools.bootstrap_install_from: self.easy_install(setuptools.bootstrap_install_from) diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index a5f324e3..ad7f4725 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -47,7 +47,7 @@ from setuptools.package_index import PackageIndex from setuptools.package_index import URL_SCHEME from setuptools.command import bdist_egg, egg_info from setuptools.compat import (iteritems, maxsize, basestring, unicode, - reraise) + reraise, PY2, PY3) from pkg_resources import ( yield_lines, normalize_path, resource_string, ensure_directory, get_distribution, find_distributions, Environment, Requirement, @@ -75,7 +75,7 @@ def samefile(p1, p2): norm_p2 = os.path.normpath(os.path.normcase(p2)) return norm_p1 == norm_p2 -if sys.version_info <= (3,): +if PY2: def _to_ascii(s): return s def isascii(s): @@ -1187,7 +1187,7 @@ Please make the appropriate changes for your system and try again.""" f = open(sitepy,'rb') current = f.read() # we want str, not bytes - if sys.version_info >= (3,): + if PY3: current = current.decode() f.close() @@ -1409,7 +1409,7 @@ def get_exe_prefixes(exe_filename): continue if parts[0].upper() in ('PURELIB','PLATLIB'): contents = z.read(name) - if sys.version_info >= (3,): + if PY3: contents = contents.decode() for pth in yield_lines(contents): pth = pth.strip().replace('\\','/') @@ -1855,7 +1855,7 @@ def get_win_launcher(type): def load_launcher_manifest(name): manifest = pkg_resources.resource_string(__name__, 'launcher manifest.xml') - if sys.version_info[0] < 3: + if PY2: return manifest % vars() else: return manifest.decode('utf-8') % vars() diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 22501c44..646f9460 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -128,7 +128,7 @@ class egg_info(Command): to the file. """ log.info("writing %s to %s", what, filename) - if sys.version_info >= (3,): + if PY3: data = data.encode("utf-8") if not self.dry_run: f = open(filename, 'wb') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 948d27fa..f9a5b7b9 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -8,6 +8,7 @@ import distutils.command.sdist as orig from distutils.util import convert_path from distutils import log from setuptools import svn_utils +from setuptools.compat import PY3 READMES = ('README', 'README.rst', 'README.txt') @@ -230,7 +231,7 @@ class sdist(orig.sdist): manifest = open(self.manifest, 'rbU') for line in manifest: # The manifest must contain UTF-8. See #303. - if sys.version_info >= (3,): + if PY3: try: line = line.decode('UTF-8') except UnicodeDecodeError: diff --git a/setuptools/command/test.py b/setuptools/command/test.py index 7422b719..3c3581a9 100644 --- a/setuptools/command/test.py +++ b/setuptools/command/test.py @@ -8,6 +8,7 @@ from pkg_resources import (resource_listdir, resource_exists, normalize_path, working_set, _namespace_packages, add_activation_listener, require, EntryPoint) +from setuptools.compat import PY3 from setuptools.py31compat import unittest_main @@ -87,10 +88,8 @@ class test(Command): self.test_runner = getattr(self.distribution, 'test_runner', None) def with_project_on_sys_path(self, func): - with_2to3 = ( - sys.version_info >= (3,) - and getattr(self.distribution, 'use_2to3', False) - ) + with_2to3 = PY3 and getattr(self.distribution, 'use_2to3', False) + if with_2to3: # If we run 2to3 we can not do this inplace: @@ -149,7 +148,7 @@ class test(Command): # Purge modules under test from sys.modules. The test loader will # re-import them from the build location. Required when 2to3 is used # with namespace packages. - if sys.version_info >= (3,) and getattr(self.distribution, 'use_2to3', False): + if PY3 and getattr(self.distribution, 'use_2to3', False): module = self.test_args[-1].split('.')[0] if module in _namespace_packages: del_modules = [] |
