diff options
author | Satoru SATOH <satoru.satoh@gmail.com> | 2018-10-24 03:42:01 +0900 |
---|---|---|
committer | Paul Ganssle <paul@ganssle.io> | 2018-10-24 12:10:20 -0400 |
commit | 74afc688fc4084390c9e9169984b5f7d8339b8e4 (patch) | |
tree | e9aab17c86c89e8b4c45a3696a79e727be98218a /setuptools | |
parent | 5b90a0d9d97f52fc91792a8143670ee1a73f51c5 (diff) | |
download | external_python_setuptools-74afc688fc4084390c9e9169984b5f7d8339b8e4.tar.gz external_python_setuptools-74afc688fc4084390c9e9169984b5f7d8339b8e4.tar.bz2 external_python_setuptools-74afc688fc4084390c9e9169984b5f7d8339b8e4.zip |
Add data_files support in setup.cfg with test case
In the test case, dist.data_files needs to be sorted because the
current implementation loads the configuration files as a dictionary
with arbitrary order on Python < 3.6.
Diffstat (limited to 'setuptools')
-rw-r--r-- | setuptools/config.py | 8 | ||||
-rw-r--r-- | setuptools/tests/test_config.py | 17 |
2 files changed, 25 insertions, 0 deletions
diff --git a/setuptools/config.py b/setuptools/config.py index 0da3dbc9..73a3bf70 100644 --- a/setuptools/config.py +++ b/setuptools/config.py @@ -598,3 +598,11 @@ class ConfigOptionsHandler(ConfigHandler): parse_list = partial(self._parse_list, separator=';') self['extras_require'] = self._parse_section_to_dict( section_options, parse_list) + + def parse_section_data_files(self, section_options): + """Parses `data_files` configuration file section. + + :param dict section_options: + """ + parsed = self._parse_section_to_dict(section_options, self._parse_list) + self['data_files'] = [(k, v) for k, v in parsed.items()] diff --git a/setuptools/tests/test_config.py b/setuptools/tests/test_config.py index acf22154..76759ec5 100644 --- a/setuptools/tests/test_config.py +++ b/setuptools/tests/test_config.py @@ -703,6 +703,23 @@ class TestOptions: with get_dist(tmpdir) as dist: assert dist.entry_points == expected + def test_data_files(self, tmpdir): + fake_env( + tmpdir, + '[options.data_files]\n' + 'cfg =\n' + ' a/b.conf\n' + ' c/d.conf\n' + 'data = e/f.dat, g/h.dat\n' + ) + + with get_dist(tmpdir) as dist: + expected = [ + ('cfg', ['a/b.conf', 'c/d.conf']), + ('data', ['e/f.dat', 'g/h.dat']), + ] + assert sorted(dist.data_files) == sorted(expected) + saved_dist_init = _Distribution.__init__ class TestExternalSetters: # During creation of the setuptools Distribution() object, we call |