3from optparse
import Values
4from typing
import TYPE_CHECKING, Generator, List, Optional, Sequence, Tuple, cast
24 """Give the distribution object a couple of extra fields.
26 These will be populated during ``get_outdated()``. This is dirty but
27 makes the rest of the code much cleaner.
30 latest_version: DistributionVersion
33 _ProcessedDists = Sequence[_DistWithLatestInfo]
41 List installed packages, including editables.
43 Packages are listed in a case-insensitive sorted order.
46 ignore_require_venv =
True
56 help=
"List outdated packages",
63 help=
"List uptodate packages",
70 help=
"List editable projects.",
78 "If in a virtualenv that has global access, do not list "
79 "globally-installed packages."
87 help=
"Only output packages installed in user-site.",
95 "Include pre-release and development versions. By default, "
96 "pip only finds stable versions."
105 choices=(
"columns",
"freeze",
"json"),
107 "Select the output format among: columns (default), freeze, or json. "
108 "The 'freeze' format cannot be used with the --outdated option."
116 help=
"List packages that are not dependencies of installed packages.",
120 "--exclude-editable",
121 action=
"store_false",
122 dest=
"include_editable",
123 help=
"Exclude editable package from output.",
126 "--include-editable",
128 dest=
"include_editable",
129 help=
"Include editable package from output.",
135 self.
parser.insert_option_group(0, index_opts)
139 self, options: Values, session: PipSession
142 Create a package finder appropriate to this list command.
153 link_collector=link_collector,
154 selection_prefs=selection_prefs,
157 def run(self, options: Values, args: List[str]) -> int:
159 raise CommandError(
"Options --outdated and --uptodate cannot be combined.")
163 "List format 'freeze' cannot be used with the --outdated option."
168 skip = set(stdlib_pkgs)
172 packages:
"_ProcessedDists" = [
173 cast(
"_DistWithLatestInfo", d)
174 for d
in get_environment(
options.path).iter_installed_distributions(
199 self, packages:
"_ProcessedDists", options: Values
200 ) ->
"_ProcessedDists":
208 self, packages:
"_ProcessedDists", options: Values
209 ) ->
"_ProcessedDists":
217 self, packages:
"_ProcessedDists", options: Values
218 ) ->
"_ProcessedDists":
231 self, packages:
"_ProcessedDists", options: Values
232 ) -> Generator[
"_DistWithLatestInfo",
None,
None]:
237 dist:
"_DistWithLatestInfo",
238 ) -> Optional[
"_DistWithLatestInfo"]:
244 for candidate
in all_candidates
252 if best_candidate
is None:
264 for dist
in map(latest_info, packages):
269 self, packages:
"_ProcessedDists", options: Values
279 for dist
in packages:
290 self, data: List[List[str]], header: List[str]
296 pkg_strings, sizes = tabulate(data)
302 for val
in pkg_strings:
307 pkgs:
"_ProcessedDists", options: Values
308) -> Tuple[List[List[str]], List[str]]:
310 Convert the package data into something usable
311 by output_package_listing_columns.
313 header = [
"Package",
"Version"]
353 for dist
in packages:
365 if editable_project_location:
366 info[
"editable_project_location"] = editable_project_location
PipSession _build_session(self, Values options, Optional[int] retries=None, Optional[int] timeout=None, bool fallback_to_certifi=False)
"_ProcessedDists" get_not_required(self, "_ProcessedDists" packages, Values options)
PackageFinder _build_package_finder(self, Values options, PipSession session)
"_ProcessedDists" get_outdated(self, "_ProcessedDists" packages, Values options)
"_ProcessedDists" get_uptodate(self, "_ProcessedDists" packages, Values options)
None output_package_listing_columns(self, List[List[str]] data, List[str] header)
None output_package_listing(self, "_ProcessedDists" packages, Values options)
Generator["_DistWithLatestInfo", None, None] iter_packages_latest_infos(self, "_ProcessedDists" packages, Values options)
int run(self, Values options, List[str] args)
str format_for_json("_ProcessedDists" packages, Values options)
Tuple[List[List[str]], List[str]] format_for_columns("_ProcessedDists" pkgs, Values options)