diff --git a/setuptools/_reqs.py b/setuptools/_reqs.py new file mode 100644 index 0000000000..ca7241746b --- /dev/null +++ b/setuptools/_reqs.py @@ -0,0 +1,19 @@ +import setuptools.extern.jaraco.text as text + +from pkg_resources import Requirement + + +def parse_strings(strs): + """ + Yield requirement strings for each specification in `strs`. + + `strs` must be a string, or a (possibly-nested) iterable thereof. + """ + return text.join_continuation(map(text.drop_comment, text.yield_lines(strs))) + + +def parse(strs): + """ + Deprecated drop-in replacement for pkg_resources.parse_requirements. + """ + return map(Requirement, parse_strings(strs)) diff --git a/setuptools/build_meta.py b/setuptools/build_meta.py index cdaac36092..1daa77c92e 100644 --- a/setuptools/build_meta.py +++ b/setuptools/build_meta.py @@ -37,8 +37,7 @@ import setuptools import distutils - -import setuptools.extern.jaraco.text as text +from ._reqs import parse_strings __all__ = ['get_requires_for_build_sdist', 'get_requires_for_build_wheel', @@ -49,15 +48,6 @@ 'SetupRequirementsError'] -def parse_requirements(strs): - """ - Yield requirement strings for each specification in `strs`. - - `strs` must be a string, or a (possibly-nested) iterable thereof. - """ - return text.join_continuation(map(text.drop_comment, text.yield_lines(strs))) - - class SetupRequirementsError(BaseException): def __init__(self, specifiers): self.specifiers = specifiers @@ -65,7 +55,7 @@ def __init__(self, specifiers): class Distribution(setuptools.dist.Distribution): def fetch_build_eggs(self, specifiers): - specifier_list = list(parse_requirements(specifiers)) + specifier_list = list(parse_strings(specifiers)) raise SetupRequirementsError(specifier_list)