Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hhhrrrttt222111
GitHub Repository: hhhrrrttt222111/Dorkify
Path: blob/master/venv/Lib/site-packages/pip/_internal/commands/freeze.py
811 views
1
# The following comment should be removed at some point in the future.
2
# mypy: disallow-untyped-defs=False
3
4
from __future__ import absolute_import
5
6
import sys
7
8
from pip._internal.cache import WheelCache
9
from pip._internal.cli import cmdoptions
10
from pip._internal.cli.base_command import Command
11
from pip._internal.models.format_control import FormatControl
12
from pip._internal.operations.freeze import freeze
13
from pip._internal.utils.compat import stdlib_pkgs
14
15
DEV_PKGS = {'pip', 'setuptools', 'distribute', 'wheel'}
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 __init__(self, *args, **kw):
30
super(FreezeCommand, self).__init__(*args, **kw)
31
32
self.cmd_opts.add_option(
33
'-r', '--requirement',
34
dest='requirements',
35
action='append',
36
default=[],
37
metavar='file',
38
help="Use the order in the given requirements file and its "
39
"comments when generating output. This option can be "
40
"used multiple times.")
41
self.cmd_opts.add_option(
42
'-f', '--find-links',
43
dest='find_links',
44
action='append',
45
default=[],
46
metavar='URL',
47
help='URL for finding packages, which will be added to the '
48
'output.')
49
self.cmd_opts.add_option(
50
'-l', '--local',
51
dest='local',
52
action='store_true',
53
default=False,
54
help='If in a virtualenv that has global access, do not output '
55
'globally-installed packages.')
56
self.cmd_opts.add_option(
57
'--user',
58
dest='user',
59
action='store_true',
60
default=False,
61
help='Only output packages installed in user-site.')
62
self.cmd_opts.add_option(cmdoptions.list_path())
63
self.cmd_opts.add_option(
64
'--all',
65
dest='freeze_all',
66
action='store_true',
67
help='Do not skip these packages in the output:'
68
' {}'.format(', '.join(DEV_PKGS)))
69
self.cmd_opts.add_option(
70
'--exclude-editable',
71
dest='exclude_editable',
72
action='store_true',
73
help='Exclude editable package from output.')
74
75
self.parser.insert_option_group(0, self.cmd_opts)
76
77
def run(self, options, args):
78
format_control = FormatControl(set(), set())
79
wheel_cache = WheelCache(options.cache_dir, format_control)
80
skip = set(stdlib_pkgs)
81
if not options.freeze_all:
82
skip.update(DEV_PKGS)
83
84
cmdoptions.check_list_path_option(options)
85
86
freeze_kwargs = dict(
87
requirement=options.requirements,
88
find_links=options.find_links,
89
local_only=options.local,
90
user_only=options.user,
91
paths=options.path,
92
isolated=options.isolated_mode,
93
wheel_cache=wheel_cache,
94
skip=skip,
95
exclude_editable=options.exclude_editable,
96
)
97
98
for line in freeze(**freeze_kwargs):
99
sys.stdout.write(line + '\n')
100
101