2from collections
import OrderedDict
3from typing
import Dict, List
16 def __init__(self, check_supported_wheels: bool =
True) ->
None:
17 """Create a RequirementSet."""
19 self.requirements: Dict[str, InstallRequirement] = OrderedDict()
22 self.unnamed_requirements: List[InstallRequirement] = []
25 requirements = sorted(
27 key=
lambda req: canonicalize_name(
req.name or ""),
29 return " ".join(str(
req.req)
for req
in requirements)
32 requirements = sorted(
33 self.requirements.values(),
34 key=
lambda req: canonicalize_name(
req.name or ""),
37 format_string =
"<{classname} object; {count} requirement(s): {reqs}>"
39 classname=self.__class__.__name__,
40 count=
len(requirements),
41 reqs=
", ".join(str(
req.req)
for req
in requirements),
46 self.unnamed_requirements.append(install_req)
52 self.requirements[project_name] = install_req
55 project_name = canonicalize_name(name)
58 project_name
in self.requirements
59 and not self.requirements[project_name].constraint
62 def get_requirement(self, name: str) -> InstallRequirement:
63 project_name = canonicalize_name(name)
65 if project_name
in self.requirements:
66 return self.requirements[project_name]
68 raise KeyError(f
"No project with the name {name!r}")
72 return self.unnamed_requirements + list(self.requirements.values())
76 """Return the list of requirements that need to be installed.
78 TODO remove this property together with the legacy resolver, since the new
79 resolver only returns requirements that need to be installed.
87 def warn_legacy_versions_and_specifiers(self) -> None:
93 f
"pip has selected the non standard version {version} "
94 f
"of {req}. In the future this version will be "
95 f
"ignored as it isn't standard compliant."
98 "set or update constraints to select another version "
99 "or contact the package author to fix the version number"
108 f
"pip has selected {req} {version} which has non "
109 f
"standard dependency specifier {dep}. "
110 f
"In the future this version of {req} will be "
111 f
"ignored as it isn't standard compliant."
114 "set or update constraints to select another version "
115 "or contact the package author to fix the version number"
None add_named_requirement(self, InstallRequirement install_req)
List[InstallRequirement] all_requirements(self)
bool has_requirement(self, str name)
None __init__(self, bool check_supported_wheels=True)
List[InstallRequirement] requirements_to_install(self)
None add_unnamed_requirement(self, InstallRequirement install_req)