diff options
| -rw-r--r-- | distutils2/command/bdist_msi.py | 2 | ||||
| -rw-r--r-- | distutils2/command/bdist_wininst.py | 2 | ||||
| -rw-r--r-- | distutils2/command/build.py | 6 | ||||
| -rw-r--r-- | distutils2/command/install_dist.py | 2 | ||||
| -rw-r--r-- | distutils2/compiler/cygwinccompiler.py | 4 | ||||
| -rw-r--r-- | distutils2/create.py | 2 | ||||
| -rw-r--r-- | distutils2/markers.py | 4 | ||||
| -rw-r--r-- | distutils2/pypi/simple.py | 4 | ||||
| -rw-r--r-- | distutils2/tests/support.py | 6 | ||||
| -rw-r--r-- | distutils2/tests/test_command_build.py | 5 | ||||
| -rw-r--r-- | distutils2/tests/test_command_build_ext.py | 6 | ||||
| -rw-r--r-- | distutils2/tests/test_command_install_dist.py | 4 | ||||
| -rw-r--r-- | distutils2/tests/test_mixin2to3.py | 8 | ||||
| -rw-r--r-- | distutils2/tests/test_util.py | 4 | ||||
| -rw-r--r-- | runtests.py | 2 | ||||
| -rw-r--r-- | setup.py | 2 |
16 files changed, 36 insertions, 27 deletions
diff --git a/distutils2/command/bdist_msi.py b/distutils2/command/bdist_msi.py index 16bde24..f79bb41 100644 --- a/distutils2/command/bdist_msi.py +++ b/distutils2/command/bdist_msi.py @@ -203,7 +203,7 @@ class bdist_msi(Command): target_version = self.target_version if not target_version: assert self.skip_build, "Should have already checked this" - target_version = sys.version[0:3] + target_version = '%s.%s' % sys.version_info[:2] plat_specifier = ".%s-%s" % (self.plat_name, target_version) build = self.get_finalized_command('build') build.build_lib = os.path.join(build.build_base, diff --git a/distutils2/command/bdist_wininst.py b/distutils2/command/bdist_wininst.py index 69e9484..ce06c1c 100644 --- a/distutils2/command/bdist_wininst.py +++ b/distutils2/command/bdist_wininst.py @@ -137,7 +137,7 @@ class bdist_wininst(Command): target_version = self.target_version if not target_version: assert self.skip_build, "Should have already checked this" - target_version = sys.version[0:3] + target_version = '%s.%s' % sys.version_info[:2] plat_specifier = ".%s-%s" % (self.plat_name, target_version) build = self.get_finalized_command('build') build.build_lib = os.path.join(build.build_base, diff --git a/distutils2/command/build.py b/distutils2/command/build.py index 708b848..d4ace38 100644 --- a/distutils2/command/build.py +++ b/distutils2/command/build.py @@ -82,8 +82,8 @@ class build(Command): raise PackagingOptionError( "--plat-name only supported on Windows (try " "using './configure --help' on your platform)") - - plat_specifier = ".%s-%s" % (self.plat_name, sys.version[0:3]) + pyversion = '%s.%s' % sys.version_info[:2] + plat_specifier = ".%s-%s" % (self.plat_name, pyversion) # Make it so Python 2.x and Python 2.x with --with-pydebug don't # share the same build directories. Doing so confuses the build @@ -116,7 +116,7 @@ class build(Command): 'temp' + plat_specifier) if self.build_scripts is None: self.build_scripts = os.path.join(self.build_base, - 'scripts-' + sys.version[0:3]) + 'scripts-' + pyversion) if self.executable is None: self.executable = os.path.normpath(sys.executable) diff --git a/distutils2/command/install_dist.py b/distutils2/command/install_dist.py index bde77c3..e11a6d3 100644 --- a/distutils2/command/install_dist.py +++ b/distutils2/command/install_dist.py @@ -255,7 +255,7 @@ class install_dist(Command): # $platbase in the other installation directories and not worry # about needing recursive variable expansion (shudder). - py_version = sys.version.split()[0] + py_version = '%s.%s' % sys.version_info[:2] prefix, exec_prefix, srcdir, projectbase = get_config_vars( 'prefix', 'exec_prefix', 'srcdir', 'projectbase') diff --git a/distutils2/compiler/cygwinccompiler.py b/distutils2/compiler/cygwinccompiler.py index 8115e9b..63bfc64 100644 --- a/distutils2/compiler/cygwinccompiler.py +++ b/distutils2/compiler/cygwinccompiler.py @@ -56,6 +56,10 @@ from distutils2.errors import PackagingExecError, CompileError, UnknownFileError from distutils2.util import get_compiler_versions from distutils2._backport import sysconfig +# TODO use platform instead of sys.version +# (platform does unholy sys.version parsing too, but at least it gives other +# VMs a chance to override the returned values) + def get_msvcr(): """Include the appropriate MSVC runtime library if Python was built diff --git a/distutils2/create.py b/distutils2/create.py index 546b178..0a60ac8 100644 --- a/distutils2/create.py +++ b/distutils2/create.py @@ -377,7 +377,7 @@ class MainProgram(object): ('long_description', 'description'), ('url', 'home_page'), ('platforms', 'platform')) - if sys.version >= '2.5': + if sys.version_info[:2] >= (2, 5): labels += ( ('provides', 'provides-dist'), ('obsoletes', 'obsoletes-dist'), diff --git a/distutils2/markers.py b/distutils2/markers.py index ac7df79..bbcd644 100644 --- a/distutils2/markers.py +++ b/distutils2/markers.py @@ -28,7 +28,9 @@ def _operate(operation, x, y): # restricted set of variables _VARS = {'sys.platform': sys.platform, - 'python_version': sys.version[:3], + 'python_version': '%s.%s' % sys.version_info[:2], + # FIXME parsing sys.platform is not reliable, but there is no other + # way to get e.g. 2.7.2+, and the PEP is defined with sys.version 'python_full_version': sys.version.split(' ', 1)[0], 'os.name': os.name, 'platform.version': platform.version(), diff --git a/distutils2/pypi/simple.py b/distutils2/pypi/simple.py index 94c2c2a..2a7185a 100644 --- a/distutils2/pypi/simple.py +++ b/distutils2/pypi/simple.py @@ -34,8 +34,8 @@ __all__ = ['Crawler', 'DEFAULT_SIMPLE_INDEX_URL'] DEFAULT_SIMPLE_INDEX_URL = "http://a.pypi.python.org/simple/" DEFAULT_HOSTS = ("*",) SOCKET_TIMEOUT = 15 -USER_AGENT = "Python-urllib/%s distutils2/%s" % ( - sys.version[:3], distutils2_version) +USER_AGENT = "Python-urllib/%s.%s distutils2/%s" % ( + sys.version_info[0], sys.version_info[1], distutils2_version) # -- Regexps ------------------------------------------------- EGG_FRAGMENT = re.compile(r'^egg=([-A-Za-z0-9_.]+)$') diff --git a/distutils2/tests/support.py b/distutils2/tests/support.py index 4852c54..366314d 100644 --- a/distutils2/tests/support.py +++ b/distutils2/tests/support.py @@ -63,8 +63,9 @@ __all__ = [ # misc. functions and decorators 'fake_dec', 'create_distribution', 'use_command', 'copy_xxmodule_c', 'fixup_build_ext', + 'requires_py26_min', 'skip_2to3_optimize', # imported from this module for backport purposes - 'unittest', 'requires_zlib', 'skip_2to3_optimize', 'skip_unless_symlink', + 'unittest', 'requires_zlib', 'skip_unless_symlink', ] @@ -402,10 +403,11 @@ except ImportError: skip_unless_symlink = unittest.skip( 'requires test.test_support.skip_unless_symlink') - skip_2to3_optimize = unittest.skipUnless(__debug__, "2to3 doesn't work under -O") +requires_py26_min = unittest.skipIf(sys.version_info[:2] < (2, 6), + 'requires Python 2.6 or higher') requires_zlib = unittest.skipUnless(zlib, 'requires zlib') diff --git a/distutils2/tests/test_command_build.py b/distutils2/tests/test_command_build.py index 08bef58..3a926cd 100644 --- a/distutils2/tests/test_command_build.py +++ b/distutils2/tests/test_command_build.py @@ -26,7 +26,8 @@ class BuildTestCase(support.TempdirManager, # build_platlib is 'build/lib.platform-x.x[-pydebug]' # examples: # build/lib.macosx-10.3-i386-2.7 - plat_spec = '.%s-%s' % (cmd.plat_name, sys.version[0:3]) + pyversion = '%s.%s' % sys.version_info[:2] + plat_spec = '.%s-%s' % (cmd.plat_name, pyversion) if hasattr(sys, 'gettotalrefcount'): self.assertTrue(cmd.build_platlib.endswith('-pydebug')) plat_spec += '-pydebug' @@ -41,7 +42,7 @@ class BuildTestCase(support.TempdirManager, self.assertEqual(cmd.build_temp, wanted) # build_scripts is build/scripts-x.x - wanted = os.path.join(cmd.build_base, 'scripts-' + sys.version[0:3]) + wanted = os.path.join(cmd.build_base, 'scripts-' + pyversion) self.assertEqual(cmd.build_scripts, wanted) # executable is os.path.normpath(sys.executable) diff --git a/distutils2/tests/test_command_build_ext.py b/distutils2/tests/test_command_build_ext.py index 5a6f77a..7b04cca 100644 --- a/distutils2/tests/test_command_build_ext.py +++ b/distutils2/tests/test_command_build_ext.py @@ -19,12 +19,12 @@ class BuildExtTestCase(support.TempdirManager, def setUp(self): super(BuildExtTestCase, self).setUp() self.tmp_dir = self.mkdtemp() - if sys.version > "2.6": + if sys.version_info[:2] >= (2, 6): self.old_user_base = site.USER_BASE site.USER_BASE = self.mkdtemp() def tearDown(self): - if sys.version > "2.6": + if sys.version_info[:2] >= (2, 6): site.USER_BASE = self.old_user_base super(BuildExtTestCase, self).tearDown() @@ -85,7 +85,7 @@ class BuildExtTestCase(support.TempdirManager, # make sure we get some library dirs under solaris self.assertGreater(len(cmd.library_dirs), 0) - @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher') + @support.requires_py26_min def test_user_site(self): dist = Distribution({'name': 'xx'}) cmd = build_ext(dist) diff --git a/distutils2/tests/test_command_install_dist.py b/distutils2/tests/test_command_install_dist.py index 572ca2a..02f962b 100644 --- a/distutils2/tests/test_command_install_dist.py +++ b/distutils2/tests/test_command_install_dist.py @@ -72,7 +72,7 @@ class InstallTestCase(support.TempdirManager, check_path(cmd.install_scripts, os.path.join(destination, "bin")) check_path(cmd.install_data, destination) - @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher') + @support.requires_py26_min def test_user_site(self): # test install with --user # preparing the environment for the test @@ -172,7 +172,7 @@ class InstallTestCase(support.TempdirManager, cmd.home = 'home' self.assertRaises(PackagingOptionError, cmd.finalize_options) - if sys.version >= '2.6': + if sys.version_info[:2] >= (2, 6): # can't combine user with with prefix/exec_prefix/home or # install_(plat)base cmd.prefix = None diff --git a/distutils2/tests/test_mixin2to3.py b/distutils2/tests/test_mixin2to3.py index 719a152..bfd5102 100644 --- a/distutils2/tests/test_mixin2to3.py +++ b/distutils2/tests/test_mixin2to3.py @@ -29,9 +29,9 @@ class Mixin2to3TestCase(support.TempdirManager, converted = fp.read() finally: fp.close() - self.assertMultiLineEqual(wanted, converted) + self.assertMultiLineEqual(converted, wanted) - @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher') + @support.requires_py26_min def test_conversion(self): # check that code and doctests get converted self.check('''\ @@ -57,7 +57,7 @@ class Mixin2to3TestCase(support.TempdirManager, ''', # 2to3 adds a newline here files=[self.filename]) - @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher') + @support.requires_py26_min def test_doctests_conversion(self): # check that doctest files are converted self.check('''\ @@ -75,7 +75,7 @@ class Mixin2to3TestCase(support.TempdirManager, ''', doctests=[self.filename]) - @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher') + @support.requires_py26_min def test_additional_fixers(self): # make sure the fixers argument works self.check("""\ diff --git a/distutils2/tests/test_util.py b/distutils2/tests/test_util.py index 6833905..c08517e 100644 --- a/distutils2/tests/test_util.py +++ b/distutils2/tests/test_util.py @@ -417,7 +417,7 @@ class UtilTestCase(support.EnvironRestorer, self.assertRaises(ImportError, resolve_name, 'a.b.Spam') self.assertRaises(ImportError, resolve_name, 'a.b.c.Spam') - @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher') + @support.requires_py26_min @support.skip_2to3_optimize def test_run_2to3_on_code(self): content = "print 'test'" @@ -432,7 +432,7 @@ class UtilTestCase(support.EnvironRestorer, file_handle.close() self.assertEqual(new_content, converted_content) - @unittest.skipIf(sys.version < '2.6', 'requires Python 2.6 or higher') + @support.requires_py26_min @support.skip_2to3_optimize def test_run_2to3_on_doctests(self): # to check if text files containing doctests only get converted. diff --git a/runtests.py b/runtests.py index 045c0dc..fa032ab 100644 --- a/runtests.py +++ b/runtests.py @@ -215,7 +215,7 @@ def test_main(): if __name__ == "__main__": - if sys.version < '2.5': + if sys.version_info[:2] < (2, 5): try: from distutils2._backport import hashlib except ImportError: @@ -208,6 +208,6 @@ def prepare_hashlib_extensions(): return exts setup_kwargs = cfg_to_args('setup.cfg') -if sys.version < '2.5': +if sys.version_info[:2] < (2, 5): setup_kwargs['ext_modules'] = prepare_hashlib_extensions() setup(**setup_kwargs) |
