Skip to content

Commit 73e08a8

Browse files
committed
Move requirements processing to _reqs module. Add parse function.
1 parent 31c62fe commit 73e08a8

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

setuptools/_reqs.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import setuptools.extern.jaraco.text as text
2+
3+
from pkg_resources import Requirement
4+
5+
6+
def parse_strings(strs):
7+
"""
8+
Yield requirement strings for each specification in `strs`.
9+
10+
`strs` must be a string, or a (possibly-nested) iterable thereof.
11+
"""
12+
return text.join_continuation(map(text.drop_comment, text.yield_lines(strs)))
13+
14+
15+
def parse(strs):
16+
"""
17+
Deprecated drop-in replacement for pkg_resources.parse_requirements.
18+
"""
19+
return map(Requirement, parse_strings(strs))

setuptools/build_meta.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737

3838
import setuptools
3939
import distutils
40-
41-
import setuptools.extern.jaraco.text as text
40+
from ._reqs import parse_strings
4241

4342
__all__ = ['get_requires_for_build_sdist',
4443
'get_requires_for_build_wheel',
@@ -49,23 +48,14 @@
4948
'SetupRequirementsError']
5049

5150

52-
def parse_requirements(strs):
53-
"""
54-
Yield requirement strings for each specification in `strs`.
55-
56-
`strs` must be a string, or a (possibly-nested) iterable thereof.
57-
"""
58-
return text.join_continuation(map(text.drop_comment, text.yield_lines(strs)))
59-
60-
6151
class SetupRequirementsError(BaseException):
6252
def __init__(self, specifiers):
6353
self.specifiers = specifiers
6454

6555

6656
class Distribution(setuptools.dist.Distribution):
6757
def fetch_build_eggs(self, specifiers):
68-
specifier_list = list(parse_requirements(specifiers))
58+
specifier_list = list(parse_strings(specifiers))
6959

7060
raise SetupRequirementsError(specifier_list)
7161

0 commit comments

Comments
 (0)