comparison env/lib/python3.9/site-packages/pip/_internal/commands/freeze.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 import sys
2
3 from pip._internal.cli import cmdoptions
4 from pip._internal.cli.base_command import Command
5 from pip._internal.cli.status_codes import SUCCESS
6 from pip._internal.operations.freeze import freeze
7 from pip._internal.utils.compat import stdlib_pkgs
8 from pip._internal.utils.deprecation import deprecated
9 from pip._internal.utils.typing import MYPY_CHECK_RUNNING
10
11 DEV_PKGS = {'pip', 'setuptools', 'distribute', 'wheel'}
12
13 if MYPY_CHECK_RUNNING:
14 from optparse import Values
15 from typing import List
16
17
18 class FreezeCommand(Command):
19 """
20 Output installed packages in requirements format.
21
22 packages are listed in a case-insensitive sorted order.
23 """
24
25 usage = """
26 %prog [options]"""
27 log_streams = ("ext://sys.stderr", "ext://sys.stderr")
28
29 def add_options(self):
30 # type: () -> None
31 self.cmd_opts.add_option(
32 '-r', '--requirement',
33 dest='requirements',
34 action='append',
35 default=[],
36 metavar='file',
37 help="Use the order in the given requirements file and its "
38 "comments when generating output. This option can be "
39 "used multiple times.")
40 self.cmd_opts.add_option(
41 '-f', '--find-links',
42 dest='find_links',
43 action='append',
44 default=[],
45 metavar='URL',
46 help='URL for finding packages, which will be added to the '
47 'output.')
48 self.cmd_opts.add_option(
49 '-l', '--local',
50 dest='local',
51 action='store_true',
52 default=False,
53 help='If in a virtualenv that has global access, do not output '
54 'globally-installed packages.')
55 self.cmd_opts.add_option(
56 '--user',
57 dest='user',
58 action='store_true',
59 default=False,
60 help='Only output packages installed in user-site.')
61 self.cmd_opts.add_option(cmdoptions.list_path())
62 self.cmd_opts.add_option(
63 '--all',
64 dest='freeze_all',
65 action='store_true',
66 help='Do not skip these packages in the output:'
67 ' {}'.format(', '.join(DEV_PKGS)))
68 self.cmd_opts.add_option(
69 '--exclude-editable',
70 dest='exclude_editable',
71 action='store_true',
72 help='Exclude editable package from output.')
73 self.cmd_opts.add_option(cmdoptions.list_exclude())
74
75 self.parser.insert_option_group(0, self.cmd_opts)
76
77 def run(self, options, args):
78 # type: (Values, List[str]) -> int
79 skip = set(stdlib_pkgs)
80 if not options.freeze_all:
81 skip.update(DEV_PKGS)
82
83 if options.excludes:
84 skip.update(options.excludes)
85
86 cmdoptions.check_list_path_option(options)
87
88 if options.find_links:
89 deprecated(
90 "--find-links option in pip freeze is deprecated.",
91 replacement=None,
92 gone_in="21.2",
93 issue=9069,
94 )
95
96 for line in freeze(
97 requirement=options.requirements,
98 find_links=options.find_links,
99 local_only=options.local,
100 user_only=options.user,
101 paths=options.path,
102 isolated=options.isolated_mode,
103 skip=skip,
104 exclude_editable=options.exclude_editable,
105 ):
106 sys.stdout.write(line + '\n')
107 return SUCCESS