Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data_files support in setup.cfg #1520

Merged
merged 3 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1520.change.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added support for ``data_files`` in ``setup.cfg``.
5 changes: 5 additions & 0 deletions docs/setuptools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2367,6 +2367,11 @@ boilerplate code in some cases.
src.subpackage1
src.subpackage2

[options.data_files]
/etc/my_package =
site.d/00_default.conf
host.d/00_default.conf
data = data/img/logo.png, data/svg/icon.svg

Metadata and options are set in the config sections of the same name.

Expand Down
8 changes: 8 additions & 0 deletions setuptools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,3 +598,11 @@ def parse_section_extras_require(self, section_options):
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()]
17 changes: 17 additions & 0 deletions setuptools/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,23 @@ def test_entry_points(self, tmpdir):
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
Expand Down