14from typing
import Dict, List, Optional, Set, Tuple, Union
61 """Parses an editable requirement into:
66 Accepted requirements:
67 svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir
78 url_no_extras = path_to_url(url_no_extras)
81 package_name =
Link(url_no_extras).egg_fragment
89 return package_name, url_no_extras, set()
91 for version_control
in vcs:
93 url = f
"{version_control}+{url}"
101 f
"{editable_req} is not a valid editable requirement. "
102 f
"It should either be a path to a local project or a VCS URL "
103 f
"(beginning with {backends})."
109 "Could not detect requirement name for '{}', please specify one "
110 "with #egg=your_package_name".format(editable_req)
112 return package_name, url, set()
201def install_req_from_editable(
203 comes_from: Optional[Union[InstallRequirement, str]] =
None,
205 use_pep517: Optional[bool] =
None,
206 isolated: bool =
False,
207 global_options: Optional[List[str]] =
None,
208 hash_options: Optional[Dict[str, List[str]]] =
None,
209 constraint: bool =
False,
210 user_supplied: bool =
False,
211 permit_editable_wheels: bool =
False,
212 config_settings: Optional[Dict[str, Union[str, List[str]]]] =
None,
213) -> InstallRequirement:
218 comes_from=comes_from,
219 user_supplied=user_supplied,
221 permit_editable_wheels=permit_editable_wheels,
223 constraint=constraint,
224 use_pep517=use_pep517,
226 global_options=global_options,
227 hash_options=hash_options,
228 config_settings=config_settings,
291 if marker_sep
in name:
292 name, markers_as_string =
name.split(marker_sep, 1)
294 if not markers_as_string:
297 markers =
Marker(markers_as_string)
304 extras_as_string =
None
322 req_as_string = f
"{wheel.name}=={wheel.version}"
337 return f
"{text} (from {line_source})"
341 req = get_requirement(req_as_string)
342 except InvalidRequirement:
344 add_msg =
"It looks like a path."
346 elif "=" in req_as_string
and not any(
347 op
in req_as_string
for op
in operators
349 add_msg =
"= is not a valid operator. Did you mean == ?"
352 msg =
with_source(f
"Invalid requirement: {req_as_string!r}")
354 msg += f
"\nHint: {add_msg}"
364 msg = f
"Extras after version '{spec_str}'."
368 if req_as_string
is not None:
376def install_req_from_line(
378 comes_from: Optional[Union[str, InstallRequirement]] =
None,
380 use_pep517: Optional[bool] =
None,
381 isolated: bool =
False,
382 global_options: Optional[List[str]] =
None,
383 hash_options: Optional[Dict[str, List[str]]] =
None,
384 constraint: bool =
False,
385 line_source: Optional[str] =
None,
386 user_supplied: bool =
False,
387 config_settings: Optional[Dict[str, Union[str, List[str]]]] =
None,
388) -> InstallRequirement:
389 """Creates an InstallRequirement from a name, which might be a
390 requirement, directory containing 'setup.py', filename, or URL.
392 :param line_source: An optional string describing where the line is from,
393 for logging purposes in case of an error.
402 use_pep517=use_pep517,
404 global_options=global_options,
405 hash_options=hash_options,
406 config_settings=config_settings,
407 constraint=constraint,
409 user_supplied=user_supplied,
451def install_req_from_parsed_requirement(
452 parsed_req: ParsedRequirement,
453 isolated: bool =
False,
454 use_pep517: Optional[bool] =
None,
455 user_supplied: bool =
False,
456 config_settings: Optional[Dict[str, Union[str, List[str]]]] =
None,
457) -> InstallRequirement:
459 req = install_req_from_editable(
462 use_pep517=use_pep517,
465 user_supplied=user_supplied,
466 config_settings=config_settings,
470 req = install_req_from_line(
473 use_pep517=use_pep517,
485 user_supplied=user_supplied,
486 config_settings=config_settings,