Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
freeze.py
Go to the documentation of this file.
1import sys
2from optparse import Values
3from typing import AbstractSet, List
4
5from pip._internal.cli import cmdoptions
6from pip._internal.cli.base_command import Command
7from pip._internal.cli.status_codes import SUCCESS
8from pip._internal.operations.freeze import freeze
9from pip._internal.utils.compat import stdlib_pkgs
10
11
13 return sys.version_info < (3, 12)
14
15
16def _dev_pkgs() -> AbstractSet[str]:
17 pkgs = {"pip"}
18
20 pkgs |= {"setuptools", "distribute", "wheel"}
21
22 return pkgs
23
24
26 """
27 Output installed packages in requirements format.
28
29 packages are listed in a case-insensitive sorted order.
30 """
31
32 usage = """
33 %prog [options]"""
34 log_streams = ("ext://sys.stderr", "ext://sys.stderr")
35
36 def add_options(self) -> None:
38 "-r",
39 "--requirement",
40 dest="requirements",
41 action="append",
42 default=[],
43 metavar="file",
44 help=(
45 "Use the order in the given requirements file and its "
46 "comments when generating output. This option can be "
47 "used multiple times."
48 ),
49 )
51 "-l",
52 "--local",
53 dest="local",
54 action="store_true",
55 default=False,
56 help=(
57 "If in a virtualenv that has global access, do not output "
58 "globally-installed packages."
59 ),
60 )
62 "--user",
63 dest="user",
64 action="store_true",
65 default=False,
66 help="Only output packages installed in user-site.",
67 )
70 "--all",
71 dest="freeze_all",
72 action="store_true",
73 help=(
74 "Do not skip these packages in the output:"
75 " {}".format(", ".join(_dev_pkgs()))
76 ),
77 )
79 "--exclude-editable",
80 dest="exclude_editable",
81 action="store_true",
82 help="Exclude editable package from output.",
83 )
85
86 self.parser.insert_option_group(0, self.cmd_optscmd_opts)
87
88 def run(self, options: Values, args: List[str]) -> int:
89 skip = set(stdlib_pkgs)
90 if not options.freeze_all:
92
95
97
98 for line in freeze(
99 requirement=options.requirements,
100 local_only=options.local,
101 user_only=options.user,
102 paths=options.path,
103 isolated=options.isolated_mode,
104 skip=skip,
105 exclude_editable=options.exclude_editable,
106 ):
107 sys.stdout.write(line + "\n")
108 return SUCCESS
int run(self, Values options, List[str] args)
Definition freeze.py:88
bool _should_suppress_build_backends()
Definition freeze.py:12
AbstractSet[str] _dev_pkgs()
Definition freeze.py:16
for i