Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/pip/commands/uninstall.py @ 0:d67268158946 draft
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
| author | bcclaywell |
|---|---|
| date | Mon, 12 Oct 2015 17:43:33 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:d67268158946 |
|---|---|
| 1 from __future__ import absolute_import | |
| 2 | |
| 3 from pip.req import InstallRequirement, RequirementSet, parse_requirements | |
| 4 from pip.basecommand import Command | |
| 5 from pip.exceptions import InstallationError | |
| 6 | |
| 7 | |
| 8 class UninstallCommand(Command): | |
| 9 """ | |
| 10 Uninstall packages. | |
| 11 | |
| 12 pip is able to uninstall most installed packages. Known exceptions are: | |
| 13 | |
| 14 - Pure distutils packages installed with ``python setup.py install``, which | |
| 15 leave behind no metadata to determine what files were installed. | |
| 16 - Script wrappers installed by ``python setup.py develop``. | |
| 17 """ | |
| 18 name = 'uninstall' | |
| 19 usage = """ | |
| 20 %prog [options] <package> ... | |
| 21 %prog [options] -r <requirements file> ...""" | |
| 22 summary = 'Uninstall packages.' | |
| 23 | |
| 24 def __init__(self, *args, **kw): | |
| 25 super(UninstallCommand, self).__init__(*args, **kw) | |
| 26 self.cmd_opts.add_option( | |
| 27 '-r', '--requirement', | |
| 28 dest='requirements', | |
| 29 action='append', | |
| 30 default=[], | |
| 31 metavar='file', | |
| 32 help='Uninstall all the packages listed in the given requirements ' | |
| 33 'file. This option can be used multiple times.', | |
| 34 ) | |
| 35 self.cmd_opts.add_option( | |
| 36 '-y', '--yes', | |
| 37 dest='yes', | |
| 38 action='store_true', | |
| 39 help="Don't ask for confirmation of uninstall deletions.") | |
| 40 | |
| 41 self.parser.insert_option_group(0, self.cmd_opts) | |
| 42 | |
| 43 def run(self, options, args): | |
| 44 with self._build_session(options) as session: | |
| 45 | |
| 46 requirement_set = RequirementSet( | |
| 47 build_dir=None, | |
| 48 src_dir=None, | |
| 49 download_dir=None, | |
| 50 isolated=options.isolated_mode, | |
| 51 session=session, | |
| 52 ) | |
| 53 for name in args: | |
| 54 requirement_set.add_requirement( | |
| 55 InstallRequirement.from_line( | |
| 56 name, isolated=options.isolated_mode, | |
| 57 ) | |
| 58 ) | |
| 59 for filename in options.requirements: | |
| 60 for req in parse_requirements( | |
| 61 filename, | |
| 62 options=options, | |
| 63 session=session): | |
| 64 requirement_set.add_requirement(req) | |
| 65 if not requirement_set.has_requirements: | |
| 66 raise InstallationError( | |
| 67 'You must give at least one requirement to %(name)s (see ' | |
| 68 '"pip help %(name)s")' % dict(name=self.name) | |
| 69 ) | |
| 70 requirement_set.uninstall(auto_confirm=options.yes) |
