U
    KQhD                     @   s`   d dl mZ d dlZd dlmZ d dlmZmZmZ d dl	m
Z
 d dlmZ G dd de
ZdS )	    )absolute_importN)
WheelCache)InstallRequirementRequirementSetparse_requirements)Command)InstallationErrorc                       s4   e Zd ZdZdZdZdZ fddZdd Z  Z	S )	UninstallCommandaB  
    Uninstall packages.

    pip is able to uninstall most installed packages. Known exceptions are:

    - Pure distutils packages installed with ``python setup.py install``, which
      leave behind no metadata to determine what files were installed.
    - Script wrappers installed by ``python setup.py develop``.
    	uninstallzU
      %prog [options] <package> ...
      %prog [options] -r <requirements file> ...zUninstall packages.c              	      sV   t t| j|| | jjddddg ddd | jjdd	d
ddd | jd| j d S )Nz-rz--requirementrequirementsappendfilezjUninstall all the packages listed in the given requirements file.  This option can be used multiple times.)destactiondefaultmetavarhelpz-yz--yesyes
store_truez2Don't ask for confirmation of uninstall deletions.)r   r   r   r   )superr	   __init__cmd_opts
add_optionparserinsert_option_group)selfargskw	__class__ 5/tmp/pip-build-tlro1kwj/pip/pip/commands/uninstall.pyr      s$     	 zUninstallCommand.__init__c           
   	   C   s   |  |}tjt t }t|j|}td d d |j||d}|D ]}|	t
j||j|d qD|jD ]$}t||||dD ]}	|	|	 q|qh|jstdt| jd |j|jd W 5 Q R X d S )N)	build_dirsrc_dirdownload_dirisolatedsessionwheel_cache)r%   r'   )optionsr&   r'   zLYou must give at least one requirement to %(name)s (see "pip help %(name)s"))name)auto_confirm)_build_sessionpipindexFormatControlsetr   	cache_dirr   isolated_modeadd_requirementr   	from_liner   r   has_requirementsr   dictr)   r
   r   )
r   r(   r   r&   format_controlr'   requirement_setr)   filenamereqr    r    r!   run-   sD     


zUninstallCommand.run)
__name__
__module____qualname____doc__r)   usagesummaryr   r:   __classcell__r    r    r   r!   r	   
   s   	r	   )
__future__r   r,   	pip.wheelr   pip.reqr   r   r   pip.basecommandr   pip.exceptionsr   r	   r    r    r    r!   <module>   s   