Commit 7a909b2a authored by Jason R. Coombs's avatar Jason R. Coombs Committed by GitHub

Merge pull request #1690 from pypa/feature/deterministic-provides-extras

Honor declared ordering for Provides-Extra entries in package metadata.
parents cb64d3a8 6f962a07
When storing extras, rely on OrderedSet to retain order of extras as indicated by the packager, which will also be deterministic on Python 2.7 (with PYTHONHASHSEED unset) and Python 3.6+.
This diff is collapsed.
packaging==16.8
pyparsing==2.2.1
six==1.10.0
ordered-set
......@@ -27,6 +27,7 @@ from distutils.version import StrictVersion
from setuptools.extern import six
from setuptools.extern import packaging
from setuptools.extern import ordered_set
from setuptools.extern.six.moves import map, filter, filterfalse
from . import SetuptoolsDeprecationWarning
......@@ -407,7 +408,7 @@ class Distribution(_Distribution):
_DISTUTILS_UNSUPPORTED_METADATA = {
'long_description_content_type': None,
'project_urls': dict,
'provides_extras': set,
'provides_extras': ordered_set.OrderedSet,
}
_patched_dist = None
......
......@@ -69,5 +69,5 @@ class VendorImporter:
sys.meta_path.append(self)
names = 'six', 'packaging', 'pyparsing',
names = 'six', 'packaging', 'pyparsing', 'ordered_set',
VendorImporter(__name__, names, 'setuptools._vendor').install()
......@@ -3,6 +3,7 @@
from __future__ import unicode_literals
import io
import collections
import re
from distutils.errors import DistutilsSetupError
from setuptools.dist import (
......@@ -271,6 +272,19 @@ def test_maintainer_author(name, attrs, tmpdir):
assert line in pkg_lines_set
def test_provides_extras_deterministic_order():
extras = collections.OrderedDict()
extras['a'] = ['foo']
extras['b'] = ['bar']
attrs = dict(extras_require=extras)
dist = Distribution(attrs)
assert dist.metadata.provides_extras == ['a', 'b']
attrs['extras_require'] = collections.OrderedDict(
reversed(list(attrs['extras_require'].items())))
dist = Distribution(attrs)
assert dist.metadata.provides_extras == ['b', 'a']
CHECK_PACKAGE_DATA_TESTS = (
# Valid.
({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment