summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2022-02-05 09:48:56 -0500
committerJason R. Coombs <jaraco@jaraco.com>2022-02-05 09:48:56 -0500
commit73e08a8acd3038a79ef37c0e5769d934d609f6c7 (patch)
treee11829070a8b348595d0e870aa1cd991b63b52d5
parent31c62fe9f5d60d6c913ac68af8469f734f68f363 (diff)
downloadpython-setuptools-git-73e08a8acd3038a79ef37c0e5769d934d609f6c7.tar.gz
Move requirements processing to _reqs module. Add parse function.
-rw-r--r--setuptools/_reqs.py19
-rw-r--r--setuptools/build_meta.py14
2 files changed, 21 insertions, 12 deletions
diff --git a/setuptools/_reqs.py b/setuptools/_reqs.py
new file mode 100644
index 00000000..ca724174
--- /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 cdaac360..1daa77c9 100644
--- a/setuptools/build_meta.py
+++ b/setuptools/build_meta.py
@@ -37,8 +37,7 @@ import warnings
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 @@ __all__ = ['get_requires_for_build_sdist',
'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 @@ class SetupRequirementsError(BaseException):
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)