@@ -272,23 +272,22 @@ def _get_url_from_path(path, name):
272
272
return path_to_url (path )
273
273
274
274
275
- def install_req_from_line (
276
- name , # type: str
277
- comes_from = None , # type: Optional[Union[str, InstallRequirement]]
278
- use_pep517 = None , # type: Optional[bool]
279
- isolated = False , # type: bool
280
- options = None , # type: Optional[Dict[str, Any]]
281
- wheel_cache = None , # type: Optional[WheelCache]
282
- constraint = False , # type: bool
283
- line_source = None , # type: Optional[str]
284
- ):
285
- # type: (...) -> InstallRequirement
286
- """Creates an InstallRequirement from a name, which might be a
287
- requirement, directory containing 'setup.py', filename, or URL.
288
-
289
- :param line_source: An optional string describing where the line is from,
290
- for logging purposes in case of an error.
291
- """
275
+ class RequirementParts (object ):
276
+ def __init__ (
277
+ self ,
278
+ requirement , # type: Optional[Requirement]
279
+ link , # type: Optional[Link]
280
+ markers , # type: Optional[Marker]
281
+ extras , # type: Set[str]
282
+ ):
283
+ self .requirement = requirement
284
+ self .link = link
285
+ self .markers = markers
286
+ self .extras = extras
287
+
288
+
289
+ def parse_req_from_line (name , line_source ):
290
+ # type: (str, Optional[str]) -> RequirementParts
292
291
if is_url (name ):
293
292
marker_sep = '; '
294
293
else :
@@ -363,13 +362,35 @@ def with_source(text):
363
362
else :
364
363
req = None
365
364
365
+ return RequirementParts (req , link , markers , extras )
366
+
367
+
368
+ def install_req_from_line (
369
+ name , # type: str
370
+ comes_from = None , # type: Optional[Union[str, InstallRequirement]]
371
+ use_pep517 = None , # type: Optional[bool]
372
+ isolated = False , # type: bool
373
+ options = None , # type: Optional[Dict[str, Any]]
374
+ wheel_cache = None , # type: Optional[WheelCache]
375
+ constraint = False , # type: bool
376
+ line_source = None , # type: Optional[str]
377
+ ):
378
+ # type: (...) -> InstallRequirement
379
+ """Creates an InstallRequirement from a name, which might be a
380
+ requirement, directory containing 'setup.py', filename, or URL.
381
+
382
+ :param line_source: An optional string describing where the line is from,
383
+ for logging purposes in case of an error.
384
+ """
385
+ parts = parse_req_from_line (name , line_source )
386
+
366
387
return InstallRequirement (
367
- req , comes_from , link = link , markers = markers ,
388
+ parts . requirement , comes_from , link = parts . link , markers = parts . markers ,
368
389
use_pep517 = use_pep517 , isolated = isolated ,
369
390
options = options if options else {},
370
391
wheel_cache = wheel_cache ,
371
392
constraint = constraint ,
372
- extras = extras ,
393
+ extras = parts . extras ,
373
394
)
374
395
375
396
0 commit comments