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