diff options
author | Davanum Srinivas <davanum@gmail.com> | 2016-04-18 15:08:49 -0400 |
---|---|---|
committer | Davanum Srinivas <davanum@gmail.com> | 2016-04-19 13:34:47 -0400 |
commit | df05ebf3e88858ae7ac74071bd20c86782e1415d (patch) | |
tree | b9f3e1af1bea5f952f05d5dc152c279c8ec15889 /setuptools/command/setopt.py | |
parent | fc6aec49d66daaf28d0c1a5ddb31766a056599f1 (diff) | |
download | python-setuptools-git-df05ebf3e88858ae7ac74071bd20c86782e1415d.tar.gz |
Preserve order of egg_info section in setup.cfg
egg_info is the dictionary with information that is injected
into setup.cfg. edit_config uses RawConfigParser which uses
collections.OrderedDict for all the data. When we use a
simple dict(), when we loop through items in edit_config, we
see random behavior as a result the fields
tag_svn_revision/tag_date/tag_build are added to the setup.cfg
randomly. So if we sort the items by key when we traverse items
we will get deterministic output as RawConfigParser uses
OrderedDict internally by default.
Diffstat (limited to 'setuptools/command/setopt.py')
-rwxr-xr-x | setuptools/command/setopt.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/setuptools/command/setopt.py b/setuptools/command/setopt.py index 7f332be5..912da782 100755 --- a/setuptools/command/setopt.py +++ b/setuptools/command/setopt.py @@ -2,6 +2,7 @@ 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 @@ -42,7 +43,8 @@ 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 settings.items(): + for section, options in sorted(settings.items(), + key=operator.itemgetter(0)): if options is None: log.info("Deleting section [%s] from %s", section, filename) opts.remove_section(section) @@ -50,7 +52,8 @@ 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 options.items(): + for option, value in sorted(options.items(), + key=operator.itemgetter(0)): if value is None: log.debug( "Deleting %s.%s from %s", |