Repository: pypa/setuptools (python)

Issue:
data_files support in setup.cfg
Hello,

I work on a Python project that uses [data_files](https://docs.python.org/2/distutils/setupscript.html#installing-additional-files) in its `setup.py`. While I've moved most of my `setup.py` arguments over to a `setup.cfg` file, I still have `data_files` in `setup.py` because `setup.cfg` doesn't seem to support it.

I could take a stab at a PR to add this support in, but I just wanted to check first. Is this feature missing on purpose, or just hasn't been implemented yet?

Pull request description:
Add data_files support in setup.cfg
<!-- First time contributors: Take a moment to review https://setuptools.readthedocs.io/en/latest/developer-guide.html! -->
<!-- Remove sections if not applicable -->

## Summary of changes

These commits add data_files support in setup.cfg, discussed in the issue #1189, such like the following.
```
[options.data_files]
data = data/48x48/logo.png, data/scale/logo.svg
conf =
    site.d/00_default.conf
    host.d/00_default.conf
```

I think it may close #1189.

### Pull Request Checklist
- [x] Changes have tests
- [x] News fragment added in changelog.d. See [documentation](http://setuptools.readthedocs.io/en/latest/developer-guide.html#making-a-pull-request) for details

Patch:
diff --git a/changelog.d/1517.change.rst b/changelog.d/1517.change.rst
deleted file mode 100644
index 18a77a8ba..000000000
--- a/changelog.d/1517.change.rst
+++ /dev/null
@@ -1,1 +0,0 @@
-Dropped use of six.u in favor of `u""` literals.
diff --git a/changelog.d/1520.change.rst b/changelog.d/1520.change.rst
new file mode 100644
index 000000000..00569c6ff
--- /dev/null
+++ b/changelog.d/1520.change.rst
@@ -0,0 +1,1 @@
+Added support for ``data_files`` in ``setup.cfg``.
diff --git a/docs/setuptools.txt b/docs/setuptools.txt
index 89f45bd85..da9b0132e 100644
--- a/docs/setuptools.txt
+++ b/docs/setuptools.txt
@@ -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.
 
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index c670a16e6..3da601b74 100644
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -632,7 +632,7 @@ class easy_install(Command):
 
     @contextlib.contextmanager
     def _tmpdir(self):
-        tmpdir = tempfile.mkdtemp(prefix=u"easy_install-")
+        tmpdir = tempfile.mkdtemp(prefix=six.u("easy_install-"))
         try:
             # cast to str as workaround for #709 and #710 and #712
             yield str(tmpdir)
diff --git a/setuptools/config.py b/setuptools/config.py
index 0da3dbc9c..73a3bf703 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()]


Test patch:
diff --git a/setuptools/tests/test_config.py b/setuptools/tests/test_config.py
index acf221549..76759ec57 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