Repository: pypa/setuptools

Issue:
Option 'python_requires' is not supported in configuration files
The option `python_requires` is not supported when metadata / options are loaded from `setup.cfg` via #862.

On a side note: Is it intended behavior that those package specific metadata / options may be given in all configuration files given by `distutils.core.Distribution.find_config_files` (i.e. including the user's `.pydistutils.cfg`, which is not specific to the package)?


Discussion:
It's probably a design flaw that these option definitions need to be defined in two places, but that's what we've got. Would you consider creating a PR to address the missing option?

> Is it intended behavior that those package specific metadata / options may be given in all configuration files?

That does seem like a defect, but perhaps ignorable. I can see how one might want to define the 'author' or 'maintainer' as users settings, though that does have some nasty implications around replicable builds. I don't think it was intentional that these other files are honored for these settings.

Resolving patch:
diff --git a/setuptools/config.py b/setuptools/config.py
--- a/setuptools/config.py
+++ b/setuptools/config.py
@@ -462,6 +462,7 @@ def parsers(self):
             'tests_require': parse_list_semicolon,
             'packages': self._parse_packages,
             'entry_points': self._parse_file,
+            'py_modules': parse_list,
         }
 
     def _parse_packages(self, value):
diff --git a/setuptools/dist.py b/setuptools/dist.py
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -166,7 +166,7 @@ def check_specifier(dist, attr, value):
         packaging.specifiers.SpecifierSet(value)
     except packaging.specifiers.InvalidSpecifier as error:
         tmpl = (
-            "{attr!r} must be a string or list of strings "
+            "{attr!r} must be a string "
             "containing valid version specifiers; {error}"
         )
         raise DistutilsSetupError(tmpl.format(attr=attr, error=error))
@@ -353,6 +353,8 @@ def parse_config_files(self, filenames=None):
         _Distribution.parse_config_files(self, filenames=filenames)
 
         parse_configuration(self, self.command_options)
+        if getattr(self, 'python_requires', None):
+            self.metadata.python_requires = self.python_requires
 
     def parse_command_line(self):
         """Process features after parsing command line options"""


Test patch:
diff --git a/setuptools/tests/test_config.py b/setuptools/tests/test_config.py
--- a/setuptools/tests/test_config.py
+++ b/setuptools/tests/test_config.py
@@ -312,6 +312,8 @@ def test_basic(self, tmpdir):
             'setup_requires = docutils>=0.3; spack ==1.1, ==1.3; there\n'
             'dependency_links = http://some.com/here/1, '
                 'http://some.com/there/2\n'
+            'python_requires = >=1.0, !=2.8\n'
+            'py_modules = module1, module2\n'
         )
         with get_dist(tmpdir) as dist:
             assert dist.zip_safe
@@ -340,6 +342,8 @@ def test_basic(self, tmpdir):
                 'there'
             ])
             assert dist.tests_require == ['mock==0.7.2', 'pytest']
+            assert dist.python_requires == '>=1.0, !=2.8'
+            assert dist.py_modules == ['module1', 'module2']
 
     def test_multiline(self, tmpdir):
         fake_env(