aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-04-20 09:25:21 -0400
committerJason R. Coombs <jaraco@jaraco.com>2016-04-20 09:25:21 -0400
commit085247fa441f9b0fac05117ca1a3283e3510fb32 (patch)
treeb068b08a093257c4b60b86f6fbf1e164f8e3125a
parentdf05ebf3e88858ae7ac74071bd20c86782e1415d (diff)
downloadexternal_python_setuptools-085247fa441f9b0fac05117ca1a3283e3510fb32.tar.gz
external_python_setuptools-085247fa441f9b0fac05117ca1a3283e3510fb32.tar.bz2
external_python_setuptools-085247fa441f9b0fac05117ca1a3283e3510fb32.zip
Use OrderedDict to retain deterministic ordering of version info in egg_info command. Remove lexicographic ordering in setopt.edit_config. Ref #553
-rwxr-xr-xsetuptools/command/egg_info.py23
-rwxr-xr-xsetuptools/command/setopt.py7
-rw-r--r--setuptools/tests/test_egg_info.py2
3 files changed, 18 insertions, 14 deletions
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py
index d1bd9b04..3c033300 100755
--- a/setuptools/command/egg_info.py
+++ b/setuptools/command/egg_info.py
@@ -13,6 +13,7 @@ import sys
import io
import warnings
import time
+import collections
from setuptools.extern import six
from setuptools.extern.six.moves import map
@@ -66,14 +67,20 @@ class egg_info(Command):
self.vtags = None
def save_version_info(self, filename):
- values = dict(
- egg_info=dict(
- tag_svn_revision=0,
- tag_date=0,
- tag_build=self.tags(),
- )
- )
- edit_config(filename, values)
+ """
+ Materialize the values of svn_revision and date into the
+ 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()
+ # follow the order these keys would have been added
+ # when PYTHONHASHSEED=0
+ egg_info['tag_date'] = 0
+ egg_info['tag_svn_revision'] = 0
+ egg_info['tag_build'] = self.tags()
+ edit_config(filename, dict(egg_info=egg_info))
def finalize_options(self):
self.egg_name = safe_name(self.distribution.get_name())
diff --git a/setuptools/command/setopt.py b/setuptools/command/setopt.py
index 912da782..7f332be5 100755
--- a/setuptools/command/setopt.py
+++ b/setuptools/command/setopt.py
@@ -2,7 +2,6 @@ from distutils.util import convert_path
from distutils import log
from distutils.errors import DistutilsOptionError
import distutils
-import operator
import os
from setuptools.extern.six.moves import configparser
@@ -43,8 +42,7 @@ def edit_config(filename, settings, dry_run=False):
log.debug("Reading configuration from %s", filename)
opts = configparser.RawConfigParser()
opts.read([filename])
- for section, options in sorted(settings.items(),
- key=operator.itemgetter(0)):
+ for section, options in settings.items():
if options is None:
log.info("Deleting section [%s] from %s", section, filename)
opts.remove_section(section)
@@ -52,8 +50,7 @@ def edit_config(filename, settings, dry_run=False):
if not opts.has_section(section):
log.debug("Adding new section [%s] to %s", section, filename)
opts.add_section(section)
- for option, value in sorted(options.items(),
- key=operator.itemgetter(0)):
+ for option, value in options.items():
if value is None:
log.debug(
"Deleting %s.%s from %s",
diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py
index d37b127e..7e7dd4a9 100644
--- a/setuptools/tests/test_egg_info.py
+++ b/setuptools/tests/test_egg_info.py
@@ -89,7 +89,7 @@ class TestEggInfo(object):
assert 'tag_svn_revision = 0' in content
if sys.version_info[0:2] >= (2, 7):
- assert re.search('tag_build.*tag_date.*tag_svn_revision',
+ assert re.search('tag_date.*tag_svn_revision.*tag_build',
content,
re.MULTILINE | re.DOTALL) is not None