Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/pip/_internal/commands/uninstall.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 from pip._vendor.packaging.utils import canonicalize_name | |
| 4 | |
| 5 from pip._internal.cli.base_command import Command | |
| 6 from pip._internal.exceptions import InstallationError | |
| 7 from pip._internal.req import parse_requirements | |
| 8 from pip._internal.req.constructors import install_req_from_line | |
| 9 from pip._internal.utils.misc import protect_pip_from_modification_on_windows | |
| 10 | |
| 11 | |
| 12 class UninstallCommand(Command): | |
| 13 """ | |
| 14 Uninstall packages. | |
| 15 | |
| 16 pip is able to uninstall most installed packages. Known exceptions are: | |
| 17 | |
| 18 - Pure distutils packages installed with ``python setup.py install``, which | |
| 19 leave behind no metadata to determine what files were installed. | |
| 20 - Script wrappers installed by ``python setup.py develop``. | |
| 21 """ | |
| 22 name = 'uninstall' | |
| 23 usage = """ | |
| 24 %prog [options] <package> ... | |
| 25 %prog [options] -r <requirements file> ...""" | |
| 26 summary = 'Uninstall packages.' | |
| 27 | |
| 28 def __init__(self, *args, **kw): | |
| 29 super(UninstallCommand, self).__init__(*args, **kw) | |
| 30 self.cmd_opts.add_option( | |
| 31 '-r', '--requirement', | |
| 32 dest='requirements', | |
| 33 action='append', | |
| 34 default=[], | |
| 35 metavar='file', | |
| 36 help='Uninstall all the packages listed in the given requirements ' | |
| 37 'file. This option can be used multiple times.', | |
| 38 ) | |
| 39 self.cmd_opts.add_option( | |
| 40 '-y', '--yes', | |
| 41 dest='yes', | |
| 42 action='store_true', | |
| 43 help="Don't ask for confirmation of uninstall deletions.") | |
| 44 | |
| 45 self.parser.insert_option_group(0, self.cmd_opts) | |
| 46 | |
| 47 def run(self, options, args): | |
| 48 with self._build_session(options) as session: | |
| 49 reqs_to_uninstall = {} | |
| 50 for name in args: | |
| 51 req = install_req_from_line( | |
| 52 name, isolated=options.isolated_mode, | |
| 53 ) | |
| 54 if req.name: | |
| 55 reqs_to_uninstall[canonicalize_name(req.name)] = req | |
| 56 for filename in options.requirements: | |
| 57 for req in parse_requirements( | |
| 58 filename, | |
| 59 options=options, | |
| 60 session=session): | |
| 61 if req.name: | |
| 62 reqs_to_uninstall[canonicalize_name(req.name)] = req | |
| 63 if not reqs_to_uninstall: | |
| 64 raise InstallationError( | |
| 65 'You must give at least one requirement to %(name)s (see ' | |
| 66 '"pip help %(name)s")' % dict(name=self.name) | |
| 67 ) | |
| 68 | |
| 69 protect_pip_from_modification_on_windows( | |
| 70 modifying_pip="pip" in reqs_to_uninstall | |
| 71 ) | |
| 72 | |
| 73 for req in reqs_to_uninstall.values(): | |
| 74 uninstall_pathset = req.uninstall( | |
| 75 auto_confirm=options.yes, verbose=self.verbosity > 0, | |
| 76 ) | |
| 77 if uninstall_pathset: | |
| 78 uninstall_pathset.commit() |
