î
½1kd€,  ã               @   sý  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z e e d d ƒ Z e e d d ƒ Z e d k rŸ e d k r� d Z qü e j	 e k s– t
 ‚ d Z n] e j	 e k r· d Z nE e d k rá e j	 e k sØ t
 ‚ d Z n e e j	 k sö t
 ‚ d Z e r e  j j e j	 d d ƒ Z n d Z y_ xX e  j e ƒ D]G Z e  j j e ƒ d	 d
 k r9e j j d  e  j j e e ƒ ƒ q9q9WWn= e k
 rÄZ z e j e j k r²‚  n  WYd d Z [ Xn Xd  d l m Z m Z m Z d  d l m Z d  d l m Z m Z d  d l m Z m  Z  m! Z! m" Z" d  d l# m$ Z$ m% Z% d  d l& m' Z' m( Z( m) Z) d  d l* Z+ e+ j, Z, d Z- d d „  Z. d d „  Z/ d d „  Z0 d d d „ Z1 d d „  Z2 Gd d „  d e3 ƒ Z4 e5 d k rùe1 ƒ  Z6 e6 rùe j6 e6 ƒ qùn  d S)é    NÚbase_prefixÚreal_prefixFTÚlibzpython-wheelsz/usr/share/python-wheelsé   z.whl)ÚInstallationErrorÚCommandErrorÚPipError)Úlogger)Úget_installed_distributionsÚget_prog)ÚgitÚ	mercurialÚ
subversionÚbazaar)ÚConfigOptionParserÚUpdatingDefaultsHelpFormatter)ÚcommandsÚget_summariesÚget_similar_commandsz1.5.4c                 s  d t  j k r d St  j d j ƒ  d d … }  t t  j d ƒ } y |  | d ‰  Wn t k
 ro d ‰  Yn Xd d „  t ƒ  Dƒ ‰ g  } y! ‡ f d	 d †  |  Dƒ d
 } Wn t k
 rÇ d } Yn Xt ƒ  } | ri| d k ró t j d ƒ n  | d k r­ˆ  j	 d ƒ r­g  } ˆ  j
 ƒ  } xU t d d ƒ D]D } | j j	 | ƒ r1| j |  d d … k r1| j | j ƒ q1q1W| r­x | D] } t | ƒ q†Wt j d ƒ q­n  t | ƒ  } | d d „  | j j Dƒ 7} d d „  |  d | d … Dƒ ‰ ‡ f d d †  | Dƒ } ‡  f d d †  | Dƒ } xÓ | D]1 }	 |	 d
 }
 |	 d rX|
 d 7}
 n  t |
 ƒ q1Wn— ˆ  j	 d ƒ s‡ˆ  j	 d ƒ rÚd d „  | j Dƒ } | j | j ƒ d d „  | Dƒ } ˆ d d „  | Dƒ 7‰ n  t d j ‡  f d d †  ˆ Dƒ ƒ ƒ t j d ƒ d S)z½Command and option completion for the main option parser (and options)
    and its subcommands (and options).

    Enable by sourcing one of the completion shell scripts (bash or zsh).
    ÚPIP_AUTO_COMPLETENÚ
COMP_WORDSr   Ú
COMP_CWORDÚ c             S   s   g  |  ] \ } } | ‘ q S© r   )Ú.0ÚcmdÚsummaryr   r   ú;/var/www/pythonscrapper/code/venv/build/pip/pip/__init__.pyú
<listcomp>[   s   	 z autocomplete.<locals>.<listcomp>c                s"   g  |  ] } | ˆ  k r | ‘ q Sr   r   )r   Úw)Úsubcommandsr   r   r   _   s   	 r   ÚhelpÚ	uninstallú-Ú
local_onlyTc             S   s7   g  |  ]- } | j  t j k r | j ƒ  | j f ‘ q Sr   )r!   ÚoptparseÚSUPPRESS_HELPÚget_opt_stringÚnargs)r   Úoptr   r   r   r   w   s   	c             S   s#   g  |  ] } | j  d  ƒ d ‘ q S)ú=r   )Úsplit)r   Úxr   r   r   r   |   s   	 c                s.   g  |  ]$ \ } } | ˆ  k r | | f ‘ q Sr   r   )r   r,   Úv)Ú	prev_optsr   r   r   }   s   	 c                s1   g  |  ]' \ } } | j  ˆ  ƒ r | | f ‘ q Sr   )Ú
startswith)r   Úkr-   )Úcurrentr   r   r      s   	 r*   z--c             S   s   g  |  ] } | j  ‘ q Sr   )Úoption_list)r   Úir   r   r   r   ‰   s   	 c             s   s"   |  ] } | D] } | Vq q d  S)Nr   )r   ÚitÚor   r   r   ú	<genexpr>‹   s    zautocomplete.<locals>.<genexpr>c             S   s.   g  |  ]$ } | j  t j k r | j ƒ  ‘ q Sr   )r!   r%   r&   r'   )r   r3   r   r   r   r   �   s   	 ú c                s%   g  |  ] } | j  ˆ  ƒ r | ‘ q Sr   )r/   )r   r,   )r1   r   r   r   �   s   	 )ÚosÚenvironr+   ÚintÚ
IndexErrorr   Úcreate_main_parserÚsysÚexitr/   Úlowerr
   ÚkeyÚappendÚprintr   ÚparserÚoption_list_allÚoption_groupsr2   Újoin)ÚcwordsÚcwordÚoptionsÚsubcommand_namerC   Ú	installedÚlcÚdistÚ
subcommandÚoptionÚ	opt_labelÚoptsr   )r1   r.   r    r   ÚautocompleteK   s\    !	+!

&rR   c              C   sö   i d d 6d d 6t  ƒ  d 6d d 6t ƒ  d 6}  t |  �  } | j ƒ  t j j t j j t j j t ƒ ƒ ƒ } d	 t	 | t
 j d  d
 … f | _ t j t j | ƒ } | j | ƒ d | _ t ƒ  } d g d d „  | Dƒ } d j | ƒ | _ | S)Nz
%prog <command> [options]ÚusageFÚadd_help_optionÚ	formatterÚglobalÚnameÚprogzpip %s from %s (python %s)é   Tr   c             S   s&   g  |  ] \ } } d  | | f ‘ q S)z%-27s %sr   )r   r3   Újr   r   r   r   ¬   s   	 z&create_main_parser.<locals>.<listcomp>Ú
)r   r   r   Údisable_interspersed_argsr8   ÚpathÚdirnameÚabspathÚ__file__Ú__version__r=   ÚversionÚ
cmdoptionsÚmake_option_groupÚgeneral_groupÚadd_option_groupÚmainr   rF   Údescription)Ú	parser_kwrC   Úpip_pkg_dirÚgen_optsÚcommand_summariesrh   r   r   r   r<   ”   s$    

* 		r<   c             C   s2  t  ƒ  } | j |  ƒ \ } } | j rZ t j j | j ƒ t j j t j ƒ t j ƒ  n  | sƒ | d d k rš t	 | ƒ d k rš | j
 ƒ  t j ƒ  n  | d j ƒ  } |  d  d  … } | j | d j ƒ  ƒ | t k r(t | ƒ } d | g } | r| j d | ƒ n  t d j | ƒ ƒ ‚ n  | | f S)Nr   r!   r   zunknown command "%s"zmaybe you meant "%s"z - )r<   Ú
parse_argsrb   r=   ÚstdoutÚwriter8   Úlinesepr>   ÚlenÚ
print_helpr?   Úremover   r   rA   r   rF   )ÚargsrC   Úgeneral_optionsÚ	args_elseÚcmd_nameÚcmd_argsÚguessÚmsgr   r   r   Ú	parseopts²   s&    			)
r{   c             C   s²   |  d  k r" t  j d d  … }  n  t ƒ  y t |  ƒ \ } } WnV t k
 r— t  j ƒ  d } t  j j d | ƒ t  j j t j	 ƒ t  j
 d ƒ Yn Xt | ƒ  } | j | ƒ S)Nr   z	ERROR: %s)r=   ÚargvrR   r{   r   Úexc_infoÚstderrro   r8   rp   r>   r   rg   )Úinitial_argsrw   rx   ÚeÚcommandr   r   r   rg   Ü   s    rg   c              C   s`   d g }  y d d l  } Wn t k
 r: |  j d ƒ Yn Xt d d g |  t j d d … ƒ S)zI
    Bootstrapping function to be called from install-pip.py script.
    Úpipr   NÚ
setuptoolsÚinstallz	--upgrader   )rƒ   ÚImportErrorrA   rg   r=   r|   )Úpkgsrƒ   r   r   r   Ú	bootstrapî   s    	r‡   c               @   sp   e  Z d  Z f  d d „ Z e j d ƒ Z e j d ƒ Z e d d d „ ƒ Z	 e
 d d	 „  ƒ Z d
 d „  Z d S)ÚFrozenRequirementc             C   s(   | |  _  | |  _ | |  _ | |  _ d  S)N)rW   ÚreqÚeditableÚcomments)ÚselfrW   r‰   rŠ   r‹   r   r   r   Ú__init__ÿ   s    			zFrozenRequirement.__init__z-r(\d+)$z-(20\d\d\d\d\d\d)$Fc             C   s6  t  j j t  j j | j ƒ ƒ } g  } d d l m } m } | j | ƒ ræ d } y | | | | ƒ }	 Wn9 t	 k
 r£ t
 j ƒ  d }
 t j d |
 ƒ d  }	 Yn X|	 d  k r t j d | ƒ | j d ƒ | j ƒ  }	 d } q n:d } | j ƒ  }	 |	 j } t | ƒ d k r'| d d d k s-t ‚ | d d } |  j j | ƒ } |  j j | ƒ } | sk| r | j d ƒ } | r˜| ƒ  j | | ƒ } n  | s¿t j d |	 ƒ | j d ƒ q | j d |	 ƒ | rè| j d ƒ } n d | j d ƒ } d } d | | |  j | ƒ f }	 n  |  | j |	 | | ƒ S)Nr   )ÚvcsÚget_src_requirementTr   zYError when trying to get requirement for VCS system %s, falling back to uneditable formatz-Could not determine repository location of %sz-## !! Could not determine repository locationFú==ú===Úsvnz(Warning: cannot find svn location for %szF## FIXME: could not find svn URL in dependency_links for this package:z3# Installing as editable to satisfy requirement %s:z{%s}z%s@%s#egg=%s)r�   r‘   )r8   r]   Únormcaser_   ÚlocationÚpip.vcsrŽ   r�   Úget_backend_namer   r=   r}   r	   ÚwarnrA   Úas_requirementÚspecsrq   ÚAssertionErrorÚ_rev_reÚsearchÚ_date_reÚget_backendÚget_locationÚgroupÚegg_nameÚproject_name)ÚclsrM   Údependency_linksÚ	find_tagsr”   r‹   rŽ   r�   rŠ   r‰   Úexr™   rb   Ú	ver_matchÚ
date_matchÚsvn_backendÚsvn_locationÚrevr   r   r   Ú	from_dist  sN    !	,	zFrozenRequirement.from_distc             C   sA   |  j  ƒ  } t j d | ƒ } | r= | d  | j ƒ  … } n  | S)Nz
-py\d\.\d$)r¡   Úrerœ   Ústart)rM   rW   Úmatchr   r   r   r¡   5  s
    zFrozenRequirement.egg_namec             C   sF   |  j  } |  j r d | } n  d j t |  j ƒ t | ƒ g ƒ d S)Nz-e %sr[   )r‰   rŠ   rF   Úlistr‹   Ústr)rŒ   r‰   r   r   r   Ú__str__=  s    		zFrozenRequirement.__str__N)Ú__name__Ú
__module__Ú__qualname__r�   r­   Úcompiler›   r�   Úclassmethodr¬   Ústaticmethodr¡   r²   r   r   r   r   rˆ   ý   s   ,rˆ   Ú__main__)7r8   r%   r=   r­   ÚerrnoÚgetattrr   r   Úin_venvÚprefixrš   r]   rF   Ú	wheel_dirÚlistdirÚfilenameÚsplitextÚinsertÚOSErrorÚerrorÚENOENTÚpip.exceptionsr   r   r   Úpip.logr	   Úpip.utilr
   r   r•   r   r   r   r   Úpip.baseparserr   r   Úpip.commandsr   r   r   Zpip.cmdoptionsr‚   rc   ra   rR   r<   r{   rg   r‡   Úobjectrˆ   r³   r>   r   r   r   r   Ú<module>   s^   				-"	I*G	