Skip to content

Commit

Permalink
Deprecate the requires keyword
Browse files Browse the repository at this point in the history
For runtime dependencies, install_requires should be used. For build
dependencies, a PEP 518-compliant `pyproject.toml` should be used.

Other dependencies can use extra requirements.
  • Loading branch information
smenon8 authored and pganssle committed Oct 27, 2018
1 parent fb84b3f commit 7bfffe2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/1541.deprecation.rst
@@ -0,0 +1 @@
Remove support for "requires" parameter.
21 changes: 20 additions & 1 deletion setuptools/config.py
Expand Up @@ -2,8 +2,10 @@
import io
import os
import sys
import warnings
from collections import defaultdict
from functools import partial
from functools import wraps
from importlib import import_module

from distutils.errors import DistutilsOptionError, DistutilsFileError
Expand Down Expand Up @@ -399,6 +401,20 @@ def parse(self):

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):

Expand Down Expand Up @@ -434,7 +450,10 @@ def parsers(self):
'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,
Expand Down
17 changes: 17 additions & 0 deletions setuptools/tests/test_config.py
Expand Up @@ -391,6 +391,23 @@ def test_classifiers(self, tmpdir):
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:

Expand Down

0 comments on commit 7bfffe2

Please sign in to comment.