î
½1kdMG ã               @   sn  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l	 Z	 d  d l
 Z
 d  d l m Z d  d l m Z m Z m Z m Z m Z d  d l m Z m Z m Z m Z m Z m Z m Z d  d l m Z d  d l m Z d  d l m Z d  d	 l m  Z  m! Z! m" Z" m# Z# m$ Z$ m% Z% m& Z& m' Z' m( Z( m) Z) m* Z* m+ Z+ m, Z, m- Z- m. Z. m/ Z/ m0 Z0 d  d
 l1 m2 Z2 m3 Z3 m4 Z4 m5 Z5 m6 Z6 m7 Z7 m8 Z8 m9 Z9 d  d l: m; Z; d  d l m< Z< d  d l= m> Z> m? Z? m@ Z@ mA ZA mB ZB mC ZC mD ZD mE ZE mF ZF mG ZG mH ZH d  d lI ZJ d  d lI mK ZK mL ZL mM ZM d  d lN ZN d  d lO ZO d d „  ZP Gd d „  d eQ ƒ ZR Gd d „  d eQ ƒ ZS Gd d „  d eQ ƒ ZT d d „  ZU e jV d e jW ƒ ZX d d d d d d „ ZY d d „  ZZ d d „  Z[ d  d! „  Z\ d d" d# „ Z] Gd$ d% „  d% eQ ƒ Z^ Gd& d' „  d' eQ ƒ Z_ Gd( d) „  d) eQ ƒ Z` d S)*é    )Ú
FeedParserN)Úchange_root)Úbin_pyÚrunning_under_virtualenvÚPIP_DELETE_MARKER_FILENAMEÚwrite_delete_marker_fileÚbin_user)ÚInstallationErrorÚUninstallationErrorÚUnsupportedWheelÚBestVersionAlreadyInstalledÚInvalidWheelFilenameÚDistributionNotFoundÚPreviousBuildDirError)Úvcs)Úlogger)r   )Údisplay_pathÚrmtreeÚaskÚask_path_existsÚ
backup_dirÚis_installable_dirÚis_localÚdist_is_localÚdist_in_usersiteÚdist_in_site_packagesÚrenamesÚnormalize_pathÚegg_link_pathÚmake_path_relativeÚcall_subprocessÚis_prereleaseÚnormalize_name)ÚurlparseÚurllibÚuses_pycacheÚConfigParserÚstring_typesÚ	HTTPErrorÚget_python_versionÚb)ÚLink)Úbuild_prefix)Ú
PipSessionÚget_file_contentÚis_urlÚurl_to_pathÚpath_to_urlÚis_archive_fileÚunpack_vcs_linkÚ
is_vcs_urlÚis_file_urlÚunpack_file_urlÚunpack_http_url)Úmove_wheel_filesÚWheelÚ	wheel_extc             C   s•   t  |  d ƒ � } | j ƒ  } Wd QXd t j d ƒ d g } x: | D]2 } y | j | ƒ } Wn t k
 rs wC Yn XPqC Wt | ƒ t k s‘ t ‚ | S)aQ  Return the contents of *filename*.

    Try to decode the file contents with utf-8, the preffered system encoding
    (e.g., cp1252 on some Windows machines) and latin1, in that order. Decoding
    a byte string with latin1 will never raise an error. In the worst case, the
    returned string will contain some garbage characters.

    ÚrbNzutf-8FÚlatin1)	ÚopenÚreadÚlocaleÚgetpreferredencodingÚdecodeÚUnicodeDecodeErrorÚtypeÚbytesÚAssertionError)ÚfilenameÚfpÚdataÚ	encodingsÚenc© rK   ú6/var/www/pythonscrapper/code/venv/build/pip/pip/req.pyÚread_text_file(   s    	rM   c               @   se  e  Z d  Z d d d d d d d d d d d „	 Z e d d d d „ ƒ Z e d d d d	 „ ƒ Z d
 d „  Z d d „  Z d d d „ Z	 d d „  Z
 e d d „  ƒ Z e d d „  ƒ Z e d d „  ƒ Z d d d „ Z d Z d d „  Z d d „  Z d d  „  Z d! d" „  Z e d# d$ „  ƒ Z e j d% ƒ Z f  d& d' „ Z e d( d) „  ƒ Z e d* d+ „  ƒ Z d, d- „  Z d d. d/ „ Z d d0 d1 „ Z d2 d3 „  Z d4 d5 „  Z  d6 d7 „  Z! d8 d9 „  Z" f  d d: d; „ Z# d< d= „  Z$ f  d> d? „ Z% d@ dA „  Z& dB dC „  Z' e dD dE „  ƒ Z( e dF dG „  ƒ Z) dH dI „  Z* dJ dK „  Z+ d dL dM „ Z, e dN dO „  ƒ Z- d S)PÚInstallRequirementNFTc             C   sL  f  |  _  t | t ƒ r9 t j j | ƒ } | j  |  _  n  | |  _ | |  _ | |  _ | |  _	 |	 d  k rr i  }	 n  |	 |  _
 | |  _ | |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ | |  _ d  |  _ d  |  _ d |  _ d  |  _ |
 |  _ | |  _ | rd |  _ n= |  j d  k	 r?t d d „  |  j j Dƒ ƒ |  _ n	 d |  _ d  S)NFTc             S   s0   g  |  ]& } t  | d  ƒ o) | d d k ‘ q S)é   r   z!=)r!   )Ú.0ÚxrK   rK   rL   ú
<listcomp>m   s   	 z/InstallRequirement.__init__.<locals>.<listcomp>)ÚextrasÚ
isinstancer'   Úpkg_resourcesÚRequirementÚparseÚreqÚ
comes_fromÚ
source_dirÚeditableÚeditable_optionsÚurlÚas_eggÚ_egg_info_pathÚsatisfied_byÚconflicts_withÚ_temp_build_dirÚ
_is_bundleÚupdateÚinstall_succeededÚuninstalledÚuse_user_siteÚ
target_dirÚfrom_bundleÚ	pycompileÚprereleasesÚanyÚspecs)ÚselfrX   rY   rZ   r[   r]   r^   rd   rk   r\   ri   rj   rK   rK   rL   Ú__init__B   s<    																					%zInstallRequirement.__init__c       	      C   s…   t  | | ƒ \ } } } | j d ƒ r6 t | ƒ } n d  } |  | | d | d d d | d | d d ƒ} | d  k	 r� | | _ n  | S)Nzfile:rZ   r[   Tr]   r\   rk   )Úparse_editableÚ
startswithr0   rS   )	ÚclsÚeditable_reqrY   Údefault_vcsÚnamer]   Úextras_overriderZ   ÚresrK   rK   rL   Úfrom_editableq   s    	z InstallRequirement.from_editablec       	      C   sØ  d } | j  ƒ  } d } t j j t j j | ƒ ƒ } d } t | ƒ rW t | ƒ } n­ t j j | ƒ r¾ t j j | k sŠ | j	 d ƒ r¾ t
 | ƒ s© t d | ƒ ‚ n  t t | ƒ ƒ } nF t | ƒ rt j j | ƒ sï t j d | ƒ n  t t | ƒ ƒ } n  | r¹| d k r¹| j } | j } | j d k rst j d | ƒ rst t j j t j j | j ƒ ƒ ƒ } n  | j t k r¿t | j ƒ } | j ƒ  s¶t d | j ƒ ‚ q¶q¿n | } |  | | d | d	 | ƒS)
zŒCreates an InstallRequirement from a name, which might be a
        requirement, directory containing 'setup.py', filename, or URL.
        NÚ.z;Directory %r is not installable. File 'setup.py' not found.zARequirement %r looks like a filename, but the file does not existÚfilez\.\./z-%s is not a supported wheel on this platform.r]   rk   )ÚstripÚosÚpathÚnormpathÚabspathr/   r+   ÚisdirÚseprq   r   r	   r1   r2   Úisfiler   ÚwarnÚurl_without_fragmentÚegg_fragmentÚschemeÚreÚsearchÚextr:   r9   rF   Ú	supportedr   )	rr   ru   rY   rk   r]   rX   r}   ÚlinkÚwheelrK   rK   rL   Ú	from_line„   s4    3		!*zInstallRequirement.from_linec             C   sÁ   |  j  r8 t |  j  ƒ } |  j rA | d |  j 7} qA n	 |  j } |  j d  k	 rm | d t |  j j ƒ 7} n  |  j r½ t |  j t ƒ r” |  j } n |  j j	 ƒ  } | r½ | d | 7} q½ n  | S)Nz from %sz in %sz
 (from %s))
rX   Ústrr]   r`   r   ÚlocationrY   rT   r'   Ú	from_path)rn   ÚsrY   rK   rK   rL   Ú__str__¯   s    				zInstallRequirement.__str__c             C   sv   |  j  d  k r d  St |  j  ƒ } |  j rr t |  j t ƒ rI |  j } n |  j j ƒ  } | rr | d | 7} qr n  | S)Nz->)rX   rŽ   rY   rT   r'   r�   )rn   r‘   rY   rK   rK   rL   r�   Á   s    	zInstallRequirement.from_pathc             C   s    |  j  d  k	 r |  j  S|  j d  k rJ t j d d ƒ |  _  | |  _ |  j  S|  j re |  j j ƒ  } n	 |  j } t j	 j
 | ƒ s� t | ƒ n  t j	 j | | ƒ S)Nz-buildzpip-)rb   rX   ÚtempfileÚmkdtempÚ_ideal_build_dirr[   ru   Úlowerr|   r}   ÚexistsÚ_make_build_dirÚjoin)rn   Ú	build_dirÚunpackru   rK   rK   rL   Úbuild_locationÎ   s    			z!InstallRequirement.build_locationc             C   s8  |  j  d k	 r d S|  j d k	 s( t ‚ |  j s7 t ‚ |  j } |  j } |  ` |  j rj |  j j ƒ  } n	 |  j } t j	 j
 | | ƒ } t j	 j | ƒ s¸ t j d | ƒ t | ƒ n  t j	 j | ƒ rã t d t | ƒ ƒ ‚ n  t j d |  t | ƒ t | ƒ f ƒ t j | | ƒ | |  _ | |  _  d |  _ d S)zkIf the build location was a temporary directory, this will move it
        to a new more permanent locationNzCreating directory %sz<A package already exists in %s; please remove it to continuez,Moving package %s from %s to new location %s)rZ   rX   rE   rb   r•   r[   ru   r–   r|   r}   r™   r—   r   Údebugr˜   r	   r   ÚshutilÚmover_   )rn   Úold_locationÚnew_build_dirru   Únew_locationrK   rK   rL   Úcorrect_build_locationÞ   s0    							z)InstallRequirement.correct_build_locationc             C   s   |  j  d  k r d  S|  j  j S)N)rX   Úproject_name)rn   rK   rK   rL   ru   û   s    zInstallRequirement.namec             C   s&   |  j  d  k r d  St j |  j  j ƒ S)N)rX   r$   ÚquoteÚunsafe_name)rn   rK   rK   rL   Úurl_name  s    zInstallRequirement.url_namec             C   sÃ   y d d  l  } Wn t k
 r0 t d ƒ ‚ Yn Xd } |  j rt d |  j k rt t j j |  j |  j d | ƒ } n t j j |  j | ƒ } t j	 r¿ t
 | t j ƒ r¿ | j t j ƒ  ƒ } n  | S)Nr   zBsetuptools must be installed to install from a source distributionzsetup.pyÚsubdirectory)Ú
setuptoolsÚImportErrorr	   r\   r|   r}   r™   rZ   ÚsixÚPY2rT   Ú	text_typeÚencodeÚsysÚgetfilesystemencoding)rn   r©   Ú
setup_fileÚsetup_pyrK   rK   rL   r²     s    
zInstallRequirement.setup_pyc             C   sî  |  j  s t ‚ |  j r8 t j d |  j |  j f ƒ n t j d |  j |  j f ƒ t j d 7_ z>|  j d k rº t j	 j
 t j	 j |  j  d ƒ ƒ rº t t j	 j |  j  d ƒ ƒ n  |  j } | j d t |  j ƒ ƒ } | j d t |  j ƒ ƒ } t j d	 | d
 g } |  j s| r&g  } nF t j	 j |  j  d ƒ } t j	 j | ƒ s`t j | ƒ n  d d g } t | | d |  j  d |  j d d d t j d d ƒWd  t j d 8_ X|  j sêt j j d |  j ƒ  ƒ |  _ |  j ƒ  n  d  S)Nz2Running setup.py (path:%s) egg_info for package %sz7Running setup.py (path:%s) egg_info for package from %sé   Ú
distributer©   zdistribute.egg-infoÚ__SETUP_PY__Ú__PKG_NAME__z-cÚegg_infozpip-egg-infoz
--egg-baseÚcwdÚfilter_stdoutÚshow_stdoutFÚcommand_levelÚcommand_desczpython setup.py egg_infoz%(Name)s==%(Version)s)rZ   rE   ru   r   Únotifyr²   r]   Úindentr|   r}   r€   r™   r   Ú_run_setup_pyÚreplaceÚreprr¯   Ú
executabler[   r—   Úmakedirsr    Ú_filter_installÚVERBOSE_DEBUGrX   rU   rV   rW   Úpkg_infor£   )rn   Úforce_root_egg_infoÚscriptÚegg_info_cmdÚegg_base_optionÚegg_info_dirrK   rK   rL   Úrun_egg_info"  s8    	 	4		
			zInstallRequirement.run_egg_infoa}  
__file__ = __SETUP_PY__
from setuptools.command import egg_info
import pkg_resources
import os
import tokenize
def replacement_run(self):
    self.mkpath(self.egg_info)
    installer = self.distribution.fetch_build_egg
    for ep in pkg_resources.iter_entry_points('egg_info.writers'):
        # require=False is the change we're making:
        writer = ep.load(require=False)
        if writer:
            writer(self, ep.name, os.path.join(self.egg_info,ep.name))
    self.find_sources()
egg_info.egg_info.run = replacement_run
exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))
c             C   sy   |  j  d  k	 r5 |  j  j | ƒ s% d  S|  j  j | ƒ S|  j sD t ‚ |  j | ƒ } t j j | ƒ si d  St	 | ƒ } | S)N)
r`   Úhas_metadataÚget_metadatarZ   rE   Úegg_info_pathr|   r}   r—   rM   )rn   rF   rH   rK   rK   rL   Úegg_info_datac  s    z InstallRequirement.egg_info_datac                s  |  j  d  k r|  j r$ |  j } n t j j |  j d ƒ } t j | ƒ } |  j r€g  } xt j | ƒ D]ü \ ‰  } } x- t j	 D]" } | | k rƒ | j
 | ƒ qƒ qƒ Wxš t | ƒ D]Œ } t j j t j j ˆ  | d d ƒ ƒ s
t j j t j j ˆ  | d d ƒ ƒ r| j
 | ƒ n  | d k s2| d k r¶ | j
 | ƒ q¶ q¶ W| j ‡  f d d	 †  | Dƒ ƒ qj Wd
 d	 „  | Dƒ } n  | sŸt d | | f ƒ ‚ n  | s»t d | | f ƒ ‚ t | ƒ d k ræ| j d d d „  ƒ n  t j j | | d ƒ |  _  n  t j j |  j  | ƒ S)Nzpip-egg-infoÚbinÚpythonÚScriptsz
Python.exeÚtestÚtestsc                s%   g  |  ] } t  j j ˆ  | ƒ ‘ q SrK   )r|   r}   r™   )rP   Údir)ÚrootrK   rL   rR   ‡  s   	z4InstallRequirement.egg_info_path.<locals>.<listcomp>c             S   s%   g  |  ] } | j  d  ƒ r | ‘ q S)z	.egg-info)Úendswith)rP   ÚfrK   rK   rL   rR   ‰  s   	 z$No files/directories in %s (from %s)rO   Úkeyc             S   s8   |  j  t j j ƒ t j j r3 |  j  t j j ƒ p6 d S)Nr   )Úcountr|   r}   r�   Úaltsep)rQ   rK   rK   rL   Ú<lambda>“  s   z2InstallRequirement.egg_info_path.<locals>.<lambda>r   )r_   r[   rZ   r|   r}   r™   ÚlistdirÚwalkr   ÚdirnamesÚremoveÚlistr—   Úextendr	   rE   ÚlenÚsort)rn   rF   ÚbaseÚ	filenamesÚdirsÚfilesrÖ   rK   )r×   rL   rÏ   o  s6    		''z InstallRequirement.egg_info_pathc             C   so   |  j  | ƒ } | s g  Sg  } xI | j ƒ  D]; } | j ƒ  } | s, | j d ƒ rZ q, n  | j | ƒ q, W| S)Nú#)rÐ   Ú
splitlinesr{   rq   Úappend)rn   rF   rH   ÚresultÚlinerK   rK   rL   Úegg_info_lines™  s    z!InstallRequirement.egg_info_linesc             C   s^   t  ƒ  } |  j d ƒ } | sA t j d t |  j d ƒ ƒ ƒ n  | j | pP d ƒ | j ƒ  S)NzPKG-INFOzNo PKG-INFO file found in %sÚ )r   rÐ   r   rƒ   r   rÏ   ÚfeedÚclose)rn   ÚprH   rK   rK   rL   rÆ   ¥  s    	#zInstallRequirement.pkg_infoc             C   s   |  j  d ƒ S)Nzdependency_links.txt)rï   )rn   rK   rK   rL   Údependency_links­  s    z#InstallRequirement.dependency_linksz	\[(.*?)\]c             c   s…   d  } xx |  j  d ƒ D]g } |  j j | j ƒ  ƒ } | rO | j d ƒ } q n  | rx | | k rx t j d | ƒ q n  | Vq Wd  S)Nzrequires.txtrO   zskipping extra %s)rï   Ú_requirements_section_reÚmatchr–   Úgroupr   r�   )rn   rS   Úin_extrarî   rö   rK   rK   rL   Úrequirements³  s    zInstallRequirement.requirementsc             c   s5   x. |  j  j D]  \ } } | d k r | Vq q Wd  S)Nz==)rX   rm   )rn   Ú	qualifierÚversionrK   rK   rL   Úabsolute_versionsÀ  s    z$InstallRequirement.absolute_versionsc             C   s   |  j  ƒ  d S)Nrû   )rÆ   )rn   rK   rK   rL   Úinstalled_versionÆ  s    z$InstallRequirement.installed_versionc             C   sk   |  j  s t ‚ |  j } | |  j k rD t j d |  |  j f ƒ n# t j d t |  j  ƒ | |  f ƒ d  S)Nz'Requested %s, but installing version %sz;Source in %s has version %s, which satisfies requirement %s)rZ   rE   rý   rX   r   rƒ   r�   r   )rn   rû   rK   rK   rL   Úassert_source_matches_versionÊ  s    		z0InstallRequirement.assert_source_matches_versionc             C   s  |  j  s! t j d |  j ƒ d  S|  j s0 t ‚ |  j s? t ‚ |  j  j d ƒ rU d  Sd |  j  k sw t d |  j  ƒ ‚ |  j s„ d  S|  j  j d d ƒ \ } } t	 j
 | ƒ } | rï | |  j  ƒ } | rÜ | j |  j ƒ q| j |  j ƒ n d st d |  j  | f ƒ ‚ d  S)Nz>Cannot update repository at %s; repository location is unknownzfile:ú+zbad url: %rrO   r   z+Unexpected version control type (in %s): %s)r]   r   ÚinforZ   r[   rE   rq   rd   Úsplitr   Úget_backendÚobtainÚexport)rn   r  Úvc_typer]   ÚbackendÚvcs_backendrK   rK   rL   Úupdate_editableÓ  s(    	"		z"InstallRequirement.update_editablec                sq  |  j  ƒ  s% t d |  j f ƒ ‚ n  |  j p4 |  j } t | ƒ } t j j | j	 | j
 ƒ  j d ƒ d ƒ d } t j j | j	 d j | j
 ƒ  j d ƒ d d … ƒ ƒ d } | j d	 t j d
 ƒ } | j
 ƒ  d } t | ƒ } t j j | ƒ }	 t j j | ƒ }
 t j j | ƒ } |	 s'|
 r_|	 r6| } n | } | j | ƒ | j d ƒ r©x| j d ƒ j ƒ  D]4 } t j j t j j | | ƒ ƒ } | j | ƒ qnWqž| j d ƒ rž| j d ƒ rÙ| j d ƒ ‰  n g  ‰  xz ‡  f d d †  | j d ƒ j ƒ  Dƒ D]M } t j j | j	 | ƒ } | j | ƒ | j | d ƒ | j | d ƒ qWqžn?| j	 j | ƒ r¼| j | j	 ƒ t j j t j j | j	 ƒ d ƒ } | j | d | ƒ nâ | rkt | d ƒ } t j j | j ƒ  j ƒ  ƒ } | j ƒ  | | j	 k s't d | |  j | j	 f ƒ ‚ | j | ƒ t j j t j j | ƒ d ƒ } | j | | j	 ƒ n3 | ržx* t j  j! | ƒ D] } | j | ƒ q„Wn  | j d ƒ rB| j" d ƒ rBxƒ | j# d ƒ D]o } t$ | ƒ rçt% } n t& } | j t j j | | ƒ ƒ t' j( d k rÌ| j t j j | | ƒ d ƒ qÌqÌWn  | j d ƒ rWt) j* ƒ  } | j+ t, | j- d ƒ ƒ ƒ | j. d ƒ rWxÉ | j/ d ƒ D]µ \ } } t$ | ƒ r¹t% } n t& } | j t j j | | ƒ ƒ t' j( d k r˜| j t j j | | ƒ d ƒ | j t j j | | ƒ d ƒ | j t j j | | ƒ d ƒ q˜q˜WqWn  | j0 | ƒ | |  _1 d S)a¥  
        Uninstall the distribution currently satisfying this requirement.

        Prompts before removing or modifying files unless
        ``auto_confirm`` is True.

        Refuses to delete or modify files outside of ``sys.prefix`` -
        thus uninstallation within a virtual environment can only
        modify that virtual environment, even if the virtualenv is
        linked to global site-packages.

        z.Cannot uninstall requirement %s, not installedz-pyr   z	.egg-infoú-Nr³   z
.dist-infoz-py%srð   z.eggzinstalled-files.txtztop_level.txtznamespace_packages.txtc                s(   g  |  ] } | r | ˆ  k r | ‘ q SrK   rK   )rP   ró   )Ú
namespacesrK   rL   rR     s   	 z0InstallRequirement.uninstall.<locals>.<listcomp>z.pyz.pyczeasy-install.pthz./Úrz;Egg-link %s does not match installed location of %s (at %s)ÚscriptsÚwin32z.batzentry_points.txtÚconsole_scriptsz.exez.exe.manifestz
-script.py)2Úcheck_if_existsr
   ru   r`   ra   ÚUninstallPathSetr|   r}   r™   r�   Úegg_namer  rÀ   rU   ÚPY_MAJORr   r—   ÚaddrÍ   rÎ   rë   r~   rØ   ÚdirnameÚadd_pthr=   ÚnormcaseÚreadliner{   rò   rE   ÚpiprŒ   Úuninstallation_pathsÚmetadata_isdirÚmetadata_listdirr   r   r   r¯   Úplatformr&   ÚSafeConfigParserÚreadfpÚFakeFileÚget_metadata_linesÚhas_sectionÚitemsrá   rf   )rn   Úauto_confirmÚdistÚpaths_to_removeÚpip_egg_info_pathÚdist_info_pathÚdebian_egg_info_pathÚeasy_install_eggÚdevelop_egg_linkÚpip_egg_info_existsÚdebian_egg_info_existsÚdist_info_existsrÏ   Úinstalled_filer}   Útop_level_pkgÚeasy_install_pthÚfhÚlink_pointerrÈ   Úbin_dirÚconfigru   ÚvaluerK   )r
  rL   Ú	uninstallì  s–     (	!	
.		*	  -zInstallRequirement.uninstallc             C   s4   |  j  r |  j  j ƒ  n t j d |  j f ƒ d  S)Nz'Can't rollback %s, nothing uninstalled.)rf   Úrollbackr   Úerrorr¤   )rn   rK   rK   rL   Úrollback_uninstallZ  s    		z%InstallRequirement.rollback_uninstallc             C   s4   |  j  r |  j  j ƒ  n t j d |  j f ƒ d  S)Nz%Can't commit %s, nothing uninstalled.)rf   Úcommitr   r8  r¤   )rn   rK   rK   rL   Úcommit_uninstalla  s    		z#InstallRequirement.commit_uninstallc             C   s�  |  j  s t ‚ d } d |  j |  j f } t j j | | ƒ } t j j | ƒ rt d t	 | ƒ d ƒ } | d k r€ d } q| d k r³ t
 j d t	 | ƒ ƒ t j | ƒ q| d k rt | ƒ } t
 j d	 t	 | ƒ t	 | ƒ f ƒ t j | | ƒ qn  | r‰t j | d t j ƒ } t j j t j j |  j  ƒ ƒ } xt j | ƒ D]ÿ \ }	 }
 } d
 |
 k r~|
 j d
 ƒ n  xl |
 D]d } t j j |	 | ƒ } |  j | | ƒ } t j |  j d | d ƒ } d | _ | j | d ƒ q…Wxb | D]Z } | t k rqôn  t j j |	 | ƒ } |  j | | ƒ } | j | |  j d | ƒ qôWqSW| j ƒ  t
 j d 8_ t
 j d t	 | ƒ ƒ n  d  S)NTz	%s-%s.zipz/The file %s exists. (i)gnore, (w)ipe, (b)ackup ÚiÚwr*   FzDeleting %szBacking up %s to %szpip-egg-infoú/ií  é   rð   r³   zSaved %s)r<  r=  r*   i  í)rZ   rE   ru   rý   r|   r}   r™   r—   r   r   r   rƒ   rá   r   rž   rŸ   ÚzipfileÚZipFileÚZIP_DEFLATEDr  r   rß   Ú_clean_zip_nameÚZipInfoÚexternal_attrÚwritestrr   Úwriterò   r¾   r½   )rn   rš   Úcreate_archiveÚarchive_nameÚarchive_pathÚresponseÚ	dest_fileÚziprÖ   Údirpathrà   rç   r  ru   ÚzipdirrF   rK   rK   rL   Úarchiveh  sN    		!	#
zInstallRequirement.archivec             C   se   | j  | t j j ƒ s/ t d | | f ƒ ‚ | t | ƒ d d  … } | j t j j d ƒ } | S)Nz$name %r doesn't start with prefix %rrO   r>  )rq   r|   r}   r�   rE   rä   rÀ   )rn   ru   ÚprefixrK   rK   rL   rC  ‘  s
    z"InstallRequirement._clean_zip_namec                s‹  |  j  r |  j | | ƒ d  S|  j rt t j j |  j ƒ } t j j | |  j ƒ |  j	 |  j d ˆ  ƒd |  _
 d  St j d d ƒ } t j j | d ƒ } z¹t j g } | j d ƒ | j d |  j ƒ | t | ƒ d d	 | g 7} |  j s| d
 g 7} n  ˆ  d  k	 r | d ˆ  g 7} n  |  j r9| d g 7} n | d g 7} t ƒ  r�| d t j j t j d d d t ƒ  ƒ g 7} n  t j d |  j ƒ t j d 7_ z* t | | d |  j d |  j d d ƒWd  t j d 8_ Xt j j | ƒ st j d | ƒ d  Sd |  _
 |  j rd  S‡  f d d †  } t  | ƒ }	 xN |	 D]1 }
 |
 j! ƒ  }
 |
 j" d ƒ rC| |
 ƒ } PqCqCWt j# d |  ƒ d  S|	 j$ ƒ  g  } t  | ƒ }	 x[ |	 D]S }
 |
 j! ƒ  } t j j% | ƒ rç| t j j& 7} n  | j t' | | ƒ | ƒ ƒ q°W|	 j$ ƒ  t  t j j | d ƒ d ƒ }	 |	 j( d j | ƒ d ƒ |	 j$ ƒ  Wd  t j j | ƒ ryt j) | ƒ n  t j* | ƒ Xd  S) Nr×   Tz-recordzpip-zinstall-record.txtz-cz�import setuptools, tokenize;__file__=%r;exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))Úinstallz--recordz#--single-version-externally-managedz--rootz	--compilez--no-compilez--install-headersÚincludeÚsiterÒ   zRunning setup.py install for %sr³   r¸   r¹   rº   FzRecord file %s not foundc                s4   ˆ  d  k s t  j j |  ƒ r# |  St ˆ  |  ƒ Sd  S)N)r|   r}   Úisabsr   )r}   )r×   rK   rL   Úprepend_rootÏ  s    z0InstallRequirement.install.<locals>.prepend_rootz	.egg-infoz;Could not find .egg-info directory in install record for %szinstalled-files.txtr=  Ú
)+r[   Úinstall_editableÚis_wheelr  rŒ   Úwheel_versionrZ   Úcheck_compatibilityru   r8   re   r“   r”   r|   r}   r™   r¯   rÂ   rì   r²   râ   r^   rj   r   rQ  r)   r   r½   r¾   r    rÄ   r—   r=   r{   rØ   rƒ   rò   r€   r�   r   rG  rá   Úrmdir)rn   Úinstall_optionsÚglobal_optionsr×   rû   Útemp_locationÚrecord_filenameÚinstall_argsrV  rÙ   rî   rË   Ú	new_linesrF   rK   )r×   rL   rR  ˜  s‚    								
 
zInstallRequirement.installc             C   s’   |  j  s t j j |  j ƒ rW t j d |  j ƒ |  j rK t |  j ƒ n  d |  _ n  |  j	 r… t j j |  j	 ƒ r… t |  j	 ƒ n  d |  _	 d S)zVRemove the source files from this requirement, if they are marked
        for deletionzRemoving source in %sN)
Ú	is_bundler|   r}   r—   Údelete_marker_filenamer   r   rZ   r   rb   )rn   rK   rK   rL   Úremove_temporary_sourceñ  s    	z*InstallRequirement.remove_temporary_sourcec             C   sš   t  j d |  j ƒ t  j d 7_ zW t t j d d |  j g t | ƒ d d g t | ƒ d |  j	 d |  j
 d	 d
 ƒWd  t  j d 8_ Xd |  _ d  S)NzRunning setup.py develop for %sr³   z-cz‘import setuptools, tokenize; __file__=%r; exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))Údevelopz	--no-depsr¸   r¹   rº   FT)r   r½   ru   r¾   r    r¯   rÂ   r²   râ   rZ   rÄ   re   )rn   r]  r^  rK   rK   rL   rX  ý  s    7z#InstallRequirement.install_editablec             C   sa   t  j } xK d d d d d d d d g D]+ } t j | | j ƒ  ƒ r( t  j } Pq( q( W| | f S)	Nz^running .*z^writing .*z^creating .*z^[Cc]opying .*z^reading .*z4^removing .*\.egg-info' \(and everything under it\)$z^byte-compiling z7^warning: manifest_maker: standard file '-c' not found$)r   ÚNOTIFYr‡   rˆ   r{   ÚINFO)rn   rî   ÚlevelÚregexrK   rK   rL   rÄ     s    		z"InstallRequirement._filter_installc             C   s  |  j  d k r d SyJ |  j  j d k rG |  j rG |  j j d k rG d St j |  j  ƒ |  _ Wn£ t j k
 rx d SYn‹ t j k
 rt j |  j  j ƒ } |  j rõ t	 | ƒ r¾ | |  _ qþ t
 ƒ  rþ t | ƒ rþ t d | j | j f ƒ ‚ qþ n	 | |  _ Yn Xd S)z¡Find an installed distribution that satisfies or conflicts
        with this requirement, and set self.satisfied_by or
        self.conflicts_with appropriately.NFr©   r´   TzVWill not install to the user site because it will lack sys.path precedence to %s in %s)rX   r¤   ra   rU   Úget_distributionr`   r   ÚVersionConflictrg   r   r   r   r	   r�   )rn   Úexisting_distrK   rK   rL   r    s(    		z"InstallRequirement.check_if_existsc             C   s   |  j  o d |  j  k S)Nz.whl)r]   )rn   rK   rK   rL   rY  :  s    zInstallRequirement.is_wheelc             C   su   |  j  d  k	 r |  j  S|  j } | s) d St j j t j j | d ƒ ƒ ph t j j t j j | d ƒ ƒ |  _  |  j  S)NFzpip-manifest.txtzpyinstall-manifest.txt)rc   rb   r|   r}   r—   r™   )rn   ræ   rK   rK   rL   rc  >  s    	!$zInstallRequirement.is_bundlec       
      c   sG  x |  j  D]õ } t j j | ƒ } xŒ t j D]� } d  } } t j j | | j ƒ } t j j | ƒ r, | j	 } t
 | ƒ } | j ƒ  }	 | j ƒ  | ƒ  j |	 ƒ \ } } Pq, q, W| rÍ d | | | f } n d  } t | |  d d d | d d d | d d ƒVq
 Wx= |  j D]2 } t j j | ƒ } t | |  d | d d ƒVqWd  S)	Nz%s+%s@%sr[   Tr]   rd   FrZ   ri   )Ú_bundle_editable_dirsr|   r}   Úbasenamer   Úbackendsr™   Úbundle_filer—   ru   r=   r>   rò   Úparse_vcs_bundle_filerN   Ú_bundle_build_dirs)
rn   Údest_dirÚpackager  r]   ÚrevÚvcs_bundle_filer  rG   ÚcontentrK   rK   rL   Úbundle_requirementsJ  s,    
		
z&InstallRequirement.bundle_requirementsc             C   s�  |  j  } | s t ‚ t j j | d ƒ } t j j | d ƒ } g  } g  } x#| | | f | | | f g D]\ } }	 }
 t j j | ƒ rj x½ t j | ƒ D]¬ } t j j |	 | ƒ } |
 j | ƒ t j j | ƒ rõ t j	 d | | |  f ƒ q› n  t j j |	 ƒ s(t j
 d |	 ƒ t j |	 ƒ n  t j t j j | | ƒ | ƒ q› Wt j | ƒ smt j | ƒ qmqj qj Wd  |  _  | |  _ | |  _ d  S)NÚsrcÚbuildzZThe directory %s (containing package %s) already exists; cannot move source from bundle %szCreating directory %s)rb   rE   r|   r}   r™   r—   rÞ   rì   r   rƒ   r   rÃ   rž   rŸ   r\  rs  rn  )rn   Údest_build_dirÚdest_src_dirræ   Úsrc_dirrš   Úbundle_build_dirsÚbundle_editable_dirsrZ   rt  Údir_collectionr  ÚdestrK   rK   rL   Úmove_bundle_filesd  s4    		#		z$InstallRequirement.move_bundle_filesc             C   s;   t  |  j |  j | d |  j d |  j d | d |  j ƒd  S)NÚuserÚhomer×   rj   )r8   ru   rX   rg   rh   rj   )rn   Úwheeldirr×   rK   rK   rL   r8   €  s    		z#InstallRequirement.move_wheel_filesc             C   s%   |  j  s t ‚ t j j |  j  t ƒ S)N)rZ   rE   r|   r}   r™   r   )rn   rK   rK   rL   rd  ‰  s    z)InstallRequirement.delete_marker_filename).Ú__name__Ú
__module__Ú__qualname__ro   Úclassmethodrx   r�   r’   r�   rœ   r£   Úpropertyru   r§   r²   rÌ   r¿   rÐ   rÏ   rï   rÆ   rô   r‡   Úcompilerõ   rù   rü   rý   rþ   r  r6  r9  r;  rP  rC  rR  re  rX  rÄ   r  rY  rc  ry  rƒ  r8   rd  rK   rK   rK   rL   rN   @   sV   -*?*	n)Y!	rN   c               @   sd   e  Z d  Z d d „  Z d d „  Z d d „  Z d d „  Z d	 d
 „  Z d d „  Z d d „  Z	 d S)ÚRequirementsc             C   s   g  |  _  i  |  _ d  S)N)Ú_keysÚ_dict)rn   rK   rK   rL   ro   ‘  s    	zRequirements.__init__c             C   s   |  j  S)N)rŽ  )rn   rK   rK   rL   Úkeys•  s    zRequirements.keysc                s   ‡  f d d †  ˆ  j  Dƒ S)Nc                s   g  |  ] } ˆ  j  | ‘ q SrK   )r�  )rP   rÚ   )rn   rK   rL   rR   ™  s   	 z'Requirements.values.<locals>.<listcomp>)rŽ  )rn   rK   )rn   rL   Úvalues˜  s    zRequirements.valuesc             C   s   | |  j  k S)N)rŽ  )rn   ÚitemrK   rK   rL   Ú__contains__›  s    zRequirements.__contains__c             C   s3   | |  j  k r" |  j  j | ƒ n  | |  j | <d  S)N)rŽ  rì   r�  )rn   rÚ   r5  rK   rK   rL   Ú__setitem__ž  s    zRequirements.__setitem__c             C   s   |  j  | S)N)r�  )rn   rÚ   rK   rK   rL   Ú__getitem__£  s    zRequirements.__getitem__c                s0   ‡  f d d †  ˆ  j  ƒ  Dƒ } d d j | ƒ S)Nc                s0   g  |  ]& } d  t  | ƒ t  ˆ  | ƒ f ‘ q S)z%s: %s)rÁ   )rP   Úk)rn   rK   rL   rR   §  s   	 z)Requirements.__repr__.<locals>.<listcomp>zRequirements({%s})z, )r�  r™   )rn   r‘  rK   )rn   rL   Ú__repr__¦  s    zRequirements.__repr__N)
r‡  rˆ  r‰  ro   r�  r‘  r“  r”  r•  r—  rK   rK   rK   rL   r�  �  s   r�  c               @   sB  e  Z d  Z d d d d d d d d d d d d d „ Z d d „  Z d d	 „  Z d
 d „  Z e d d „  ƒ Z e d d „  ƒ Z	 e d d „  ƒ Z
 d d „  Z d d d „ Z d d „  Z d d d d „ Z d d d „ Z d d „  Z d d „  Z d d d  d! „ Z f  d" d# „ Z d$ d% „  Z d& Z d' d( „  Z d) d* „  Z d S)+ÚRequirementSetNFTc             C   sß   | |  _  | |  _ | |  _ | r6 t j j | ƒ } n  | |  _ | |  _ | |  _ |
 |  _	 t
 ƒ  |  _ i  |  _ g  |  _ |	 |  _ g  |  _ g  |  _ g  |  _ | |  _ | |  _ | |  _ | pÃ t ƒ  |  _ | |  _ | |  _ d  S)N)rš   r~  Údownload_dirr|   r}   Ú
expanduserÚdownload_cacheÚupgradeÚignore_installedÚforce_reinstallr�  rù   Úrequirement_aliasesÚunnamed_requirementsÚignore_dependenciesÚsuccessfully_downloadedÚsuccessfully_installedÚreqs_to_cleanupr^   rg   rh   r-   Úsessionrj   Úwheel_download_dir)rn   rš   r~  r™  r›  rœ  r�  r^   rh   r¡  rž  rg   r¥  rj   r¦  rK   rK   rL   ro   ­  s,    																	zRequirementSet.__init__c             C   sL   d d „  |  j  j ƒ  Dƒ } | j d d d „  ƒ d j d d „  | Dƒ ƒ S)Nc             S   s   g  |  ] } | j  s | ‘ q SrK   )rY   )rP   rX   rK   rK   rL   rR   Ë  s   	 z*RequirementSet.__str__.<locals>.<listcomp>rÚ   c             S   s   |  j  j ƒ  S)N)ru   r–   )rX   rK   rK   rL   rÝ   Í  s    z(RequirementSet.__str__.<locals>.<lambda>ú c             S   s   g  |  ] } t  | j ƒ ‘ q SrK   )rŽ   rX   )rP   rX   rK   rK   rL   rR   Î  s   	 )rù   r‘  rå   r™   )rn   ÚreqsrK   rK   rL   r’   Ê  s    zRequirementSet.__str__c             C   s¿   | j  } |  j | _ |  j | _ |  j | _ |  j | _ | sR |  j j | ƒ ni |  j | ƒ r† t d | |  j	 | ƒ | f ƒ ‚ n  | |  j
 | <| j ƒ  | k r» | |  j | j ƒ  <n  d  S)Nz5Double requirement given: %s (already in %s, name=%r))ru   r^   rg   rh   rj   r   rì   Úhas_requirementr	   Úget_requirementrù   r–   rŸ  )rn   Úinstall_reqru   rK   rK   rL   Úadd_requirementÐ  s    	zRequirementSet.add_requirementc             C   sC   x< | | j  ƒ  f D]( } | |  j k s7 | |  j k r d Sq Wd S)NTF)r–   rù   rŸ  )rn   r¤   ru   rK   rK   rL   r©  ã  s    zRequirementSet.has_requirementc             C   s   t  |  j j ƒ  ƒ p |  j S)N)râ   rù   r‘  r   )rn   rK   rK   rL   Úhas_requirementsé  s    zRequirementSet.has_requirementsc             C   sJ   t  d d „  |  j j ƒ  Dƒ ƒ r& d St  d d „  |  j Dƒ ƒ rF d Sd S)Nc             s   s   |  ] } | j  Vq d  S)N)r[   )rP   rX   rK   rK   rL   ú	<genexpr>ï  s    z/RequirementSet.has_editables.<locals>.<genexpr>Tc             s   s   |  ] } | j  Vq d  S)N)r[   )rP   rX   rK   rK   rL   r®  ñ  s    F)rl   rù   r‘  r   )rn   rK   rK   rL   Úhas_editablesí  s
    "zRequirementSet.has_editablesc             C   sg   |  j  rc t j j |  j  ƒ |  _  t j j |  j  ƒ r: d St j d ƒ t d t |  j  ƒ ƒ ‚ n  d S)NTz!Could not find download directoryz0Could not find or access download directory '%s'F)	r™  r|   r}   rš  r—   r   Úfatalr	   r   )rn   rK   rK   rL   Úis_downloadõ  s    	zRequirementSet.is_downloadc             C   sl   xU | | j  ƒ  f D]A } | |  j k r3 |  j | S| |  j k r |  j |  j | Sq Wt d | ƒ ‚ d  S)NzNo project with the name %r)r–   rù   rŸ  ÚKeyError)rn   r¤   ru   rK   rK   rL   rª    s    zRequirementSet.get_requirementc             C   s8   x1 |  j  j ƒ  D]  } | j d | ƒ | j ƒ  q Wd  S)Nr#  )rù   r‘  r6  r;  )rn   r#  rX   rK   rK   rL   r6  
  s    zRequirementSet.uninstallc             C   sŽ  t  |  j ƒ } t  |  j j ƒ  ƒ } xc| s3 | r‰| rK | j d ƒ } n | j d ƒ } d } |  j rí | j rí | j ƒ  | j rÍ |  j	 rÄ |  j
 o¦ t | j ƒ s¸ | j | _ n  d  | _ qÍ d } n  | j rí t j d | ƒ qí n  | j r | j d  k rE| j |  j ƒ | _ qEn% | rE| j |  j |  j ƒ | _ n  | j d  k	 r' t j j | j ƒ r' t d | | j f ƒ ‚ q' q' Wd  S)Nr   TFz<Requirement already satisfied (use --upgrade to upgrade): %sz¨Could not install requirement %s because source folder %s does not exist (perhaps --no-download was used without first running an equivalent install with --no-install?))râ   r   rù   r‘  Úpopr�  r[   r  r`   rœ  rg   r   ra   r   r½   rZ   rœ   r~  rš   r±  r|   r}   r€   r	   )rn   Úunnamedr¨  Úreq_to_installÚinstall_neededrK   rK   rL   Úlocate_files  s4    
						%zRequirementSet.locate_filesc          (   C   s«  t  |  j ƒ } t  |  j j ƒ  ƒ } x€| s3 | r¦| rK | j d ƒ } n | j d ƒ } d } d } d }	 |  j rš| j rš| j ƒ  | j r`|  j	 rW|  j
 r| j ry | j | |  j	 ƒ }
 Wn? t k
 ré d } d } Yqt k
 r
t j ƒ  d }	 YqX|
 j | _ n  | s]|  j o6t | j ƒ sH| j | _ n  d | _ q]q`d } n  | j rš| rƒt j d | ƒ q—t j d | ƒ qšn  | j r·t j d | ƒ n^ | r| j r| j j ƒ  j d	 ƒ rt j d
 t t | j ƒ ƒ ƒ qt j d | ƒ n  t j d 7_ zld } d } | j rÛ| j d k ri| j |  j ƒ } | | _ n	 | j } t j j  |  j! ƒ s—t" |  j! ƒ n  | j# |  j$ ƒ |  j$ rÎ| j% ƒ  | j& |  j' ƒ q1| j% ƒ  nV| r1| j |  j! |  j$ ƒ } d } d }
 | j( rnWt j j  t j j) | d ƒ ƒ rUt* t+ j, d | | f ƒ ƒ ‚ n| j d k rŽ|	 rs|	 ‚ n  | j | d |  j	 ƒ}
 n t- | j ƒ }
 |
 s©t. ‚ |
 rcyY |
 j/ j0 t1 ƒ rß|  j2 rß|  j2 } d } n |  j' } |  j$ } |  j3 |
 | | | ƒ Wqit4 k
 r_} z5 t j5 d | | f ƒ t6 d | | |
 f ƒ ‚ WYd d } ~ XqiXn d } | r1| j7 } |
 o�|
 j/ j0 t1 ƒ } | rà| j8 |  j! |  j ƒ xý | j9 ƒ  D]  } | j: | ƒ |  j; | ƒ q¹WnÌ |  j$ r3| | _ | s| j% ƒ  n  |
 r¬|
 j< t= j> k r¬| j& |  j' ƒ q¬ny | rQ| | _ |
 j | _ n[ | | _ | j% ƒ  | r}| j% d d ƒ n  | j? ƒ  | r¬| j r¬|  j@ | ƒ d } n  |  j sÂ| j ƒ  n  | j r.|  j	 sÝ|  j r|  j oót | j ƒ s| j | _ n  d | _ q+t j d | ƒ d } q.q1n  | rët  tA jB | ƒ ƒ d } | jC sx| jD ƒ  | _C |  j; | ƒ n  |  jE sxd | jF | jG ƒ D]M } |  jH | jI ƒ r²q”n  tJ tK | ƒ | ƒ } | j: | ƒ |  j; | ƒ q”Wqn&| s| jL | jM ƒ | jG r*t j d d j) | jG ƒ ƒ n  |  jE sìx¶ | j | jG ƒ D]Ÿ } y tA jN jO | ƒ jI } Wn? tP k
 r¦t j ƒ  d } t jQ d | | | f ƒ wFYn X|  jH | ƒ r¼qFn  tJ | | ƒ } | j: | ƒ |  j; | ƒ qFWn  |  jH | jR ƒ s|  j; | ƒ qn  | sE|  j$ s/| jS d k	 rE|  jT j: | ƒ qEn  | r�|  jU j: | ƒ | r�| j r�| j j d ƒ r�|  j@ | ƒ q�n  Wd t j d 8_ Xq' Wd S)zGPrepare process. Create temp directories, download and/or unpack files.r   TFNrO   z"Requirement already up-to-date: %sz<Requirement already satisfied (use --upgrade to upgrade): %szObtaining %szfile:zUnpacking %szDownloading/unpacking %sr³   zsetup.pya‘  
                          pip can't proceed with requirement '%s' due to a pre-existing build directory.
                           location: %s
                          This is likely due to a previous installation that failed.
                          pip is being responsible and not assuming it can delete this.
                          Please delete it and try again.
                        rœ  z4Could not install requirement %s because of error %szDCould not install requirement %s because of HTTP error %s for URL %srÇ   z!Installing extra requirements: %rú,z.Invalid requirement: %r (%s) in requirement %szfile:///)Vrâ   r   rù   r‘  r³  r�  r[   r  r`   rœ  rž  r]   Úfind_requirementr   r   r¯   Úexc_inforg   r   ra   r   r½   r–   rq   r   r0   r¾   rZ   rœ   r~  r|   r}   r—   rš   r˜   r  r±  rÌ   rP  r™  ri   r™   r   ÚtextwrapÚdedentr+   rE   rF   rØ   r:   r¦  Ú
unpack_urlr(   r°  r	   rc  rƒ  ry  rì   r¬  r†   r   Úall_schemesrþ   Úcopy_to_build_dirrU   Úfind_distributionsrX   Úas_requirementr¡  ÚrequiresrS   r©  r¤   rN   rŽ   Úadd_dependency_linksrô   rV   rW   Ú
ValueErrorr8  ru   rb   r¤  r¢  )rn   ÚfinderrÇ   Úbundler´  r¨  rµ  rR  Úbest_installedÚ	not_foundr]   rc  rY  r�   r›   r™  Údo_downloadÚexcÚeÚsubreqr$  rX   ru   rK   rK   rL   Úprepare_files6  sV   
		
					!#			
	!								)					

								 		!zRequirementSet.prepare_filesc             C   sÌ   t  j d ƒ t  j d 7_ x |  j D] } | j ƒ  q& Wg  } |  j ƒ  r_ | j |  j ƒ n  | rx | j |  j ƒ n  x> | D]6 } t	 j
 j | ƒ r t  j d | ƒ t | ƒ q q Wt  j d 8_ d S)zClean up files, remove builds.zCleaning up...r³   zRemoving temporary dir %s...N)r   r½   r¾   r¤  re  Ú_pip_has_created_build_dirrì   rš   r~  r|   r}   r—   r   r   )rn   rÆ  rX   Ú
remove_dirrÖ   rK   rK   rL   Úcleanup_files#  s    zRequirementSet.cleanup_filesc             C   s1   |  j  t k o0 t j j t j j |  j  t ƒ ƒ S)N)rš   r,   r|   r}   r—   r™   r   )rn   rK   rK   rL   rÎ  :  s    z)RequirementSet._pip_has_created_build_dirc             C   s‡   | j  r |  j p |  j } t j d | j | f ƒ t j j | | j ƒ } t	 j
 | j | ƒ t d d | d g d | d d ƒd  S)NzCopying %s to %srÒ   z%s/setup.pyÚcleanr¸   r¼   zpython setup.py clean)r[   r~  rš   r   r   ru   r|   r}   r™   rž   ÚcopytreerZ   r    )rn   rµ  rh   r‚  rK   rK   rL   r¿  >  s    z RequirementSet.copy_to_build_dirc             C   s±   | d  k r |  j  } n  t | ƒ rL | r3 | } n | } t | | | ƒ na t | ƒ r~ t | | | ƒ | r­ t | ƒ q­ n/ t | | |  j | |  j ƒ | r­ t | ƒ n  d  S)N)	r™  r4   r3   r5   r6   r   r7   r›  r¥  )rn   r‹   r�   r™  Úonly_downloadÚlocrK   rK   rL   r½  F  s&    	
zRequirementSet.unpack_urlc          "   O   s  d d „  |  j  j ƒ  Dƒ } t j j d ƒ } xI | D]A } | j d k r5 | j | k r5 | j | ƒ | j | ƒ q5 q5 W| rª t	 j
 d d j d d „  | Dƒ ƒ ƒ n  t	 j d 7_ zCx<| D]4} | j d	 k r0y= t j j d
 ƒ }	 t j d ƒ }
 |
 |	 k r|
 | _ n  Wq0t j k
 r,Yq0Xn  | j r†t	 j
 d | j ƒ t	 j d 7_ z | j d d ƒ Wd t	 j d 8_ Xn  y | j | | | | Ž Wn+ | j rÆ| j rÆ| j ƒ  n  ‚  Yn  X| j rí| j rí| j ƒ  n  | j ƒ  qÃ WWd t	 j d 8_ X| |  _ d S)zRInstall everything in this set (after having downloaded and unpacked the packages)c             S   s   g  |  ] } | j  s | ‘ q SrK   )r`   )rP   r  rK   rK   rL   rR   g  s   	 z*RequirementSet.install.<locals>.<listcomp>zdistribute>=0.7r´   z!Installing collected packages: %sz, c             S   s   g  |  ] } | j  ‘ q SrK   )ru   )rP   rX   rK   rK   rL   rR   w  s   	 r³   r©   zdistribute<0.7zFound existing installation: %sr#  TN)rù   r‘  rU   rV   rW   ru   rý   rá   rì   r   r½   r™   r¾   rk  ra   r   r6  rR  re   r9  r;  re  r£  )rn   r]  r^  ÚargsÚkwargsÚ
to_installÚdistribute_reqrX   ÚrequirementÚdistribute_requirementÚexisting_distributerK   rK   rL   rR  e  sJ    	*		zRequirementSet.installc             C   s�  t  j | d t  j ƒ } g  } xJ|  j d f |  j d f f D]*\ } } t j j t j j | ƒ ƒ } xýt j	 | ƒ D]ì\ } } } xÀ t
 j D]µ }	 |	 ƒ  }
 d  } } |
 j | k r� xR | D] } | j | ƒ r¿ Pq¿ q¿ W|
 j t j j | | ƒ ƒ \ } } | j | ƒ |
 j } |
 j i | d 6| d 6} | j |
 j ƒ Pq� q� Wd | k re| j d ƒ n  xQ | D]I } t j j | | ƒ } |  j | | ƒ } | j | d | d d ƒ qlWx_ | D]W } | t k rØqÀn  t j j | | ƒ } |  j | | ƒ } | j | | d | ƒ qÀW| rw t j j | | ƒ } |  j | | ƒ } | j | d | | ƒ qw qw Wq= W| j d	 |  j ƒ  ƒ | j ƒ  d  S)
Nr=  r{  rz  r]   rv  zpip-egg-infor>  rð   zpip-manifest.txt)r@  rA  rB  rš   r~  r|   r}   r  r   rß   r   rp  r  rq   Úget_infor™   rì   rq  Úguiderá   rC  rF  r   rG  ry  rò   )rn   Úbundle_filenamerM  Úvcs_dirsrÖ   ro  rN  rà   rç   r  r  Úvcs_urlÚvcs_revÚvcs_dirrw  Ú	vcs_guider  ru   rF   rK   rK   rL   Úcreate_bundleª  sL    +	
	 #zRequirementSet.create_bundlezÝ# This is a pip bundle file, that contains many source packages
# that can be installed as a group.  You can install this like:
#     pip this_file.zip
# The rest of the file contains a list of all the packages included:
c             C   s®   |  j  g } xA d d „  |  j j ƒ  Dƒ D]# } | j d | j | j f ƒ q) W| j d ƒ xA d d „  |  j j ƒ  Dƒ D]# } | j d | j | j f ƒ qz Wd j | ƒ S)Nc             S   s   g  |  ] } | j  s | ‘ q SrK   )rY   )rP   rX   rK   rK   rL   rR   å  s   	 z6RequirementSet.bundle_requirements.<locals>.<listcomp>z%s==%s
zC# These packages were installed to satisfy the above requirements:
c             S   s   g  |  ] } | j  r | ‘ q SrK   )rY   )rP   rX   rK   rK   rL   rR   é  s   	 rð   )ÚBUNDLE_HEADERrù   r‘  rì   ru   rý   r™   )rn   ÚpartsrX   rK   rK   rL   ry  ã  s    #!#!z"RequirementSet.bundle_requirementsc             C   se   | j  | t j j ƒ s/ t d | | f ƒ ‚ | t | ƒ d d  … } | j t j j d ƒ } | S)Nz$name %r doesn't start with prefix %rrO   r>  )rq   r|   r}   r�   rE   rä   rÀ   )rn   ru   rQ  rK   rK   rL   rC  ï  s
    zRequirementSet._clean_zip_name)r‡  rˆ  r‰  ro   r’   r¬  r©  r‹  r­  r¯  r±  rª  r6  r·  rÍ  rÐ  rÎ  r¿  r½  rR  rä  rå  ry  rC  rK   rK   rK   rL   r˜  «  s2   		'íE7r˜  c             C   s   t  j |  ƒ t |  ƒ d  S)N)r|   rÃ   r   )rš   rK   rK   rL   r˜   ÷  s    r˜   z^(http|https|file):c          
   c   s  | d  k r t  ƒ  } n  d  } | r- | j n d  } | rK t j | ƒ } n  t j j t j j |  ƒ ƒ } t |  d | d | ƒ\ }  } xzt	 | j
 ƒ  ƒ D]f\ }	 }
 |	 d 7}	 |
 j ƒ  }
 t j d d |
 ƒ }
 |
 sš |
 j d ƒ rí qš n  | r| j |
 ƒ rqš n  |
 j d ƒ s&|
 j d ƒ rþ|
 j d ƒ rN|
 d	 d  … j ƒ  } n% |
 t d ƒ d  … j ƒ  j d
 ƒ } t j |  ƒ r—t j |  | ƒ } n3 t j | ƒ sÊt j j t j j |  ƒ | ƒ } n  x3t | | d |  d | d | ƒD] } | VqìWqš |
 j d ƒ s |
 j d ƒ rqš |
 j d ƒ s=|
 j d ƒ rÖ|
 j d ƒ re|
 d	 d  … j ƒ  }
 n% |
 t d ƒ d  … j ƒ  j d
 ƒ }
 t j j | |
 ƒ } t j j | ƒ rº| }
 n  | r | j j |
 ƒ q qš |
 j d ƒ sô|
 j d ƒ rY|
 j d ƒ r|
 d	 d  … j ƒ  }
 n% |
 t d ƒ d  … j ƒ  j d
 ƒ }
 | r |
 g | _ q qš |
 j d ƒ r©|
 t d ƒ d  … j ƒ  j d
 ƒ }
 | r | j j |
 ƒ q qš |
 j d ƒ rÄd | _ qš |
 j d ƒ rßg  | _ qš |
 j d ƒ r:|
 t d ƒ d  … j ƒ  j d
 ƒ }
 | j t t |
 ƒ j ƒ  g ƒ O_ qš |
 j d ƒ rUd | _ qš |
 j d ƒ rgqš |
 j d ƒ ryqš |
 j d ƒ rÔ|
 t d ƒ d  … j ƒ  j d
 ƒ }
 | j  t t |
 ƒ j ƒ  g ƒ O_  qš |
 j d ƒ r/|
 t d ƒ d  … j ƒ  j d
 ƒ }
 | j  t t |
 ƒ j ƒ  g ƒ O_  qš d |  |	 f } |
 j d ƒ s]|
 j d ƒ r×|
 j d ƒ r…|
 d	 d  … j ƒ  }
 n% |
 t d ƒ d  … j ƒ  j d
 ƒ }
 t! j" |
 d | d | rË| j# n d  ƒ} n$ t! j$ |
 | d  t% | d! d  ƒ ƒ} | Vqš Wd  S)"NrY   r¥  rO   z
(^|\s)#.*$rð   rê   z-rz--requirementr³   ú=Úoptionsz-Zz--always-unzipz-fz--find-linksz-iz--index-urlz--extra-index-urlz--use-wheelTz
--no-indexz--allow-externalz--allow-all-externalz--no-allow-externalz--no-allow-insecurez--allow-insecurez--allow-unverifiedz-r %s (line %s)z-ez
--editablert   rk   Úpre)&r-   Úskip_requirements_regexr‡   rŒ  r|   r}   r  r   r.   Ú	enumeraterë   r{   Úsubrq   rˆ   rä   Ú
_scheme_rer#   Úurljoinr™   Úparse_requirementsÚlstripr—   Ú
find_linksrì   Ú
index_urlsÚ	use_wheelÚallow_externalÚsetr"   r–   Úallow_all_externalÚallow_unverifiedrN   rx   rt   r�   Úgetattr)rF   rÅ  rY   rè  r¥  Ú
skip_matchÚ
skip_regexÚreqs_file_dirrx  Úline_numberrî   Úreq_urlr’  Úrelative_to_reqs_filerX   rK   rK   rL   rï  ÿ  sš    	
%$(%	%%%'%'%'%'$rï  c             C   s.   t  j d |  ƒ } | r* | j d ƒ }  n  |  S)z2
        Strip req postfix ( -dev, 0.2, etc )
    z^(.*?)(?:-dev|-\d.*)$rO   )r‡   rˆ   r÷   )rX   rö   rK   rK   rL   Ú_strip_postfixc  s    rÿ  c             C   sp   d d „  |  j  d d ƒ d j  d ƒ Dƒ } d  } | d d k rO | d } n | d d k rl | d } n  | S)Nc             S   s   g  |  ] } | r | ‘ q SrK   rK   )rP   ró   rK   rK   rL   rR   p  s   	 z'_build_req_from_url.<locals>.<listcomp>rê   rO   r   r>  r³   ÚtagsÚbranchesÚtagÚbranché   Útrunkéþÿÿÿ)ztagszbranchesztagzbranchéýÿÿÿéÿÿÿÿr  )r  )r]   ræ  rX   rK   rK   rL   Ú_build_req_from_urln  s    ,r	  c             C   s{   t  j d ƒ } | j |  ƒ } | rw t ƒ  } xC | D]; } | \ } } | | k re t d | ƒ ‚ n  | | | <q4 W| Sd S)zz
        This method generates a dictionary of the query string
        parameters contained in a given editable URL.
    z([\?#&](?P<name>[^&=]+)=(?P<value>[^&=]+)z%s option already definedN)r‡   rŒ  ÚfindallÚdictÚ	Exception)rX   ÚregexpÚmatchedÚretÚoptionru   r5  rK   rK   rL   Ú_build_editable_optionsy  s    	r  c             C   sm  |  } d } t  j d | ƒ } | rE | j d ƒ } | j d ƒ } n | } t j j | ƒ r  t j j t j j | d ƒ ƒ s‘ t d | ƒ ‚ n  t	 | ƒ } n  | j
 ƒ  j d ƒ rë | rÛ d | t j j d | ƒ j f Sd | d f Sn  x; t D]3 } | j
 ƒ  j d	 | ƒ rò d
 | | f } Pqò qò Wd | k r_| rL| d | } q_t d |  ƒ ‚ n  | j d d ƒ d j
 ƒ  } t j | ƒ sÄd |  d j d d „  t j Dƒ ƒ d } t | ƒ ‚ n  y t |  ƒ }	 Wn8 t k
 rt j ƒ  d }
 t d |  |
 f ƒ ‚ Yn X|	 s"d |	 k rJt |  ƒ } | sTt d |  ƒ ‚ qTn
 |	 d } t | ƒ } | | |	 f S)zSParses svn+http://blahblah@rev#egg=Foobar into a requirement
    (Foobar) and a URLNz^(.+)(\[[^\]]+\])$rO   r³   zsetup.pyz;Directory %r is not installable. File 'setup.py' not found.zfile:Ú__placeholder__z%s:z%s+%srÿ   zb%s should either be a path to a local project or a VCS url beginning with svn+, git+, hg+, or bzr+r   zFor --editable=%s only z, c             S   s   g  |  ] } | j  d  ‘ q S)z+URL)ru   )rP   r  rK   rK   rL   rR   ¸  s   	 z"parse_editable.<locals>.<listcomp>z is currently supportedz*--editable=%s error in editable options:%sÚeggz@--editable=%s is not the right format; it must have #egg=Package)r‡   rö   r÷   r|   r}   r€   r—   r™   r	   r1   r–   rq   rU   rV   rW   rS   r   r  r  rp  r  r  r¯   rº  r	  rÿ  )rs   rt   r]   rS   ÚmÚurl_no_extrasÚversion_controlr  Úerror_messagerè  ÚmessagerX   ru  rK   rK   rL   rp   �  sT    ! $
rp   c               @   s‘   e  Z d  Z d Z d d „  Z d d „  Z d d „  Z d d	 „  Z d
 d „  Z d d „  Z	 d d „  Z
 d d d „ Z d d „  Z d d „  Z d S)r  zMA set of file paths to be removed in the uninstallation of a
    requirement.c             C   s@   t  ƒ  |  _ t  ƒ  |  _ i  |  _ | |  _ d  |  _ g  |  _ d  S)N)rõ  ÚpathsÚ_refuseÚpthr$  Úsave_dirÚ_moved_paths)rn   r$  rK   rK   rL   ro   Ñ  s    			zUninstallPathSet.__init__c             C   s
   t  | ƒ S)zs
        Return True if the given path is one we are permitted to
        remove/modify, False otherwise.

        )r   )rn   r}   rK   rK   rL   Ú
_permittedÙ  s    zUninstallPathSet._permittedc             C   sa   t  |  j ƒ s] t ƒ  r+ d t j f } n d } t j d |  j j t |  j j	 ƒ | ƒ d Sd S)Nzoutside environment %szowned by OSzNot uninstalling %s at %s, %sFT)
r   r$  r   r¯   rQ  r   r½   r¤   r   r�   )rn   ÚreasonrK   rK   rL   Ú_can_uninstallá  s    		zUninstallPathSet._can_uninstallc             C   s“   t  | ƒ } t j j | ƒ s" d  S|  j | ƒ rD |  j j | ƒ n |  j j | ƒ t j j | ƒ d d k r� t	 r� |  j t
 j | ƒ ƒ n  d  S)NrO   z.py)r   r|   r}   r—   r  r  r  r  Úsplitextr%   ÚimpÚcache_from_source)rn   r}   rK   rK   rL   r  ð  s    "zUninstallPathSet.addc             C   sk   t  | ƒ } |  j | ƒ rW | |  j k r@ t | ƒ |  j | <n  |  j | j | ƒ n |  j j | ƒ d  S)N)r   r  r  ÚUninstallPthEntriesr  r  )rn   Úpth_fileÚentryrK   rK   rL   r  þ  s    zUninstallPathSet.add_pthc                sY   t  ƒ  } xI t | d t ƒD]5 ‰  t ‡  f d d †  | Dƒ ƒ s | j ˆ  ƒ q q W| S)zÔCompact a path set to contain the minimal number of paths
        necessary to contain all paths in the set. If /a/path/ and
        /a/path/to/a/file.txt are both in the set, leave only the
        shorter path.rÚ   c                sJ   g  |  ]@ } ˆ  j  | ƒ oC ˆ  t | j t j j ƒ ƒ t j j k ‘ q SrK   )rq   rä   Úrstripr|   r}   r�   )rP   Ú	shortpath)r}   rK   rL   rR     s   	z,UninstallPathSet.compact.<locals>.<listcomp>)rõ  Úsortedrä   rl   r  )rn   r  Úshort_pathsrK   )r}   rL   Úcompact  s    	zUninstallPathSet.compactc             C   s5   t  j j |  j t  j j | ƒ d j t  j j ƒ ƒ S)NrO   )r|   r}   r™   r  Ú
splitdriverð  r�   )rn   r}   rK   rK   rL   Ú_stash  s    	zUninstallPathSet._stashFc             C   s¿  |  j  ƒ  s d S|  j s4 t j d |  j j ƒ d St j d |  j j ƒ t j d 7_ t |  j |  j ƒ ƒ } z6| r„ d } n- x | D] } t j | ƒ q‹ Wt	 d d ƒ } |  j
 rô t j d ƒ x* |  j |  j
 ƒ D] } t j | ƒ qÚ Wn  | d k r§t j d	 d
 d d ƒ |  _ xK | D]C } |  j | ƒ } t j d | ƒ |  j j | ƒ t | | ƒ q"Wx! |  j j ƒ  D] } | j ƒ  qyWt j d |  j j ƒ n  Wd t j d 8_ Xd S)z[Remove paths in ``self.paths`` with confirmation (unless
        ``auto_confirm`` is True).Nz7Can't uninstall '%s'. No files were found to uninstall.zUninstalling %s:r³   ÚyzProceed (y/n)? Únz.Not removing or modifying (outside of prefix):Úsuffixz
-uninstallrQ  zpip-zRemoving file or directory %szSuccessfully uninstalled %s)r.  r/  )r   r  r   r½   r$  r¤   r¾   r)  r+  r   r  r“   r”   r  r-  r   r  rì   r   r  r‘  rá   )rn   r#  r  rK  r}   Únew_pathr  rK   rK   rL   rá     s<    			zUninstallPathSet.removec             C   s¤   |  j  d k r* t j d |  j j ƒ d St j d |  j j ƒ x> |  j D]3 } |  j | ƒ } t j d | ƒ t	 | | ƒ qK Wx |  j
 D] } | j ƒ  qŒ Wd S)z1Rollback the changes previously made by remove().Nz'Can't roll back %s; was not uninstalledFzRolling back uninstall of %szReplacing %s)r  r   r8  r$  r¤   r½   r  r-  r   r   r  r7  )rn   r}   Útmp_pathr  rK   rK   rL   r7  =  s    zUninstallPathSet.rollbackc             C   s5   |  j  d k	 r1 t |  j  ƒ d |  _  g  |  _ n  d S)z?Remove temporary save dir: rollback will no longer be possible.N)r  r   r  )rn   rK   rK   rL   r:  J  s    	zUninstallPathSet.commitN)r‡  rˆ  r‰  Ú__doc__ro   r  r   r  r  r+  r-  rá   r7  r:  rK   rK   rK   rL   r  Î  s   	%r  c               @   s@   e  Z d  Z d d „  Z d d „  Z d d „  Z d d „  Z d	 S)
r$  c             C   sG   t  j j | ƒ s% t d | ƒ ‚ n  | |  _ t ƒ  |  _ d  |  _ d  S)Nz.Cannot remove entries from nonexistent file %s)r|   r}   r‚   r
   rz   rõ  ÚentriesÚ_saved_lines)rn   r%  rK   rK   rL   ro   S  s
    	zUninstallPthEntries.__init__c             C   sa   t  j j | ƒ } t j d k rM t  j j | ƒ d rM | j d d ƒ } n  |  j j | ƒ d  S)Nr  r   ú\r>  )	r|   r}   r  r¯   r  r,  rÀ   r4  r  )rn   r&  rK   rK   rL   r  Z  s    &zUninstallPthEntries.addc             C   sï   t  j d |  j ƒ t |  j d ƒ } | j ƒ  } | |  _ | j ƒ  t d d „  | Dƒ ƒ rg d } n d } xR |  j D]G } y, t  j d | ƒ | j	 t
 | | ƒ ƒ Wqw t k
 r½ Yqw Xqw Wt |  j d ƒ } | j | ƒ | j ƒ  d  S)	NzRemoving pth entries from %s:r;   c             s   s!   |  ] } t  d  ƒ | k Vq d S)z
N)r*   )rP   rî   rK   rK   rL   r®  k  s    z-UninstallPthEntries.remove.<locals>.<genexpr>z
rW  zRemoving entry: %sÚwb)r   r   rz   r=   Ú	readlinesr5  rò   rl   r4  rá   r*   rÄ  Ú
writelines)rn   r1  ÚlinesÚendliner&  rK   rK   rL   rá   d  s"    	
		zUninstallPthEntries.removec             C   sk   |  j  d  k r' t j d |  j ƒ d St j d |  j ƒ t |  j d ƒ } | j |  j  ƒ | j ƒ  d S)Nz.Cannot roll back changes to %s, none were madeFz!Rolling %s back to previous stater7  T)r5  r   r8  rz   r   r=   r9  rò   )rn   r1  rK   rK   rL   r7  y  s    
zUninstallPthEntries.rollbackN)r‡  rˆ  r‰  ro   r  rá   r7  rK   rK   rK   rL   r$  R  s   
r$  c               @   s:   e  Z d  Z d Z d d „  Z d d „  Z d d „  Z d S)	r  zQWrap a list of lines in an object with readline() to make
    ConfigParser happy.c             C   s   d d „  | Dƒ |  _  d  S)Nc             s   s   |  ] } | Vq d  S)NrK   )rP   ÚlrK   rK   rL   r®  ˆ  s    z$FakeFile.__init__.<locals>.<genexpr>)Ú_gen)rn   r:  rK   rK   rL   ro   ‡  s    zFakeFile.__init__c             C   sT   y7 y t  |  j ƒ SWn t k
 r5 |  j j  ƒ  SYn XWn t k
 rO d SYn Xd  S)Nrð   )Únextr=  Ú	NameErrorÚStopIteration)rn   rK   rK   rL   r  Š  s    zFakeFile.readlinec             C   s   |  j  S)N)r=  )rn   rK   rK   rL   Ú__iter__“  s    zFakeFile.__iter__N)r‡  rˆ  r‰  r3  ro   r  rA  rK   rK   rK   rL   r  „  s   	r  )aÚemail.parserr   r|   r"  r?   r‡   r¯   rž   r“   r»  r@  Údistutils.utilr   Úpip.locationsr   r   r   r   r   Úpip.exceptionsr	   r
   r   r   r   r   r   Úpip.vcsr   Úpip.logr   Úpip.utilr   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   Zpip.backwardcompatr#   r$   r%   r&   r'   r(   r)   r*   Ú	pip.indexr+   r,   Úpip.downloadr-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   Ú	pip.wheelr  r8   r9   r:   rU   r«   rM   ÚobjectrN   r�  r˜  r˜   rŒ  ÚIrí  rï  rÿ  r	  r  rp   r  r$  r  rK   rK   rK   rL   Ú<module>   sV   (4p:Lÿ ÿ ÿ Rÿ ÿ N	cA„2