aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2019-10-06 21:29:51 -0400
committerGitHub <noreply@github.com>2019-10-06 21:29:51 -0400
commit01bf4fb2b13c3f7f6d9e8d253d2923b5ea09caa2 (patch)
treea3eea31cca692d8dd2704b475dbd8ebf473a0e56
parentda3ccf5f648a5836ce5e9b0747a263860ae1dfaa (diff)
parent2e3c34f669c5272d036ef7edc58871c96663d587 (diff)
downloadexternal_python_setuptools-01bf4fb2b13c3f7f6d9e8d253d2923b5ea09caa2.tar.gz
external_python_setuptools-01bf4fb2b13c3f7f6d9e8d253d2923b5ea09caa2.tar.bz2
external_python_setuptools-01bf4fb2b13c3f7f6d9e8d253d2923b5ea09caa2.zip
Merge pull request #1847 from pypa/bugfix/1787-python-requires-invalid
Crash when invalid python_requires indicated in setup.cfg
-rw-r--r--changelog.d/1847.change.rst1
-rw-r--r--setuptools/config.py2
-rw-r--r--setuptools/tests/test_config.py34
3 files changed, 37 insertions, 0 deletions
diff --git a/changelog.d/1847.change.rst b/changelog.d/1847.change.rst
new file mode 100644
index 00000000..d3f7724e
--- /dev/null
+++ b/changelog.d/1847.change.rst
@@ -0,0 +1 @@
+In declarative config, now traps errors when invalid ``python_requires`` values are supplied.
diff --git a/setuptools/config.py b/setuptools/config.py
index b6626043..2d50e25e 100644
--- a/setuptools/config.py
+++ b/setuptools/config.py
@@ -12,6 +12,7 @@ from importlib import import_module
from distutils.errors import DistutilsOptionError, DistutilsFileError
from setuptools.extern.packaging.version import LegacyVersion, parse
+from setuptools.extern.packaging.specifiers import SpecifierSet
from setuptools.extern.six import string_types, PY3
@@ -554,6 +555,7 @@ class ConfigOptionsHandler(ConfigHandler):
'packages': self._parse_packages,
'entry_points': self._parse_file,
'py_modules': parse_list,
+ 'python_requires': SpecifierSet,
}
def _parse_packages(self, value):
diff --git a/setuptools/tests/test_config.py b/setuptools/tests/test_config.py
index bc97664d..1b94a586 100644
--- a/setuptools/tests/test_config.py
+++ b/setuptools/tests/test_config.py
@@ -819,6 +819,40 @@ class TestOptions:
]
assert sorted(dist.data_files) == sorted(expected)
+ def test_python_requires_simple(self, tmpdir):
+ fake_env(
+ tmpdir,
+ DALS("""
+ [options]
+ python_requires=>=2.7
+ """),
+ )
+ with get_dist(tmpdir) as dist:
+ dist.parse_config_files()
+
+ def test_python_requires_compound(self, tmpdir):
+ fake_env(
+ tmpdir,
+ DALS("""
+ [options]
+ python_requires=>=2.7,!=3.0.*
+ """),
+ )
+ with get_dist(tmpdir) as dist:
+ dist.parse_config_files()
+
+ def test_python_requires_invalid(self, tmpdir):
+ fake_env(
+ tmpdir,
+ DALS("""
+ [options]
+ python_requires=invalid
+ """),
+ )
+ with pytest.raises(Exception):
+ with get_dist(tmpdir) as dist:
+ dist.parse_config_files()
+
saved_dist_init = _Distribution.__init__