Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/pip/_internal/commands/freeze.py @ 1:56ad4e20f292 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
| author | guerler |
|---|---|
| date | Fri, 31 Jul 2020 00:32:28 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:d30785e31577 | 1:56ad4e20f292 |
|---|---|
| 1 from __future__ import absolute_import | |
| 2 | |
| 3 import sys | |
| 4 | |
| 5 from pip._internal.cache import WheelCache | |
| 6 from pip._internal.cli import cmdoptions | |
| 7 from pip._internal.cli.base_command import Command | |
| 8 from pip._internal.models.format_control import FormatControl | |
| 9 from pip._internal.operations.freeze import freeze | |
| 10 from pip._internal.utils.compat import stdlib_pkgs | |
| 11 | |
| 12 DEV_PKGS = {'pip', 'setuptools', 'distribute', 'wheel'} | |
| 13 | |
| 14 | |
| 15 class FreezeCommand(Command): | |
| 16 """ | |
| 17 Output installed packages in requirements format. | |
| 18 | |
| 19 packages are listed in a case-insensitive sorted order. | |
| 20 """ | |
| 21 name = 'freeze' | |
| 22 usage = """ | |
| 23 %prog [options]""" | |
| 24 summary = 'Output installed packages in requirements format.' | |
| 25 log_streams = ("ext://sys.stderr", "ext://sys.stderr") | |
| 26 | |
| 27 def __init__(self, *args, **kw): | |
| 28 super(FreezeCommand, self).__init__(*args, **kw) | |
| 29 | |
| 30 self.cmd_opts.add_option( | |
| 31 '-r', '--requirement', | |
| 32 dest='requirements', | |
| 33 action='append', | |
| 34 default=[], | |
| 35 metavar='file', | |
| 36 help="Use the order in the given requirements file and its " | |
| 37 "comments when generating output. This option can be " | |
| 38 "used multiple times.") | |
| 39 self.cmd_opts.add_option( | |
| 40 '-f', '--find-links', | |
| 41 dest='find_links', | |
| 42 action='append', | |
| 43 default=[], | |
| 44 metavar='URL', | |
| 45 help='URL for finding packages, which will be added to the ' | |
| 46 'output.') | |
| 47 self.cmd_opts.add_option( | |
| 48 '-l', '--local', | |
| 49 dest='local', | |
| 50 action='store_true', | |
| 51 default=False, | |
| 52 help='If in a virtualenv that has global access, do not output ' | |
| 53 'globally-installed packages.') | |
| 54 self.cmd_opts.add_option( | |
| 55 '--user', | |
| 56 dest='user', | |
| 57 action='store_true', | |
| 58 default=False, | |
| 59 help='Only output packages installed in user-site.') | |
| 60 self.cmd_opts.add_option(cmdoptions.list_path()) | |
| 61 self.cmd_opts.add_option( | |
| 62 '--all', | |
| 63 dest='freeze_all', | |
| 64 action='store_true', | |
| 65 help='Do not skip these packages in the output:' | |
| 66 ' %s' % ', '.join(DEV_PKGS)) | |
| 67 self.cmd_opts.add_option( | |
| 68 '--exclude-editable', | |
| 69 dest='exclude_editable', | |
| 70 action='store_true', | |
| 71 help='Exclude editable package from output.') | |
| 72 | |
| 73 self.parser.insert_option_group(0, self.cmd_opts) | |
| 74 | |
| 75 def run(self, options, args): | |
| 76 format_control = FormatControl(set(), set()) | |
| 77 wheel_cache = WheelCache(options.cache_dir, format_control) | |
| 78 skip = set(stdlib_pkgs) | |
| 79 if not options.freeze_all: | |
| 80 skip.update(DEV_PKGS) | |
| 81 | |
| 82 cmdoptions.check_list_path_option(options) | |
| 83 | |
| 84 freeze_kwargs = dict( | |
| 85 requirement=options.requirements, | |
| 86 find_links=options.find_links, | |
| 87 local_only=options.local, | |
| 88 user_only=options.user, | |
| 89 paths=options.path, | |
| 90 skip_regex=options.skip_requirements_regex, | |
| 91 isolated=options.isolated_mode, | |
| 92 wheel_cache=wheel_cache, | |
| 93 skip=skip, | |
| 94 exclude_editable=options.exclude_editable, | |
| 95 ) | |
| 96 | |
| 97 try: | |
| 98 for line in freeze(**freeze_kwargs): | |
| 99 sys.stdout.write(line + '\n') | |
| 100 finally: | |
| 101 wheel_cache.cleanup() |
