11
11
import logging
12
12
import os
13
13
import re
14
- from typing import Any , Dict , Optional , Set , Tuple , Union
14
+ from typing import Dict , List , Optional , Set , Tuple , Union
15
15
16
16
from pip ._vendor .packaging .markers import Marker
17
17
from pip ._vendor .packaging .requirements import InvalidRequirement , Requirement
@@ -201,13 +201,15 @@ def parse_req_from_editable(editable_req: str) -> RequirementParts:
201
201
def install_req_from_editable (
202
202
editable_req : str ,
203
203
comes_from : Optional [Union [InstallRequirement , str ]] = None ,
204
+ * ,
204
205
use_pep517 : Optional [bool ] = None ,
205
206
isolated : bool = False ,
206
- options : Optional [Dict [str , Any ]] = None ,
207
+ global_options : Optional [List [str ]] = None ,
208
+ hash_options : Optional [Dict [str , List [str ]]] = None ,
207
209
constraint : bool = False ,
208
210
user_supplied : bool = False ,
209
211
permit_editable_wheels : bool = False ,
210
- config_settings : Optional [Dict [str , str ]] = None ,
212
+ config_settings : Optional [Dict [str , Union [ str , List [ str ]] ]] = None ,
211
213
) -> InstallRequirement :
212
214
213
215
parts = parse_req_from_editable (editable_req )
@@ -222,8 +224,8 @@ def install_req_from_editable(
222
224
constraint = constraint ,
223
225
use_pep517 = use_pep517 ,
224
226
isolated = isolated ,
225
- global_options = options . get ( " global_options" , []) if options else [] ,
226
- hash_options = options . get ( "hashes" , {}) if options else {} ,
227
+ global_options = global_options ,
228
+ hash_options = hash_options ,
227
229
config_settings = config_settings ,
228
230
extras = parts .extras ,
229
231
)
@@ -375,13 +377,15 @@ def _parse_req_string(req_as_string: str) -> Requirement:
375
377
def install_req_from_line (
376
378
name : str ,
377
379
comes_from : Optional [Union [str , InstallRequirement ]] = None ,
380
+ * ,
378
381
use_pep517 : Optional [bool ] = None ,
379
382
isolated : bool = False ,
380
- options : Optional [Dict [str , Any ]] = None ,
383
+ global_options : Optional [List [str ]] = None ,
384
+ hash_options : Optional [Dict [str , List [str ]]] = None ,
381
385
constraint : bool = False ,
382
386
line_source : Optional [str ] = None ,
383
387
user_supplied : bool = False ,
384
- config_settings : Optional [Dict [str , str ]] = None ,
388
+ config_settings : Optional [Dict [str , Union [ str , List [ str ]] ]] = None ,
385
389
) -> InstallRequirement :
386
390
"""Creates an InstallRequirement from a name, which might be a
387
391
requirement, directory containing 'setup.py', filename, or URL.
@@ -398,8 +402,8 @@ def install_req_from_line(
398
402
markers = parts .markers ,
399
403
use_pep517 = use_pep517 ,
400
404
isolated = isolated ,
401
- global_options = options . get ( " global_options" , []) if options else [] ,
402
- hash_options = options . get ( "hashes" , {}) if options else {} ,
405
+ global_options = global_options ,
406
+ hash_options = hash_options ,
403
407
config_settings = config_settings ,
404
408
constraint = constraint ,
405
409
extras = parts .extras ,
@@ -413,7 +417,7 @@ def install_req_from_req_string(
413
417
isolated : bool = False ,
414
418
use_pep517 : Optional [bool ] = None ,
415
419
user_supplied : bool = False ,
416
- config_settings : Optional [Dict [str , str ]] = None ,
420
+ config_settings : Optional [Dict [str , Union [ str , List [ str ]] ]] = None ,
417
421
) -> InstallRequirement :
418
422
try :
419
423
req = get_requirement (req_string )
@@ -452,7 +456,6 @@ def install_req_from_parsed_requirement(
452
456
isolated : bool = False ,
453
457
use_pep517 : Optional [bool ] = None ,
454
458
user_supplied : bool = False ,
455
- config_settings : Optional [Dict [str , str ]] = None ,
456
459
) -> InstallRequirement :
457
460
if parsed_req .is_editable :
458
461
req = install_req_from_editable (
@@ -462,7 +465,6 @@ def install_req_from_parsed_requirement(
462
465
constraint = parsed_req .constraint ,
463
466
isolated = isolated ,
464
467
user_supplied = user_supplied ,
465
- config_settings = config_settings ,
466
468
)
467
469
468
470
else :
@@ -471,11 +473,17 @@ def install_req_from_parsed_requirement(
471
473
comes_from = parsed_req .comes_from ,
472
474
use_pep517 = use_pep517 ,
473
475
isolated = isolated ,
474
- options = parsed_req .options ,
476
+ global_options = (
477
+ parsed_req .options .get ("global_options" , [])
478
+ if parsed_req .options
479
+ else []
480
+ ),
481
+ hash_options = (
482
+ parsed_req .options .get ("hashes" , {}) if parsed_req .options else {}
483
+ ),
475
484
constraint = parsed_req .constraint ,
476
485
line_source = parsed_req .line_source ,
477
486
user_supplied = user_supplied ,
478
- config_settings = config_settings ,
479
487
)
480
488
return req
481
489
0 commit comments