diff options
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/uninstall.py')
-rw-r--r-- | venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/uninstall.py | 71 |
1 files changed, 71 insertions, 0 deletions
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 new file mode 100644 index 0000000..3bfa07f --- /dev/null +++ b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/uninstall.py | |||
@@ -0,0 +1,71 @@ | |||
1 | from __future__ import absolute_import | ||
2 | |||
3 | from pip._vendor.packaging.utils import canonicalize_name | ||
4 | |||
5 | from pip._internal.basecommand import Command | ||
6 | from pip._internal.exceptions import InstallationError | ||
7 | from pip._internal.req import InstallRequirement, parse_requirements | ||
8 | |||
9 | |||
10 | class 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() | ||