aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Ganssle <pganssle@users.noreply.github.com>2018-10-29 16:38:10 -0400
committerGitHub <noreply@github.com>2018-10-29 16:38:10 -0400
commita50f09b90c4433aa4ef7b50c682413191da0a1d9 (patch)
tree17b5f6a345ca3040b51a922374607121ec006ccd
parent566f3aadfa112b8d6b9a1ecf5178552f6e0f8c6c (diff)
parent1c226bdeb61dbd82419508dcc65b9969d0f42e16 (diff)
downloadexternal_python_setuptools-a50f09b90c4433aa4ef7b50c682413191da0a1d9.tar.gz
external_python_setuptools-a50f09b90c4433aa4ef7b50c682413191da0a1d9.tar.bz2
external_python_setuptools-a50f09b90c4433aa4ef7b50c682413191da0a1d9.zip
Merge pull request #1541 from smenon8/deprecate-requires
Deprecate the requires keyword
-rw-r--r--changelog.d/1541.deprecation.rst1
-rw-r--r--setuptools/config.py22
-rw-r--r--setuptools/tests/test_config.py17
3 files changed, 39 insertions, 1 deletions
diff --git a/changelog.d/1541.deprecation.rst b/changelog.d/1541.deprecation.rst
new file mode 100644
index 00000000..cc07aaa7
--- /dev/null
+++ b/changelog.d/1541.deprecation.rst
@@ -0,0 +1 @@
+Officially deprecated the ``requires`` parameter in ``setup()``.
diff --git a/setuptools/config.py b/setuptools/config.py
index 15d18672..d1ac6734 100644
--- a/setuptools/config.py
+++ b/setuptools/config.py
@@ -2,9 +2,12 @@ from __future__ import absolute_import, unicode_literals
import io
import os
import sys
+
+import warnings
import functools
from collections import defaultdict
from functools import partial
+from functools import wraps
from importlib import import_module
from distutils.errors import DistutilsOptionError, DistutilsFileError
@@ -402,6 +405,20 @@ class ConfigHandler:
section_parser_method(section_options)
+ def _deprecated_config_handler(self, func, msg, warning_class):
+ """ this function will wrap around parameters that are deprecated
+
+ :param msg: deprecation message
+ :param warning_class: class of warning exception to be raised
+ :param func: function to be wrapped around
+ """
+ @wraps(func)
+ def config_handler(*args, **kwargs):
+ warnings.warn(msg, warning_class)
+ return func(*args, **kwargs)
+
+ return config_handler
+
class ConfigMetadataHandler(ConfigHandler):
@@ -437,7 +454,10 @@ class ConfigMetadataHandler(ConfigHandler):
'platforms': parse_list,
'keywords': parse_list,
'provides': parse_list,
- 'requires': parse_list,
+ 'requires': self._deprecated_config_handler(parse_list,
+ "The requires parameter is deprecated, please use " +
+ "install_requires for runtime dependencies.",
+ DeprecationWarning),
'obsoletes': parse_list,
'classifiers': self._get_parser_compound(parse_file, parse_list),
'license': parse_file,
diff --git a/setuptools/tests/test_config.py b/setuptools/tests/test_config.py
index 76759ec5..736c184d 100644
--- a/setuptools/tests/test_config.py
+++ b/setuptools/tests/test_config.py
@@ -391,6 +391,23 @@ class TestMetadata:
with get_dist(tmpdir) as dist:
assert set(dist.metadata.classifiers) == expected
+ def test_deprecated_config_handlers(self, tmpdir):
+ fake_env(
+ tmpdir,
+ '[metadata]\n'
+ 'version = 10.1.1\n'
+ 'description = Some description\n'
+ 'requires = some, requirement\n'
+ )
+
+ with pytest.deprecated_call():
+ with get_dist(tmpdir) as dist:
+ metadata = dist.metadata
+
+ assert metadata.version == '10.1.1'
+ assert metadata.description == 'Some description'
+ assert metadata.requires == ['some', 'requirement']
+
class TestOptions: