summaryrefslogtreecommitdiff
path: root/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands
diff options
context:
space:
mode:
authorShubham Saini <shubham6405@gmail.com>2019-08-05 08:32:33 +0000
committerShubham Saini <shubham6405@gmail.com>2019-08-05 08:32:33 +0000
commit227b2d30a8675b44918f9d9ca89b24144a938215 (patch)
tree9f8e6a28724514b6fdf463a9ab2067a7ef309b72 /venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands
parent842a8cfbbbdb1f92889d892e4859dbd5d40c5be8 (diff)
removing venv files
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands')
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/__init__.py79
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/check.py42
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/completion.py94
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/configuration.py227
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/download.py233
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/freeze.py96
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/hash.py57
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/help.py36
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/install.py502
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/list.py343
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/search.py135
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/show.py164
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/uninstall.py71
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/wheel.py179
14 files changed, 0 insertions, 2258 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/__init__.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/__init__.py
deleted file mode 100644
index d44e6f1..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/__init__.py
+++ /dev/null
@@ -1,79 +0,0 @@
1"""
2Package containing all pip commands
3"""
4from __future__ import absolute_import
5
6from pip._internal.commands.completion import CompletionCommand
7from pip._internal.commands.configuration import ConfigurationCommand
8from pip._internal.commands.download import DownloadCommand
9from pip._internal.commands.freeze import FreezeCommand
10from pip._internal.commands.hash import HashCommand
11from pip._internal.commands.help import HelpCommand
12from pip._internal.commands.list import ListCommand
13from pip._internal.commands.check import CheckCommand
14from pip._internal.commands.search import SearchCommand
15from pip._internal.commands.show import ShowCommand
16from pip._internal.commands.install import InstallCommand
17from pip._internal.commands.uninstall import UninstallCommand
18from pip._internal.commands.wheel import WheelCommand
19
20from pip._internal.utils.typing import MYPY_CHECK_RUNNING
21
22if MYPY_CHECK_RUNNING:
23 from typing import List, Type
24 from pip._internal.basecommand import Command
25
26commands_order = [
27 InstallCommand,
28 DownloadCommand,
29 UninstallCommand,
30 FreezeCommand,
31 ListCommand,
32 ShowCommand,
33 CheckCommand,
34 ConfigurationCommand,
35 SearchCommand,
36 WheelCommand,
37 HashCommand,
38 CompletionCommand,
39 HelpCommand,
40] # type: List[Type[Command]]
41
42commands_dict = {c.name: c for c in commands_order}
43
44
45def get_summaries(ordered=True):
46 """Yields sorted (command name, command summary) tuples."""
47
48 if ordered:
49 cmditems = _sort_commands(commands_dict, commands_order)
50 else:
51 cmditems = commands_dict.items()
52
53 for name, command_class in cmditems:
54 yield (name, command_class.summary)
55
56
57def get_similar_commands(name):
58 """Command name auto-correct."""
59 from difflib import get_close_matches
60
61 name = name.lower()
62
63 close_commands = get_close_matches(name, commands_dict.keys())
64
65 if close_commands:
66 return close_commands[0]
67 else:
68 return False
69
70
71def _sort_commands(cmddict, order):
72 def keyfn(key):
73 try:
74 return order.index(key[1])
75 except ValueError:
76 # unordered items should come last
77 return 0xff
78
79 return sorted(cmddict.items(), key=keyfn)
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/check.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/check.py
deleted file mode 100644
index b1bf38a..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/check.py
+++ /dev/null
@@ -1,42 +0,0 @@
1import logging
2
3from pip._internal.basecommand import Command
4from pip._internal.operations.check import (
5 check_package_set, create_package_set_from_installed,
6)
7from pip._internal.utils.misc import get_installed_distributions
8
9logger = logging.getLogger(__name__)
10
11
12class CheckCommand(Command):
13 """Verify installed packages have compatible dependencies."""
14 name = 'check'
15 usage = """
16 %prog [options]"""
17 summary = 'Verify installed packages have compatible dependencies.'
18
19 def run(self, options, args):
20 package_set = create_package_set_from_installed()
21 missing, conflicting = check_package_set(package_set)
22
23 for project_name in missing:
24 version = package_set[project_name].version
25 for dependency in missing[project_name]:
26 logger.info(
27 "%s %s requires %s, which is not installed.",
28 project_name, version, dependency[0],
29 )
30
31 for project_name in conflicting:
32 version = package_set[project_name].version
33 for dep_name, dep_version, req in conflicting[project_name]:
34 logger.info(
35 "%s %s has requirement %s, but you have %s %s.",
36 project_name, version, req, dep_name, dep_version,
37 )
38
39 if missing or conflicting:
40 return 1
41 else:
42 logger.info("No broken requirements found.")
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/completion.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/completion.py
deleted file mode 100644
index 8da1e83..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/completion.py
+++ /dev/null
@@ -1,94 +0,0 @@
1from __future__ import absolute_import
2
3import sys
4import textwrap
5
6from pip._internal.basecommand import Command
7from pip._internal.utils.misc import get_prog
8
9BASE_COMPLETION = """
10# pip %(shell)s completion start%(script)s# pip %(shell)s completion end
11"""
12
13COMPLETION_SCRIPTS = {
14 'bash': """
15 _pip_completion()
16 {
17 COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \\
18 COMP_CWORD=$COMP_CWORD \\
19 PIP_AUTO_COMPLETE=1 $1 ) )
20 }
21 complete -o default -F _pip_completion %(prog)s
22 """,
23 'zsh': """
24 function _pip_completion {
25 local words cword
26 read -Ac words
27 read -cn cword
28 reply=( $( COMP_WORDS="$words[*]" \\
29 COMP_CWORD=$(( cword-1 )) \\
30 PIP_AUTO_COMPLETE=1 $words[1] ) )
31 }
32 compctl -K _pip_completion %(prog)s
33 """,
34 'fish': """
35 function __fish_complete_pip
36 set -lx COMP_WORDS (commandline -o) ""
37 set -lx COMP_CWORD ( \\
38 math (contains -i -- (commandline -t) $COMP_WORDS)-1 \\
39 )
40 set -lx PIP_AUTO_COMPLETE 1
41 string split \\ -- (eval $COMP_WORDS[1])
42 end
43 complete -fa "(__fish_complete_pip)" -c %(prog)s
44 """,
45}
46
47
48class CompletionCommand(Command):
49 """A helper command to be used for command completion."""
50 name = 'completion'
51 summary = 'A helper command used for command completion.'
52 ignore_require_venv = True
53
54 def __init__(self, *args, **kw):
55 super(CompletionCommand, self).__init__(*args, **kw)
56
57 cmd_opts = self.cmd_opts
58
59 cmd_opts.add_option(
60 '--bash', '-b',
61 action='store_const',
62 const='bash',
63 dest='shell',
64 help='Emit completion code for bash')
65 cmd_opts.add_option(
66 '--zsh', '-z',
67 action='store_const',
68 const='zsh',
69 dest='shell',
70 help='Emit completion code for zsh')
71 cmd_opts.add_option(
72 '--fish', '-f',
73 action='store_const',
74 const='fish',
75 dest='shell',
76 help='Emit completion code for fish')
77
78 self.parser.insert_option_group(0, cmd_opts)
79
80 def run(self, options, args):
81 """Prints the completion code of the given shell"""
82 shells = COMPLETION_SCRIPTS.keys()
83 shell_options = ['--' + shell for shell in sorted(shells)]
84 if options.shell in shells:
85 script = textwrap.dedent(
86 COMPLETION_SCRIPTS.get(options.shell, '') % {
87 'prog': get_prog(),
88 }
89 )
90 print(BASE_COMPLETION % {'script': script, 'shell': options.shell})
91 else:
92 sys.stderr.write(
93 'ERROR: You must pass %s\n' % ' or '.join(shell_options)
94 )
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/configuration.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/configuration.py
deleted file mode 100644
index e10d9a9..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/configuration.py
+++ /dev/null
@@ -1,227 +0,0 @@
1import logging
2import os
3import subprocess
4
5from pip._internal.basecommand import Command
6from pip._internal.configuration import Configuration, kinds
7from pip._internal.exceptions import PipError
8from pip._internal.locations import venv_config_file
9from pip._internal.status_codes import ERROR, SUCCESS
10from pip._internal.utils.misc import get_prog
11
12logger = logging.getLogger(__name__)
13
14
15class ConfigurationCommand(Command):
16 """Manage local and global configuration.
17
18 Subcommands:
19
20 list: List the active configuration (or from the file specified)
21 edit: Edit the configuration file in an editor
22 get: Get the value associated with name
23 set: Set the name=value
24 unset: Unset the value associated with name
25
26 If none of --user, --global and --venv are passed, a virtual
27 environment configuration file is used if one is active and the file
28 exists. Otherwise, all modifications happen on the to the user file by
29 default.
30 """
31
32 name = 'config'
33 usage = """
34 %prog [<file-option>] list
35 %prog [<file-option>] [--editor <editor-path>] edit
36
37 %prog [<file-option>] get name
38 %prog [<file-option>] set name value
39 %prog [<file-option>] unset name
40 """
41
42 summary = "Manage local and global configuration."
43
44 def __init__(self, *args, **kwargs):
45 super(ConfigurationCommand, self).__init__(*args, **kwargs)
46
47 self.configuration = None
48
49 self.cmd_opts.add_option(
50 '--editor',
51 dest='editor',
52 action='store',
53 default=None,
54 help=(
55 'Editor to use to edit the file. Uses VISUAL or EDITOR '
56 'environment variables if not provided.'
57 )
58 )
59
60 self.cmd_opts.add_option(
61 '--global',
62 dest='global_file',
63 action='store_true',
64 default=False,
65 help='Use the system-wide configuration file only'
66 )
67
68 self.cmd_opts.add_option(
69 '--user',
70 dest='user_file',
71 action='store_true',
72 default=False,
73 help='Use the user configuration file only'
74 )
75
76 self.cmd_opts.add_option(
77 '--venv',
78 dest='venv_file',
79 action='store_true',
80 default=False,
81 help='Use the virtualenv configuration file only'
82 )
83
84 self.parser.insert_option_group(0, self.cmd_opts)
85
86 def run(self, options, args):
87 handlers = {
88 "list": self.list_values,
89 "edit": self.open_in_editor,
90 "get": self.get_name,
91 "set": self.set_name_value,
92 "unset": self.unset_name
93 }
94
95 # Determine action
96 if not args or args[0] not in handlers:
97 logger.error("Need an action ({}) to perform.".format(
98 ", ".join(sorted(handlers)))
99 )
100 return ERROR
101
102 action = args[0]
103
104 # Determine which configuration files are to be loaded
105 # Depends on whether the command is modifying.
106 try:
107 load_only = self._determine_file(
108 options, need_value=(action in ["get", "set", "unset", "edit"])
109 )
110 except PipError as e:
111 logger.error(e.args[0])
112 return ERROR
113
114 # Load a new configuration
115 self.configuration = Configuration(
116 isolated=options.isolated_mode, load_only=load_only
117 )
118 self.configuration.load()
119
120 # Error handling happens here, not in the action-handlers.
121 try:
122 handlers[action](options, args[1:])
123 except PipError as e:
124 logger.error(e.args[0])
125 return ERROR
126
127 return SUCCESS
128
129 def _determine_file(self, options, need_value):
130 file_options = {
131 kinds.USER: options.user_file,
132 kinds.GLOBAL: options.global_file,
133 kinds.VENV: options.venv_file
134 }
135
136 if sum(file_options.values()) == 0:
137 if not need_value:
138 return None
139 # Default to user, unless there's a virtualenv file.
140 elif os.path.exists(venv_config_file):
141 return kinds.VENV
142 else:
143 return kinds.USER
144 elif sum(file_options.values()) == 1:
145 # There's probably a better expression for this.
146 return [key for key in file_options if file_options[key]][0]
147
148 raise PipError(
149 "Need exactly one file to operate upon "
150 "(--user, --venv, --global) to perform."
151 )
152
153 def list_values(self, options, args):
154 self._get_n_args(args, "list", n=0)
155
156 for key, value in sorted(self.configuration.items()):
157 logger.info("%s=%r", key, value)
158
159 def get_name(self, options, args):
160 key = self._get_n_args(args, "get [name]", n=1)
161 value = self.configuration.get_value(key)
162
163 logger.info("%s", value)
164
165 def set_name_value(self, options, args):
166 key, value = self._get_n_args(args, "set [name] [value]", n=2)
167 self.configuration.set_value(key, value)
168
169 self._save_configuration()
170
171 def unset_name(self, options, args):
172 key = self._get_n_args(args, "unset [name]", n=1)
173 self.configuration.unset_value(key)
174
175 self._save_configuration()
176
177 def open_in_editor(self, options, args):
178 editor = self._determine_editor(options)
179
180 fname = self.configuration.get_file_to_edit()
181 if fname is None:
182 raise PipError("Could not determine appropriate file.")
183
184 try:
185 subprocess.check_call([editor, fname])
186 except subprocess.CalledProcessError as e:
187 raise PipError(
188 "Editor Subprocess exited with exit code {}"
189 .format(e.returncode)
190 )
191
192 def _get_n_args(self, args, example, n):
193 """Helper to make sure the command got the right number of arguments
194 """
195 if len(args) != n:
196 msg = (
197 'Got unexpected number of arguments, expected {}. '
198 '(example: "{} config {}")'
199 ).format(n, get_prog(), example)
200 raise PipError(msg)
201
202 if n == 1:
203 return args[0]
204 else:
205 return args
206
207 def _save_configuration(self):
208 # We successfully ran a modifying command. Need to save the
209 # configuration.
210 try:
211 self.configuration.save()
212 except Exception:
213 logger.error(
214 "Unable to save configuration. Please report this as a bug.",
215 exc_info=1
216 )
217 raise PipError("Internal Error.")
218
219 def _determine_editor(self, options):
220 if options.editor is not None:
221 return options.editor
222 elif "VISUAL" in os.environ:
223 return os.environ["VISUAL"]
224 elif "EDITOR" in os.environ:
225 return os.environ["EDITOR"]
226 else:
227 raise PipError("Could not determine editor to use.")
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/download.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/download.py
deleted file mode 100644
index 916a470..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/download.py
+++ /dev/null
@@ -1,233 +0,0 @@
1from __future__ import absolute_import
2
3import logging
4import os
5
6from pip._internal import cmdoptions
7from pip._internal.basecommand import RequirementCommand
8from pip._internal.exceptions import CommandError
9from pip._internal.index import FormatControl
10from pip._internal.operations.prepare import RequirementPreparer
11from pip._internal.req import RequirementSet
12from pip._internal.resolve import Resolver
13from pip._internal.utils.filesystem import check_path_owner
14from pip._internal.utils.misc import ensure_dir, normalize_path
15from pip._internal.utils.temp_dir import TempDirectory
16
17logger = logging.getLogger(__name__)
18
19
20class DownloadCommand(RequirementCommand):
21 """
22 Download packages from:
23
24 - PyPI (and other indexes) using requirement specifiers.
25 - VCS project urls.
26 - Local project directories.
27 - Local or remote source archives.
28
29 pip also supports downloading from "requirements files", which provide
30 an easy way to specify a whole environment to be downloaded.
31 """
32 name = 'download'
33
34 usage = """
35 %prog [options] <requirement specifier> [package-index-options] ...
36 %prog [options] -r <requirements file> [package-index-options] ...
37 %prog [options] <vcs project url> ...
38 %prog [options] <local project path> ...
39 %prog [options] <archive url/path> ..."""
40
41 summary = 'Download packages.'
42
43 def __init__(self, *args, **kw):
44 super(DownloadCommand, self).__init__(*args, **kw)
45
46 cmd_opts = self.cmd_opts
47
48 cmd_opts.add_option(cmdoptions.constraints())
49 cmd_opts.add_option(cmdoptions.requirements())
50 cmd_opts.add_option(cmdoptions.build_dir())
51 cmd_opts.add_option(cmdoptions.no_deps())
52 cmd_opts.add_option(cmdoptions.global_options())
53 cmd_opts.add_option(cmdoptions.no_binary())
54 cmd_opts.add_option(cmdoptions.only_binary())
55 cmd_opts.add_option(cmdoptions.src())
56 cmd_opts.add_option(cmdoptions.pre())
57 cmd_opts.add_option(cmdoptions.no_clean())
58 cmd_opts.add_option(cmdoptions.require_hashes())
59 cmd_opts.add_option(cmdoptions.progress_bar())
60 cmd_opts.add_option(cmdoptions.no_build_isolation())
61
62 cmd_opts.add_option(
63 '-d', '--dest', '--destination-dir', '--destination-directory',
64 dest='download_dir',
65 metavar='dir',
66 default=os.curdir,
67 help=("Download packages into <dir>."),
68 )
69
70 cmd_opts.add_option(
71 '--platform',
72 dest='platform',
73 metavar='platform',
74 default=None,
75 help=("Only download wheels compatible with <platform>. "
76 "Defaults to the platform of the running system."),
77 )
78
79 cmd_opts.add_option(
80 '--python-version',
81 dest='python_version',
82 metavar='python_version',
83 default=None,
84 help=("Only download wheels compatible with Python "
85 "interpreter version <version>. If not specified, then the "
86 "current system interpreter minor version is used. A major "
87 "version (e.g. '2') can be specified to match all "
88 "minor revs of that major version. A minor version "
89 "(e.g. '34') can also be specified."),
90 )
91
92 cmd_opts.add_option(
93 '--implementation',
94 dest='implementation',
95 metavar='implementation',
96 default=None,
97 help=("Only download wheels compatible with Python "
98 "implementation <implementation>, e.g. 'pp', 'jy', 'cp', "
99 " or 'ip'. If not specified, then the current "
100 "interpreter implementation is used. Use 'py' to force "
101 "implementation-agnostic wheels."),
102 )
103
104 cmd_opts.add_option(
105 '--abi',
106 dest='abi',
107 metavar='abi',
108 default=None,
109 help=("Only download wheels compatible with Python "
110 "abi <abi>, e.g. 'pypy_41'. If not specified, then the "
111 "current interpreter abi tag is used. Generally "
112 "you will need to specify --implementation, "
113 "--platform, and --python-version when using "
114 "this option."),
115 )
116
117 index_opts = cmdoptions.make_option_group(
118 cmdoptions.index_group,
119 self.parser,
120 )
121
122 self.parser.insert_option_group(0, index_opts)
123 self.parser.insert_option_group(0, cmd_opts)
124
125 def run(self, options, args):
126 options.ignore_installed = True
127 # editable doesn't really make sense for `pip download`, but the bowels
128 # of the RequirementSet code require that property.
129 options.editables = []
130
131 if options.python_version:
132 python_versions = [options.python_version]
133 else:
134 python_versions = None
135
136 dist_restriction_set = any([
137 options.python_version,
138 options.platform,
139 options.abi,
140 options.implementation,
141 ])
142 binary_only = FormatControl(set(), {':all:'})
143 no_sdist_dependencies = (
144 options.format_control != binary_only and
145 not options.ignore_dependencies
146 )
147 if dist_restriction_set and no_sdist_dependencies:
148 raise CommandError(
149 "When restricting platform and interpreter constraints using "
150 "--python-version, --platform, --abi, or --implementation, "
151 "either --no-deps must be set, or --only-binary=:all: must be "
152 "set and --no-binary must not be set (or must be set to "
153 ":none:)."
154 )
155
156 options.src_dir = os.path.abspath(options.src_dir)
157 options.download_dir = normalize_path(options.download_dir)
158
159 ensure_dir(options.download_dir)
160
161 with self._build_session(options) as session:
162 finder = self._build_package_finder(
163 options=options,
164 session=session,
165 platform=options.platform,
166 python_versions=python_versions,
167 abi=options.abi,
168 implementation=options.implementation,
169 )
170 build_delete = (not (options.no_clean or options.build_dir))
171 if options.cache_dir and not check_path_owner(options.cache_dir):
172 logger.warning(
173 "The directory '%s' or its parent directory is not owned "
174 "by the current user and caching wheels has been "
175 "disabled. check the permissions and owner of that "
176 "directory. If executing pip with sudo, you may want "
177 "sudo's -H flag.",
178 options.cache_dir,
179 )
180 options.cache_dir = None
181
182 with TempDirectory(
183 options.build_dir, delete=build_delete, kind="download"
184 ) as directory:
185
186 requirement_set = RequirementSet(
187 require_hashes=options.require_hashes,
188 )
189 self.populate_requirement_set(
190 requirement_set,
191 args,
192 options,
193 finder,
194 session,
195 self.name,
196 None
197 )
198
199 preparer = RequirementPreparer(
200 build_dir=directory.path,
201 src_dir=options.src_dir,
202 download_dir=options.download_dir,
203 wheel_download_dir=None,
204 progress_bar=options.progress_bar,
205 build_isolation=options.build_isolation,
206 )
207
208 resolver = Resolver(
209 preparer=preparer,
210 finder=finder,
211 session=session,
212 wheel_cache=None,
213 use_user_site=False,
214 upgrade_strategy="to-satisfy-only",
215 force_reinstall=False,
216 ignore_dependencies=options.ignore_dependencies,
217 ignore_requires_python=False,
218 ignore_installed=True,
219 isolated=options.isolated_mode,
220 )
221 resolver.resolve(requirement_set)
222
223 downloaded = ' '.join([
224 req.name for req in requirement_set.successfully_downloaded
225 ])
226 if downloaded:
227 logger.info('Successfully downloaded %s', downloaded)
228
229 # Clean up
230 if not options.no_clean:
231 requirement_set.cleanup_files()
232
233 return requirement_set
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
deleted file mode 100644
index ac562d7..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/freeze.py
+++ /dev/null
@@ -1,96 +0,0 @@
1from __future__ import absolute_import
2
3import sys
4
5from pip._internal import index
6from pip._internal.basecommand import Command
7from pip._internal.cache import WheelCache
8from pip._internal.compat import stdlib_pkgs
9from pip._internal.operations.freeze import freeze
10
11DEV_PKGS = {'pip', 'setuptools', 'distribute', 'wheel'}
12
13
14class 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()
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/hash.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/hash.py
deleted file mode 100644
index 0ce1419..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/hash.py
+++ /dev/null
@@ -1,57 +0,0 @@
1from __future__ import absolute_import
2
3import hashlib
4import logging
5import sys
6
7from pip._internal.basecommand import Command
8from pip._internal.status_codes import ERROR
9from pip._internal.utils.hashes import FAVORITE_HASH, STRONG_HASHES
10from pip._internal.utils.misc import read_chunks
11
12logger = logging.getLogger(__name__)
13
14
15class HashCommand(Command):
16 """
17 Compute a hash of a local package archive.
18
19 These can be used with --hash in a requirements file to do repeatable
20 installs.
21
22 """
23 name = 'hash'
24 usage = '%prog [options] <file> ...'
25 summary = 'Compute hashes of package archives.'
26 ignore_require_venv = True
27
28 def __init__(self, *args, **kw):
29 super(HashCommand, self).__init__(*args, **kw)
30 self.cmd_opts.add_option(
31 '-a', '--algorithm',
32 dest='algorithm',
33 choices=STRONG_HASHES,
34 action='store',
35 default=FAVORITE_HASH,
36 help='The hash algorithm to use: one of %s' %
37 ', '.join(STRONG_HASHES))
38 self.parser.insert_option_group(0, self.cmd_opts)
39
40 def run(self, options, args):
41 if not args:
42 self.parser.print_usage(sys.stderr)
43 return ERROR
44
45 algorithm = options.algorithm
46 for path in args:
47 logger.info('%s:\n--hash=%s:%s',
48 path, algorithm, _hash_of_file(path, algorithm))
49
50
51def _hash_of_file(path, algorithm):
52 """Return the hash digest of a file."""
53 with open(path, 'rb') as archive:
54 hash = hashlib.new(algorithm)
55 for chunk in read_chunks(archive):
56 hash.update(chunk)
57 return hash.hexdigest()
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/help.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/help.py
deleted file mode 100644
index f4a0e40..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/help.py
+++ /dev/null
@@ -1,36 +0,0 @@
1from __future__ import absolute_import
2
3from pip._internal.basecommand import SUCCESS, Command
4from pip._internal.exceptions import CommandError
5
6
7class HelpCommand(Command):
8 """Show help for commands"""
9 name = 'help'
10 usage = """
11 %prog <command>"""
12 summary = 'Show help for commands.'
13 ignore_require_venv = True
14
15 def run(self, options, args):
16 from pip._internal.commands import commands_dict, get_similar_commands
17
18 try:
19 # 'pip help' with no args is handled by pip.__init__.parseopt()
20 cmd_name = args[0] # the command we need help for
21 except IndexError:
22 return SUCCESS
23
24 if cmd_name not in commands_dict:
25 guess = get_similar_commands(cmd_name)
26
27 msg = ['unknown command "%s"' % cmd_name]
28 if guess:
29 msg.append('maybe you meant "%s"' % guess)
30
31 raise CommandError(' - '.join(msg))
32
33 command = commands_dict[cmd_name]()
34 command.parser.print_help()
35
36 return SUCCESS
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/install.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/install.py
deleted file mode 100644
index 057a64e..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/install.py
+++ /dev/null
@@ -1,502 +0,0 @@
1from __future__ import absolute_import
2
3import errno
4import logging
5import operator
6import os
7import shutil
8from optparse import SUPPRESS_HELP
9
10from pip._internal import cmdoptions
11from pip._internal.basecommand import RequirementCommand
12from pip._internal.cache import WheelCache
13from pip._internal.exceptions import (
14 CommandError, InstallationError, PreviousBuildDirError,
15)
16from pip._internal.locations import distutils_scheme, virtualenv_no_global
17from pip._internal.operations.check import check_install_conflicts
18from pip._internal.operations.prepare import RequirementPreparer
19from pip._internal.req import RequirementSet, install_given_reqs
20from pip._internal.resolve import Resolver
21from pip._internal.status_codes import ERROR
22from pip._internal.utils.filesystem import check_path_owner
23from pip._internal.utils.misc import ensure_dir, get_installed_version
24from pip._internal.utils.temp_dir import TempDirectory
25from pip._internal.wheel import WheelBuilder
26
27try:
28 import wheel
29except ImportError:
30 wheel = None
31
32
33logger = logging.getLogger(__name__)
34
35
36class InstallCommand(RequirementCommand):
37 """
38 Install packages from:
39
40 - PyPI (and other indexes) using requirement specifiers.
41 - VCS project urls.
42 - Local project directories.
43 - Local or remote source archives.
44
45 pip also supports installing from "requirements files", which provide
46 an easy way to specify a whole environment to be installed.
47 """
48 name = 'install'
49
50 usage = """
51 %prog [options] <requirement specifier> [package-index-options] ...
52 %prog [options] -r <requirements file> [package-index-options] ...
53 %prog [options] [-e] <vcs project url> ...
54 %prog [options] [-e] <local project path> ...
55 %prog [options] <archive url/path> ..."""
56
57 summary = 'Install packages.'
58
59 def __init__(self, *args, **kw):
60 super(InstallCommand, self).__init__(*args, **kw)
61
62 cmd_opts = self.cmd_opts
63
64 cmd_opts.add_option(cmdoptions.requirements())
65 cmd_opts.add_option(cmdoptions.constraints())
66 cmd_opts.add_option(cmdoptions.no_deps())
67 cmd_opts.add_option(cmdoptions.pre())
68
69 cmd_opts.add_option(cmdoptions.editable())
70 cmd_opts.add_option(
71 '-t', '--target',
72 dest='target_dir',
73 metavar='dir',
74 default=None,
75 help='Install packages into <dir>. '
76 'By default this will not replace existing files/folders in '
77 '<dir>. Use --upgrade to replace existing packages in <dir> '
78 'with new versions.'
79 )
80 cmd_opts.add_option(
81 '--user',
82 dest='use_user_site',
83 action='store_true',
84 help="Install to the Python user install directory for your "
85 "platform. Typically ~/.local/, or %APPDATA%\\Python on "
86 "Windows. (See the Python documentation for site.USER_BASE "
87 "for full details.)")
88 cmd_opts.add_option(
89 '--no-user',
90 dest='use_user_site',
91 action='store_false',
92 help=SUPPRESS_HELP)
93 cmd_opts.add_option(
94 '--root',
95 dest='root_path',
96 metavar='dir',
97 default=None,
98 help="Install everything relative to this alternate root "
99 "directory.")
100 cmd_opts.add_option(
101 '--prefix',
102 dest='prefix_path',
103 metavar='dir',
104 default=None,
105 help="Installation prefix where lib, bin and other top-level "
106 "folders are placed")
107
108 cmd_opts.add_option(cmdoptions.build_dir())
109
110 cmd_opts.add_option(cmdoptions.src())
111
112 cmd_opts.add_option(
113 '-U', '--upgrade',
114 dest='upgrade',
115 action='store_true',
116 help='Upgrade all specified packages to the newest available '
117 'version. The handling of dependencies depends on the '
118 'upgrade-strategy used.'
119 )
120
121 cmd_opts.add_option(
122 '--upgrade-strategy',
123 dest='upgrade_strategy',
124 default='only-if-needed',
125 choices=['only-if-needed', 'eager'],
126 help='Determines how dependency upgrading should be handled '
127 '[default: %default]. '
128 '"eager" - dependencies are upgraded regardless of '
129 'whether the currently installed version satisfies the '
130 'requirements of the upgraded package(s). '
131 '"only-if-needed" - are upgraded only when they do not '
132 'satisfy the requirements of the upgraded package(s).'
133 )
134
135 cmd_opts.add_option(
136 '--force-reinstall',
137 dest='force_reinstall',
138 action='store_true',
139 help='Reinstall all packages even if they are already '
140 'up-to-date.')
141
142 cmd_opts.add_option(
143 '-I', '--ignore-installed',
144 dest='ignore_installed',
145 action='store_true',
146 help='Ignore the installed packages (reinstalling instead).')
147
148 cmd_opts.add_option(cmdoptions.ignore_requires_python())
149 cmd_opts.add_option(cmdoptions.no_build_isolation())
150
151 cmd_opts.add_option(cmdoptions.install_options())
152 cmd_opts.add_option(cmdoptions.global_options())
153
154 cmd_opts.add_option(
155 "--compile",
156 action="store_true",
157 dest="compile",
158 default=True,
159 help="Compile Python source files to bytecode",
160 )
161
162 cmd_opts.add_option(
163 "--no-compile",
164 action="store_false",
165 dest="compile",
166 help="Do not compile Python source files to bytecode",
167 )
168
169 cmd_opts.add_option(
170 "--no-warn-script-location",
171 action="store_false",
172 dest="warn_script_location",
173 default=True,
174 help="Do not warn when installing scripts outside PATH",
175 )
176 cmd_opts.add_option(
177 "--no-warn-conflicts",
178 action="store_false",
179 dest="warn_about_conflicts",
180 default=True,
181 help="Do not warn about broken dependencies",
182 )
183
184 cmd_opts.add_option(cmdoptions.no_binary())
185 cmd_opts.add_option(cmdoptions.only_binary())
186 cmd_opts.add_option(cmdoptions.no_clean())
187 cmd_opts.add_option(cmdoptions.require_hashes())
188 cmd_opts.add_option(cmdoptions.progress_bar())
189
190 index_opts = cmdoptions.make_option_group(
191 cmdoptions.index_group,
192 self.parser,
193 )
194
195 self.parser.insert_option_group(0, index_opts)
196 self.parser.insert_option_group(0, cmd_opts)
197
198 def run(self, options, args):
199 cmdoptions.check_install_build_global(options)
200
201 upgrade_strategy = "to-satisfy-only"
202 if options.upgrade:
203 upgrade_strategy = options.upgrade_strategy
204
205 if options.build_dir:
206 options.build_dir = os.path.abspath(options.build_dir)
207
208 options.src_dir = os.path.abspath(options.src_dir)
209 install_options = options.install_options or []
210 if options.use_user_site:
211 if options.prefix_path:
212 raise CommandError(
213 "Can not combine '--user' and '--prefix' as they imply "
214 "different installation locations"
215 )
216 if virtualenv_no_global():
217 raise InstallationError(
218 "Can not perform a '--user' install. User site-packages "
219 "are not visible in this virtualenv."
220 )
221 install_options.append('--user')
222 install_options.append('--prefix=')
223
224 target_temp_dir = TempDirectory(kind="target")
225 if options.target_dir:
226 options.ignore_installed = True
227 options.target_dir = os.path.abspath(options.target_dir)
228 if (os.path.exists(options.target_dir) and not
229 os.path.isdir(options.target_dir)):
230 raise CommandError(
231 "Target path exists but is not a directory, will not "
232 "continue."
233 )
234
235 # Create a target directory for using with the target option
236 target_temp_dir.create()
237 install_options.append('--home=' + target_temp_dir.path)
238
239 global_options = options.global_options or []
240
241 with self._build_session(options) as session:
242 finder = self._build_package_finder(options, session)
243 build_delete = (not (options.no_clean or options.build_dir))
244 wheel_cache = WheelCache(options.cache_dir, options.format_control)
245
246 if options.cache_dir and not check_path_owner(options.cache_dir):
247 logger.warning(
248 "The directory '%s' or its parent directory is not owned "
249 "by the current user and caching wheels has been "
250 "disabled. check the permissions and owner of that "
251 "directory. If executing pip with sudo, you may want "
252 "sudo's -H flag.",
253 options.cache_dir,
254 )
255 options.cache_dir = None
256
257 with TempDirectory(
258 options.build_dir, delete=build_delete, kind="install"
259 ) as directory:
260 requirement_set = RequirementSet(
261 require_hashes=options.require_hashes,
262 )
263
264 try:
265 self.populate_requirement_set(
266 requirement_set, args, options, finder, session,
267 self.name, wheel_cache
268 )
269 preparer = RequirementPreparer(
270 build_dir=directory.path,
271 src_dir=options.src_dir,
272 download_dir=None,
273 wheel_download_dir=None,
274 progress_bar=options.progress_bar,
275 build_isolation=options.build_isolation,
276 )
277
278 resolver = Resolver(
279 preparer=preparer,
280 finder=finder,
281 session=session,
282 wheel_cache=wheel_cache,
283 use_user_site=options.use_user_site,
284 upgrade_strategy=upgrade_strategy,
285 force_reinstall=options.force_reinstall,
286 ignore_dependencies=options.ignore_dependencies,
287 ignore_requires_python=options.ignore_requires_python,
288 ignore_installed=options.ignore_installed,
289 isolated=options.isolated_mode,
290 )
291 resolver.resolve(requirement_set)
292
293 # If caching is disabled or wheel is not installed don't
294 # try to build wheels.
295 if wheel and options.cache_dir:
296 # build wheels before install.
297 wb = WheelBuilder(
298 finder, preparer, wheel_cache,
299 build_options=[], global_options=[],
300 )
301 # Ignore the result: a failed wheel will be
302 # installed from the sdist/vcs whatever.
303 wb.build(
304 requirement_set.requirements.values(),
305 session=session, autobuilding=True
306 )
307
308 to_install = resolver.get_installation_order(
309 requirement_set
310 )
311
312 # Consistency Checking of the package set we're installing.
313 should_warn_about_conflicts = (
314 not options.ignore_dependencies and
315 options.warn_about_conflicts
316 )
317 if should_warn_about_conflicts:
318 self._warn_about_conflicts(to_install)
319
320 # Don't warn about script install locations if
321 # --target has been specified
322 warn_script_location = options.warn_script_location
323 if options.target_dir:
324 warn_script_location = False
325
326 installed = install_given_reqs(
327 to_install,
328 install_options,
329 global_options,
330 root=options.root_path,
331 home=target_temp_dir.path,
332 prefix=options.prefix_path,
333 pycompile=options.compile,
334 warn_script_location=warn_script_location,
335 use_user_site=options.use_user_site,
336 )
337
338 possible_lib_locations = get_lib_location_guesses(
339 user=options.use_user_site,
340 home=target_temp_dir.path,
341 root=options.root_path,
342 prefix=options.prefix_path,
343 isolated=options.isolated_mode,
344 )
345 reqs = sorted(installed, key=operator.attrgetter('name'))
346 items = []
347 for req in reqs:
348 item = req.name
349 try:
350 installed_version = get_installed_version(
351 req.name, possible_lib_locations
352 )
353 if installed_version:
354 item += '-' + installed_version
355 except Exception:
356 pass
357 items.append(item)
358 installed = ' '.join(items)
359 if installed:
360 logger.info('Successfully installed %s', installed)
361 except EnvironmentError as error:
362 show_traceback = (self.verbosity >= 1)
363
364 message = create_env_error_message(
365 error, show_traceback, options.use_user_site,
366 )
367 logger.error(message, exc_info=show_traceback)
368
369 return ERROR
370 except PreviousBuildDirError:
371 options.no_clean = True
372 raise
373 finally:
374 # Clean up
375 if not options.no_clean:
376 requirement_set.cleanup_files()
377 wheel_cache.cleanup()
378
379 if options.target_dir:
380 self._handle_target_dir(
381 options.target_dir, target_temp_dir, options.upgrade
382 )
383 return requirement_set
384
385 def _handle_target_dir(self, target_dir, target_temp_dir, upgrade):
386 ensure_dir(target_dir)
387
388 # Checking both purelib and platlib directories for installed
389 # packages to be moved to target directory
390 lib_dir_list = []
391
392 with target_temp_dir:
393 # Checking both purelib and platlib directories for installed
394 # packages to be moved to target directory
395 scheme = distutils_scheme('', home=target_temp_dir.path)
396 purelib_dir = scheme['purelib']
397 platlib_dir = scheme['platlib']
398 data_dir = scheme['data']
399
400 if os.path.exists(purelib_dir):
401 lib_dir_list.append(purelib_dir)
402 if os.path.exists(platlib_dir) and platlib_dir != purelib_dir:
403 lib_dir_list.append(platlib_dir)
404 if os.path.exists(data_dir):
405 lib_dir_list.append(data_dir)
406
407 for lib_dir in lib_dir_list:
408 for item in os.listdir(lib_dir):
409 if lib_dir == data_dir:
410 ddir = os.path.join(data_dir, item)
411 if any(s.startswith(ddir) for s in lib_dir_list[:-1]):
412 continue
413 target_item_dir = os.path.join(target_dir, item)
414 if os.path.exists(target_item_dir):
415 if not upgrade:
416 logger.warning(
417 'Target directory %s already exists. Specify '
418 '--upgrade to force replacement.',
419 target_item_dir
420 )
421 continue
422 if os.path.islink(target_item_dir):
423 logger.warning(
424 'Target directory %s already exists and is '
425 'a link. Pip will not automatically replace '
426 'links, please remove if replacement is '
427 'desired.',
428 target_item_dir
429 )
430 continue
431 if os.path.isdir(target_item_dir):
432 shutil.rmtree(target_item_dir)
433 else:
434 os.remove(target_item_dir)
435
436 shutil.move(
437 os.path.join(lib_dir, item),
438 target_item_dir
439 )
440
441 def _warn_about_conflicts(self, to_install):
442 package_set, _dep_info = check_install_conflicts(to_install)
443 missing, conflicting = _dep_info
444
445 # NOTE: There is some duplication here from pip check
446 for project_name in missing:
447 version = package_set[project_name][0]
448 for dependency in missing[project_name]:
449 logger.critical(
450 "%s %s requires %s, which is not installed.",
451 project_name, version, dependency[1],
452 )
453
454 for project_name in conflicting:
455 version = package_set[project_name][0]
456 for dep_name, dep_version, req in conflicting[project_name]:
457 logger.critical(
458 "%s %s has requirement %s, but you'll have %s %s which is "
459 "incompatible.",
460 project_name, version, req, dep_name, dep_version,
461 )
462
463
464def get_lib_location_guesses(*args, **kwargs):
465 scheme = distutils_scheme('', *args, **kwargs)
466 return [scheme['purelib'], scheme['platlib']]
467
468
469def create_env_error_message(error, show_traceback, using_user_site):
470 """Format an error message for an EnvironmentError
471
472 It may occur anytime during the execution of the install command.
473 """
474 parts = []
475
476 # Mention the error if we are not going to show a traceback
477 parts.append("Could not install packages due to an EnvironmentError")
478 if not show_traceback:
479 parts.append(": ")
480 parts.append(str(error))
481 else:
482 parts.append(".")
483
484 # Spilt the error indication from a helper message (if any)
485 parts[-1] += "\n"
486
487 # Suggest useful actions to the user:
488 # (1) using user site-packages or (2) verifying the permissions
489 if error.errno == errno.EACCES:
490 user_option_part = "Consider using the `--user` option"
491 permissions_part = "Check the permissions"
492
493 if not using_user_site:
494 parts.extend([
495 user_option_part, " or ",
496 permissions_part.lower(),
497 ])
498 else:
499 parts.append(permissions_part)
500 parts.append(".\n")
501
502 return "".join(parts).strip() + "\n"
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/list.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/list.py
deleted file mode 100644
index 1b46c6f..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/list.py
+++ /dev/null
@@ -1,343 +0,0 @@
1from __future__ import absolute_import
2
3import json
4import logging
5import warnings
6
7from pip._vendor import six
8from pip._vendor.six.moves import zip_longest
9
10from pip._internal.basecommand import Command
11from pip._internal.cmdoptions import index_group, make_option_group
12from pip._internal.exceptions import CommandError
13from pip._internal.index import PackageFinder
14from pip._internal.utils.deprecation import RemovedInPip11Warning
15from pip._internal.utils.misc import (
16 dist_is_editable, get_installed_distributions,
17)
18from pip._internal.utils.packaging import get_installer
19
20logger = logging.getLogger(__name__)
21
22
23class ListCommand(Command):
24 """
25 List installed packages, including editables.
26
27 Packages are listed in a case-insensitive sorted order.
28 """
29 name = 'list'
30 usage = """
31 %prog [options]"""
32 summary = 'List installed packages.'
33
34 def __init__(self, *args, **kw):
35 super(ListCommand, self).__init__(*args, **kw)
36
37 cmd_opts = self.cmd_opts
38
39 cmd_opts.add_option(
40 '-o', '--outdated',
41 action='store_true',
42 default=False,
43 help='List outdated packages')
44 cmd_opts.add_option(
45 '-u', '--uptodate',
46 action='store_true',
47 default=False,
48 help='List uptodate packages')
49 cmd_opts.add_option(
50 '-e', '--editable',
51 action='store_true',
52 default=False,
53 help='List editable projects.')
54 cmd_opts.add_option(
55 '-l', '--local',
56 action='store_true',
57 default=False,
58 help=('If in a virtualenv that has global access, do not list '
59 'globally-installed packages.'),
60 )
61 self.cmd_opts.add_option(
62 '--user',
63 dest='user',
64 action='store_true',
65 default=False,
66 help='Only output packages installed in user-site.')
67
68 cmd_opts.add_option(
69 '--pre',
70 action='store_true',
71 default=False,
72 help=("Include pre-release and development versions. By default, "
73 "pip only finds stable versions."),
74 )
75
76 cmd_opts.add_option(
77 '--format',
78 action='store',
79 dest='list_format',
80 default="columns",
81 choices=('legacy', 'columns', 'freeze', 'json'),
82 help="Select the output format among: columns (default), freeze, "
83 "json, or legacy.",
84 )
85
86 cmd_opts.add_option(
87 '--not-required',
88 action='store_true',
89 dest='not_required',
90 help="List packages that are not dependencies of "
91 "installed packages.",
92 )
93
94 cmd_opts.add_option(
95 '--exclude-editable',
96 action='store_false',
97 dest='include_editable',
98 help='Exclude editable package from output.',
99 )
100 cmd_opts.add_option(
101 '--include-editable',
102 action='store_true',
103 dest='include_editable',
104 help='Include editable package from output.',
105 default=True,
106 )
107 index_opts = make_option_group(index_group, self.parser)
108
109 self.parser.insert_option_group(0, index_opts)
110 self.parser.insert_option_group(0, cmd_opts)
111
112 def _build_package_finder(self, options, index_urls, session):
113 """
114 Create a package finder appropriate to this list command.
115 """
116 return PackageFinder(
117 find_links=options.find_links,
118 index_urls=index_urls,
119 allow_all_prereleases=options.pre,
120 trusted_hosts=options.trusted_hosts,
121 process_dependency_links=options.process_dependency_links,
122 session=session,
123 )
124
125 def run(self, options, args):
126 if options.list_format == "legacy":
127 warnings.warn(
128 "The legacy format has been deprecated and will be removed "
129 "in the future.",
130 RemovedInPip11Warning,
131 )
132
133 if options.outdated and options.uptodate:
134 raise CommandError(
135 "Options --outdated and --uptodate cannot be combined.")
136
137 packages = get_installed_distributions(
138 local_only=options.local,
139 user_only=options.user,
140 editables_only=options.editable,
141 include_editables=options.include_editable,
142 )
143
144 if options.outdated:
145 packages = self.get_outdated(packages, options)
146 elif options.uptodate:
147 packages = self.get_uptodate(packages, options)
148
149 if options.not_required:
150 packages = self.get_not_required(packages, options)
151
152 self.output_package_listing(packages, options)
153
154 def get_outdated(self, packages, options):
155 return [
156 dist for dist in self.iter_packages_latest_infos(packages, options)
157 if dist.latest_version > dist.parsed_version
158 ]
159
160 def get_uptodate(self, packages, options):
161 return [
162 dist for dist in self.iter_packages_latest_infos(packages, options)
163 if dist.latest_version == dist.parsed_version
164 ]
165
166 def get_not_required(self, packages, options):
167 dep_keys = set()
168 for dist in packages:
169 dep_keys.update(requirement.key for requirement in dist.requires())
170 return {pkg for pkg in packages if pkg.key not in dep_keys}
171
172 def iter_packages_latest_infos(self, packages, options):
173 index_urls = [options.index_url] + options.extra_index_urls
174 if options.no_index:
175 logger.debug('Ignoring indexes: %s', ','.join(index_urls))
176 index_urls = []
177
178 dependency_links = []
179 for dist in packages:
180 if dist.has_metadata('dependency_links.txt'):
181 dependency_links.extend(
182 dist.get_metadata_lines('dependency_links.txt'),
183 )
184
185 with self._build_session(options) as session:
186 finder = self._build_package_finder(options, index_urls, session)
187 finder.add_dependency_links(dependency_links)
188
189 for dist in packages:
190 typ = 'unknown'
191 all_candidates = finder.find_all_candidates(dist.key)
192 if not options.pre:
193 # Remove prereleases
194 all_candidates = [candidate for candidate in all_candidates
195 if not candidate.version.is_prerelease]
196
197 if not all_candidates:
198 continue
199 best_candidate = max(all_candidates,
200 key=finder._candidate_sort_key)
201 remote_version = best_candidate.version
202 if best_candidate.location.is_wheel:
203 typ = 'wheel'
204 else:
205 typ = 'sdist'
206 # This is dirty but makes the rest of the code much cleaner
207 dist.latest_version = remote_version
208 dist.latest_filetype = typ
209 yield dist
210
211 def output_legacy(self, dist, options):
212 if options.verbose >= 1:
213 return '%s (%s, %s, %s)' % (
214 dist.project_name,
215 dist.version,
216 dist.location,
217 get_installer(dist),
218 )
219 elif dist_is_editable(dist):
220 return '%s (%s, %s)' % (
221 dist.project_name,
222 dist.version,
223 dist.location,
224 )
225 else:
226 return '%s (%s)' % (dist.project_name, dist.version)
227
228 def output_legacy_latest(self, dist, options):
229 return '%s - Latest: %s [%s]' % (
230 self.output_legacy(dist, options),
231 dist.latest_version,
232 dist.latest_filetype,
233 )
234
235 def output_package_listing(self, packages, options):
236 packages = sorted(
237 packages,
238 key=lambda dist: dist.project_name.lower(),
239 )
240 if options.list_format == 'columns' and packages:
241 data, header = format_for_columns(packages, options)
242 self.output_package_listing_columns(data, header)
243 elif options.list_format == 'freeze':
244 for dist in packages:
245 if options.verbose >= 1:
246 logger.info("%s==%s (%s)", dist.project_name,
247 dist.version, dist.location)
248 else:
249 logger.info("%s==%s", dist.project_name, dist.version)
250 elif options.list_format == 'json':
251 logger.info(format_for_json(packages, options))
252 elif options.list_format == "legacy":
253 for dist in packages:
254 if options.outdated:
255 logger.info(self.output_legacy_latest(dist, options))
256 else:
257 logger.info(self.output_legacy(dist, options))
258
259 def output_package_listing_columns(self, data, header):
260 # insert the header first: we need to know the size of column names
261 if len(data) > 0:
262 data.insert(0, header)
263
264 pkg_strings, sizes = tabulate(data)
265
266 # Create and add a separator.
267 if len(data) > 0:
268 pkg_strings.insert(1, " ".join(map(lambda x: '-' * x, sizes)))
269
270 for val in pkg_strings:
271 logger.info(val)
272
273
274def tabulate(vals):
275 # From pfmoore on GitHub:
276 # https://github.com/pypa/pip/issues/3651#issuecomment-216932564
277 assert len(vals) > 0
278
279 sizes = [0] * max(len(x) for x in vals)
280 for row in vals:
281 sizes = [max(s, len(str(c))) for s, c in zip_longest(sizes, row)]
282
283 result = []
284 for row in vals:
285 display = " ".join([str(c).ljust(s) if c is not None else ''
286 for s, c in zip_longest(sizes, row)])
287 result.append(display)
288
289 return result, sizes
290
291
292def format_for_columns(pkgs, options):
293 """
294 Convert the package data into something usable
295 by output_package_listing_columns.
296 """
297 running_outdated = options.outdated
298 # Adjust the header for the `pip list --outdated` case.
299 if running_outdated:
300 header = ["Package", "Version", "Latest", "Type"]
301 else:
302 header = ["Package", "Version"]
303
304 data = []
305 if options.verbose >= 1 or any(dist_is_editable(x) for x in pkgs):
306 header.append("Location")
307 if options.verbose >= 1:
308 header.append("Installer")
309
310 for proj in pkgs:
311 # if we're working on the 'outdated' list, separate out the
312 # latest_version and type
313 row = [proj.project_name, proj.version]
314
315 if running_outdated:
316 row.append(proj.latest_version)
317 row.append(proj.latest_filetype)
318
319 if options.verbose >= 1 or dist_is_editable(proj):
320 row.append(proj.location)
321 if options.verbose >= 1:
322 row.append(get_installer(proj))
323
324 data.append(row)
325
326 return data, header
327
328
329def format_for_json(packages, options):
330 data = []
331 for dist in packages:
332 info = {
333 'name': dist.project_name,
334 'version': six.text_type(dist.version),
335 }
336 if options.verbose >= 1:
337 info['location'] = dist.location
338 info['installer'] = get_installer(dist)
339 if options.outdated:
340 info['latest_version'] = six.text_type(dist.latest_version)
341 info['latest_filetype'] = dist.latest_filetype
342 data.append(info)
343 return json.dumps(data)
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/search.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/search.py
deleted file mode 100644
index 83895ce..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/search.py
+++ /dev/null
@@ -1,135 +0,0 @@
1from __future__ import absolute_import
2
3import logging
4import sys
5import textwrap
6from collections import OrderedDict
7
8from pip._vendor import pkg_resources
9from pip._vendor.packaging.version import parse as parse_version
10# NOTE: XMLRPC Client is not annotated in typeshed as on 2017-07-17, which is
11# why we ignore the type on this import
12from pip._vendor.six.moves import xmlrpc_client # type: ignore
13
14from pip._internal.basecommand import SUCCESS, Command
15from pip._internal.compat import get_terminal_size
16from pip._internal.download import PipXmlrpcTransport
17from pip._internal.exceptions import CommandError
18from pip._internal.models import PyPI
19from pip._internal.status_codes import NO_MATCHES_FOUND
20from pip._internal.utils.logging import indent_log
21
22logger = logging.getLogger(__name__)
23
24
25class SearchCommand(Command):
26 """Search for PyPI packages whose name or summary contains <query>."""
27 name = 'search'
28 usage = """
29 %prog [options] <query>"""
30 summary = 'Search PyPI for packages.'
31 ignore_require_venv = True
32
33 def __init__(self, *args, **kw):
34 super(SearchCommand, self).__init__(*args, **kw)
35 self.cmd_opts.add_option(
36 '-i', '--index',
37 dest='index',
38 metavar='URL',
39 default=PyPI.pypi_url,
40 help='Base URL of Python Package Index (default %default)')
41
42 self.parser.insert_option_group(0, self.cmd_opts)
43
44 def run(self, options, args):
45 if not args:
46 raise CommandError('Missing required argument (search query).')
47 query = args
48 pypi_hits = self.search(query, options)
49 hits = transform_hits(pypi_hits)
50
51 terminal_width = None
52 if sys.stdout.isatty():
53 terminal_width = get_terminal_size()[0]
54
55 print_results(hits, terminal_width=terminal_width)
56 if pypi_hits:
57 return SUCCESS
58 return NO_MATCHES_FOUND
59
60 def search(self, query, options):
61 index_url = options.index
62 with self._build_session(options) as session:
63 transport = PipXmlrpcTransport(index_url, session)
64 pypi = xmlrpc_client.ServerProxy(index_url, transport)
65 hits = pypi.search({'name': query, 'summary': query}, 'or')
66 return hits
67
68
69def transform_hits(hits):
70 """
71 The list from pypi is really a list of versions. We want a list of
72 packages with the list of versions stored inline. This converts the
73 list from pypi into one we can use.
74 """
75 packages = OrderedDict()
76 for hit in hits:
77 name = hit['name']
78 summary = hit['summary']
79 version = hit['version']
80
81 if name not in packages.keys():
82 packages[name] = {
83 'name': name,
84 'summary': summary,
85 'versions': [version],
86 }
87 else:
88 packages[name]['versions'].append(version)
89
90 # if this is the highest version, replace summary and score
91 if version == highest_version(packages[name]['versions']):
92 packages[name]['summary'] = summary
93
94 return list(packages.values())
95
96
97def print_results(hits, name_column_width=None, terminal_width=None):
98 if not hits:
99 return
100 if name_column_width is None:
101 name_column_width = max([
102 len(hit['name']) + len(highest_version(hit.get('versions', ['-'])))
103 for hit in hits
104 ]) + 4
105
106 installed_packages = [p.project_name for p in pkg_resources.working_set]
107 for hit in hits:
108 name = hit['name']
109 summary = hit['summary'] or ''
110 latest = highest_version(hit.get('versions', ['-']))
111 if terminal_width is not None:
112 target_width = terminal_width - name_column_width - 5
113 if target_width > 10:
114 # wrap and indent summary to fit terminal
115 summary = textwrap.wrap(summary, target_width)
116 summary = ('\n' + ' ' * (name_column_width + 3)).join(summary)
117
118 line = '%-*s - %s' % (name_column_width,
119 '%s (%s)' % (name, latest), summary)
120 try:
121 logger.info(line)
122 if name in installed_packages:
123 dist = pkg_resources.get_distribution(name)
124 with indent_log():
125 if dist.version == latest:
126 logger.info('INSTALLED: %s (latest)', dist.version)
127 else:
128 logger.info('INSTALLED: %s', dist.version)
129 logger.info('LATEST: %s', latest)
130 except UnicodeEncodeError:
131 pass
132
133
134def highest_version(versions):
135 return max(versions, key=parse_version)
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/show.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/show.py
deleted file mode 100644
index bad9628..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/show.py
+++ /dev/null
@@ -1,164 +0,0 @@
1from __future__ import absolute_import
2
3import logging
4import os
5from email.parser import FeedParser # type: ignore
6
7from pip._vendor import pkg_resources
8from pip._vendor.packaging.utils import canonicalize_name
9
10from pip._internal.basecommand import Command
11from pip._internal.status_codes import ERROR, SUCCESS
12
13logger = logging.getLogger(__name__)
14
15
16class ShowCommand(Command):
17 """Show information about one or more installed packages."""
18 name = 'show'
19 usage = """
20 %prog [options] <package> ..."""
21 summary = 'Show information about installed packages.'
22 ignore_require_venv = True
23
24 def __init__(self, *args, **kw):
25 super(ShowCommand, self).__init__(*args, **kw)
26 self.cmd_opts.add_option(
27 '-f', '--files',
28 dest='files',
29 action='store_true',
30 default=False,
31 help='Show the full list of installed files for each package.')
32
33 self.parser.insert_option_group(0, self.cmd_opts)
34
35 def run(self, options, args):
36 if not args:
37 logger.warning('ERROR: Please provide a package name or names.')
38 return ERROR
39 query = args
40
41 results = search_packages_info(query)
42 if not print_results(
43 results, list_files=options.files, verbose=options.verbose):
44 return ERROR
45 return SUCCESS
46
47
48def search_packages_info(query):
49 """
50 Gather details from installed distributions. Print distribution name,
51 version, location, and installed files. Installed files requires a
52 pip generated 'installed-files.txt' in the distributions '.egg-info'
53 directory.
54 """
55 installed = {}
56 for p in pkg_resources.working_set:
57 installed[canonicalize_name(p.project_name)] = p
58
59 query_names = [canonicalize_name(name) for name in query]
60
61 for dist in [installed[pkg] for pkg in query_names if pkg in installed]:
62 package = {
63 'name': dist.project_name,
64 'version': dist.version,
65 'location': dist.location,
66 'requires': [dep.project_name for dep in dist.requires()],
67 }
68 file_list = None
69 metadata = None
70 if isinstance(dist, pkg_resources.DistInfoDistribution):
71 # RECORDs should be part of .dist-info metadatas
72 if dist.has_metadata('RECORD'):
73 lines = dist.get_metadata_lines('RECORD')
74 paths = [l.split(',')[0] for l in lines]
75 paths = [os.path.join(dist.location, p) for p in paths]
76 file_list = [os.path.relpath(p, dist.location) for p in paths]
77
78 if dist.has_metadata('METADATA'):
79 metadata = dist.get_metadata('METADATA')
80 else:
81 # Otherwise use pip's log for .egg-info's
82 if dist.has_metadata('installed-files.txt'):
83 paths = dist.get_metadata_lines('installed-files.txt')
84 paths = [os.path.join(dist.egg_info, p) for p in paths]
85 file_list = [os.path.relpath(p, dist.location) for p in paths]
86
87 if dist.has_metadata('PKG-INFO'):
88 metadata = dist.get_metadata('PKG-INFO')
89
90 if dist.has_metadata('entry_points.txt'):
91 entry_points = dist.get_metadata_lines('entry_points.txt')
92 package['entry_points'] = entry_points
93
94 if dist.has_metadata('INSTALLER'):
95 for line in dist.get_metadata_lines('INSTALLER'):
96 if line.strip():
97 package['installer'] = line.strip()
98 break
99
100 # @todo: Should pkg_resources.Distribution have a
101 # `get_pkg_info` method?
102 feed_parser = FeedParser()
103 feed_parser.feed(metadata)
104 pkg_info_dict = feed_parser.close()
105 for key in ('metadata-version', 'summary',
106 'home-page', 'author', 'author-email', 'license'):
107 package[key] = pkg_info_dict.get(key)
108
109 # It looks like FeedParser cannot deal with repeated headers
110 classifiers = []
111 for line in metadata.splitlines():
112 if line.startswith('Classifier: '):
113 classifiers.append(line[len('Classifier: '):])
114 package['classifiers'] = classifiers
115
116 if file_list:
117 package['files'] = sorted(file_list)
118 yield package
119
120
121def print_results(distributions, list_files=False, verbose=False):
122 """
123 Print the informations from installed distributions found.
124 """
125 results_printed = False
126 for i, dist in enumerate(distributions):
127 results_printed = True
128 if i > 0:
129 logger.info("---")
130
131 name = dist.get('name', '')
132 required_by = [
133 pkg.project_name for pkg in pkg_resources.working_set
134 if name in [required.name for required in pkg.requires()]
135 ]
136
137 logger.info("Name: %s", name)
138 logger.info("Version: %s", dist.get('version', ''))
139 logger.info("Summary: %s", dist.get('summary', ''))
140 logger.info("Home-page: %s", dist.get('home-page', ''))
141 logger.info("Author: %s", dist.get('author', ''))
142 logger.info("Author-email: %s", dist.get('author-email', ''))
143 logger.info("License: %s", dist.get('license', ''))
144 logger.info("Location: %s", dist.get('location', ''))
145 logger.info("Requires: %s", ', '.join(dist.get('requires', [])))
146 logger.info("Required-by: %s", ', '.join(required_by))
147
148 if verbose:
149 logger.info("Metadata-Version: %s",
150 dist.get('metadata-version', ''))
151 logger.info("Installer: %s", dist.get('installer', ''))
152 logger.info("Classifiers:")
153 for classifier in dist.get('classifiers', []):
154 logger.info(" %s", classifier)
155 logger.info("Entry-points:")
156 for entry in dist.get('entry_points', []):
157 logger.info(" %s", entry.strip())
158 if list_files:
159 logger.info("Files:")
160 for line in dist.get('files', []):
161 logger.info(" %s", line.strip())
162 if "files" not in dist:
163 logger.info("Cannot locate installed-files.txt")
164 return results_printed
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/uninstall.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/uninstall.py
deleted file mode 100644
index 3bfa07f..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/uninstall.py
+++ /dev/null
@@ -1,71 +0,0 @@
1from __future__ import absolute_import
2
3from pip._vendor.packaging.utils import canonicalize_name
4
5from pip._internal.basecommand import Command
6from pip._internal.exceptions import InstallationError
7from pip._internal.req import InstallRequirement, parse_requirements
8
9
10class UninstallCommand(Command):
11 """
12 Uninstall packages.
13
14 pip is able to uninstall most installed packages. Known exceptions are:
15
16 - Pure distutils packages installed with ``python setup.py install``, which
17 leave behind no metadata to determine what files were installed.
18 - Script wrappers installed by ``python setup.py develop``.
19 """
20 name = 'uninstall'
21 usage = """
22 %prog [options] <package> ...
23 %prog [options] -r <requirements file> ..."""
24 summary = 'Uninstall packages.'
25
26 def __init__(self, *args, **kw):
27 super(UninstallCommand, self).__init__(*args, **kw)
28 self.cmd_opts.add_option(
29 '-r', '--requirement',
30 dest='requirements',
31 action='append',
32 default=[],
33 metavar='file',
34 help='Uninstall all the packages listed in the given requirements '
35 'file. This option can be used multiple times.',
36 )
37 self.cmd_opts.add_option(
38 '-y', '--yes',
39 dest='yes',
40 action='store_true',
41 help="Don't ask for confirmation of uninstall deletions.")
42
43 self.parser.insert_option_group(0, self.cmd_opts)
44
45 def run(self, options, args):
46 with self._build_session(options) as session:
47 reqs_to_uninstall = {}
48 for name in args:
49 req = InstallRequirement.from_line(
50 name, isolated=options.isolated_mode,
51 )
52 if req.name:
53 reqs_to_uninstall[canonicalize_name(req.name)] = req
54 for filename in options.requirements:
55 for req in parse_requirements(
56 filename,
57 options=options,
58 session=session):
59 if req.name:
60 reqs_to_uninstall[canonicalize_name(req.name)] = req
61 if not reqs_to_uninstall:
62 raise InstallationError(
63 'You must give at least one requirement to %(name)s (see '
64 '"pip help %(name)s")' % dict(name=self.name)
65 )
66 for req in reqs_to_uninstall.values():
67 uninstall_pathset = req.uninstall(
68 auto_confirm=options.yes, verbose=self.verbosity > 0,
69 )
70 if uninstall_pathset:
71 uninstall_pathset.commit()
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/wheel.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/wheel.py
deleted file mode 100644
index ed8cdfc..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/wheel.py
+++ /dev/null
@@ -1,179 +0,0 @@
1# -*- coding: utf-8 -*-
2from __future__ import absolute_import
3
4import logging
5import os
6
7from pip._internal import cmdoptions
8from pip._internal.basecommand import RequirementCommand
9from pip._internal.cache import WheelCache
10from pip._internal.exceptions import CommandError, PreviousBuildDirError
11from pip._internal.operations.prepare import RequirementPreparer
12from pip._internal.req import RequirementSet
13from pip._internal.resolve import Resolver
14from pip._internal.utils.temp_dir import TempDirectory
15from pip._internal.wheel import WheelBuilder
16
17logger = logging.getLogger(__name__)
18
19
20class WheelCommand(RequirementCommand):
21 """
22 Build Wheel archives for your requirements and dependencies.
23
24 Wheel is a built-package format, and offers the advantage of not
25 recompiling your software during every install. For more details, see the
26 wheel docs: https://wheel.readthedocs.io/en/latest/
27
28 Requirements: setuptools>=0.8, and wheel.
29
30 'pip wheel' uses the bdist_wheel setuptools extension from the wheel
31 package to build individual wheels.
32
33 """
34
35 name = 'wheel'
36 usage = """
37 %prog [options] <requirement specifier> ...
38 %prog [options] -r <requirements file> ...
39 %prog [options] [-e] <vcs project url> ...
40 %prog [options] [-e] <local project path> ...
41 %prog [options] <archive url/path> ..."""
42
43 summary = 'Build wheels from your requirements.'
44
45 def __init__(self, *args, **kw):
46 super(WheelCommand, self).__init__(*args, **kw)
47
48 cmd_opts = self.cmd_opts
49
50 cmd_opts.add_option(
51 '-w', '--wheel-dir',
52 dest='wheel_dir',
53 metavar='dir',
54 default=os.curdir,
55 help=("Build wheels into <dir>, where the default is the "
56 "current working directory."),
57 )
58 cmd_opts.add_option(cmdoptions.no_binary())
59 cmd_opts.add_option(cmdoptions.only_binary())
60 cmd_opts.add_option(
61 '--build-option',
62 dest='build_options',
63 metavar='options',
64 action='append',
65 help="Extra arguments to be supplied to 'setup.py bdist_wheel'.",
66 )
67 cmd_opts.add_option(cmdoptions.no_build_isolation())
68 cmd_opts.add_option(cmdoptions.constraints())
69 cmd_opts.add_option(cmdoptions.editable())
70 cmd_opts.add_option(cmdoptions.requirements())
71 cmd_opts.add_option(cmdoptions.src())
72 cmd_opts.add_option(cmdoptions.ignore_requires_python())
73 cmd_opts.add_option(cmdoptions.no_deps())
74 cmd_opts.add_option(cmdoptions.build_dir())
75 cmd_opts.add_option(cmdoptions.progress_bar())
76
77 cmd_opts.add_option(
78 '--global-option',
79 dest='global_options',
80 action='append',
81 metavar='options',
82 help="Extra global options to be supplied to the setup.py "
83 "call before the 'bdist_wheel' command.")
84
85 cmd_opts.add_option(
86 '--pre',
87 action='store_true',
88 default=False,
89 help=("Include pre-release and development versions. By default, "
90 "pip only finds stable versions."),
91 )
92
93 cmd_opts.add_option(cmdoptions.no_clean())
94 cmd_opts.add_option(cmdoptions.require_hashes())
95
96 index_opts = cmdoptions.make_option_group(
97 cmdoptions.index_group,
98 self.parser,
99 )
100
101 self.parser.insert_option_group(0, index_opts)
102 self.parser.insert_option_group(0, cmd_opts)
103
104 def run(self, options, args):
105 cmdoptions.check_install_build_global(options)
106
107 index_urls = [options.index_url] + options.extra_index_urls
108 if options.no_index:
109 logger.debug('Ignoring indexes: %s', ','.join(index_urls))
110 index_urls = []
111
112 if options.build_dir:
113 options.build_dir = os.path.abspath(options.build_dir)
114
115 options.src_dir = os.path.abspath(options.src_dir)
116
117 with self._build_session(options) as session:
118 finder = self._build_package_finder(options, session)
119 build_delete = (not (options.no_clean or options.build_dir))
120 wheel_cache = WheelCache(options.cache_dir, options.format_control)
121
122 with TempDirectory(
123 options.build_dir, delete=build_delete, kind="wheel"
124 ) as directory:
125 requirement_set = RequirementSet(
126 require_hashes=options.require_hashes,
127 )
128
129 try:
130 self.populate_requirement_set(
131 requirement_set, args, options, finder, session,
132 self.name, wheel_cache
133 )
134
135 preparer = RequirementPreparer(
136 build_dir=directory.path,
137 src_dir=options.src_dir,
138 download_dir=None,
139 wheel_download_dir=options.wheel_dir,
140 progress_bar=options.progress_bar,
141 build_isolation=options.build_isolation,
142 )
143
144 resolver = Resolver(
145 preparer=preparer,
146 finder=finder,
147 session=session,
148 wheel_cache=wheel_cache,
149 use_user_site=False,
150 upgrade_strategy="to-satisfy-only",
151 force_reinstall=False,
152 ignore_dependencies=options.ignore_dependencies,
153 ignore_requires_python=options.ignore_requires_python,
154 ignore_installed=True,
155 isolated=options.isolated_mode,
156 )
157 resolver.resolve(requirement_set)
158
159 # build wheels
160 wb = WheelBuilder(
161 finder, preparer, wheel_cache,
162 build_options=options.build_options or [],
163 global_options=options.global_options or [],
164 no_clean=options.no_clean,
165 )
166 wheels_built_successfully = wb.build(
167 requirement_set.requirements.values(), session=session,
168 )
169 if not wheels_built_successfully:
170 raise CommandError(
171 "Failed to build one or more wheels"
172 )
173 except PreviousBuildDirError:
174 options.no_clean = True
175 raise
176 finally:
177 if not options.no_clean:
178 requirement_set.cleanup_files()
179 wheel_cache.cleanup()