Mercurial > repos > guerler > hhblits
comparison lib/python3.8/site-packages/pip/_internal/commands/freeze.py @ 0:9e54283cc701 draft
"planemo upload commit d12c32a45bcd441307e632fca6d9af7d60289d44"
author | guerler |
---|---|
date | Mon, 27 Jul 2020 03:47:31 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:9e54283cc701 |
---|---|
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 ' %s' % ', '.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 skip_regex=options.skip_requirements_regex, | |
93 isolated=options.isolated_mode, | |
94 wheel_cache=wheel_cache, | |
95 skip=skip, | |
96 exclude_editable=options.exclude_editable, | |
97 ) | |
98 | |
99 try: | |
100 for line in freeze(**freeze_kwargs): | |
101 sys.stdout.write(line + '\n') | |
102 finally: | |
103 wheel_cache.cleanup() |