4from typing
import Container, Dict, Generator, Iterable, List, NamedTuple, Optional, Set
27 requirement: Optional[List[str]] =
None,
28 local_only: bool =
False,
29 user_only: bool =
False,
30 paths: Optional[List[str]] =
None,
31 isolated: bool =
False,
32 exclude_editable: bool =
False,
33 skip: Container[str] = (),
34) -> Generator[str,
None,
None]:
35 installations: Dict[str, FrozenRequirement] = {}
37 dists = get_environment(paths).iter_installed_distributions(
38 local_only=local_only,
53 emitted_options: Set[str] = set()
57 for req_file_path
in requirement:
58 with open(req_file_path)
as req_file:
73 "--process-dependency-links",
80 if line
not in emitted_options:
87 line = line[2:].strip()
89 line = line[
len(
"--editable") :].strip().
lstrip(
"=")
90 line_req = install_req_from_editable(
95 line_req = install_req_from_line(
102 "Skipping line in requirement file [%s] because "
103 "it's not clear what it would install: %s",
108 " (add #egg=PackageName to the URL to avoid"
113 if line_req_canonical_name
not in installations:
118 "Requirement file [%s] contains %s, but "
119 "package %r is not installed",
127 yield str(installations[line_req_canonical_name]).rstrip()
128 del installations[line_req_canonical_name]
136 "Requirement %s included multiple times [%s]",
138 ", ".join(sorted(set(files))),
141 yield (
"## The following requirements were added by pip freeze:")
144 yield str(installation).rstrip()
156 Compute and return values (req, comments) for use in
157 FrozenRequirement.from_dist().
160 assert editable_project_location
167 if vcs_backend
is None:
170 'No VCS found for editable requirement "%s" in: %r',
175 requirement=location,
176 comments=[f
"# Editable install with no version control ({display})"],
179 vcs_name = type(vcs_backend).__name__
183 except RemoteNotFoundError:
186 requirement=location,
187 comments=[f
"# Editable {vcs_name} install with no remote ({display})"],
189 except RemoteNotValidError
as ex:
192 requirement=location,
194 f
"# Editable {vcs_name} install ({display}) with either a deleted "
195 f
"local remote or invalid URI:",
201 "cannot determine version of editable source in %s "
202 "(%s command not found in path)",
207 except InstallationError
as exc:
208 logger.warning(
"Error when trying to get requirement for VCS system %s", exc)
212 logger.warning(
"Could not determine repository location of %s", location)
215 requirement=location,
216 comments=[
"## !! Could not determine repository location"],