3
LY                 @   s  d Z ddlmZ ddlZddlZ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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 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% ddl&m'Z'm(Z(m)Z)m*Z* ddl+m,Z,m-Z- ddl.m/Z/ ddl0m1Z1m2Z2m3Z3 ddl4mZ5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z= dddgZ>d3d4d5d6d7d8gZ?ej@eAZBG dd  d eCZDG d!d deCZEe
jFd"e
jGfd#d$ZHG d%d& d&eCZIG d'd( d(eCZJedd)ZKd*d ZLd+d, ZMd-d. ZNd/d0 ZOed1d2ZPdS )9z!Routines related to PyPI, indexes    )absolute_importN)
namedtuple)parse)request)	ipaddress)cached_propertysplitextnormalize_pathARCHIVE_EXTENSIONSSUPPORTED_EXTENSIONS)RemovedInPip10Warning)
indent_log)check_requires_python)DistributionNotFoundBestVersionAlreadyInstalledInvalidWheelFilenameUnsupportedWheel)HAS_TLSis_urlpath_to_urlurl_to_path)Wheel	wheel_ext)get_supported)html5librequestssix)canonicalize_name)
specifiers)SSLError)unescapeFormatControlfmt_ctl_handle_mutual_excludePackageFinderhttps*	localhost127.0.0.0/8::1/128filesshc               @   s\   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d Z
dd Zdd ZdS )InstallationCandidatec             C   s,   || _ t|| _|| _| j | j| jf| _d S )N)projectparse_versionversionlocation_key)selfr,   r.   r/    r2   \/private/var/folders/7d/20zwc49s3kn54d3vgq8bd4640000gn/T/pip-build-an2lx5zf/pip/pip/index.py__init__>   s    
zInstallationCandidate.__init__c             C   s   dj | j| j| jS )Nz,<InstallationCandidate({0!r}, {1!r}, {2!r})>)formatr,   r.   r/   )r1   r2   r2   r3   __repr__D   s    zInstallationCandidate.__repr__c             C   s
   t | jS )N)hashr0   )r1   r2   r2   r3   __hash__I   s    zInstallationCandidate.__hash__c             C   s   | j |dd S )Nc             S   s   | |k S )Nr2   )sor2   r2   r3   <lambda>M   s    z.InstallationCandidate.__lt__.<locals>.<lambda>)_compare)r1   otherr2   r2   r3   __lt__L   s    zInstallationCandidate.__lt__c             C   s   | j |dd S )Nc             S   s   | |kS )Nr2   )r9   r:   r2   r2   r3   r;   P   s    z.InstallationCandidate.__le__.<locals>.<lambda>)r<   )r1   r=   r2   r2   r3   __le__O   s    zInstallationCandidate.__le__c             C   s   | j |dd S )Nc             S   s   | |kS )Nr2   )r9   r:   r2   r2   r3   r;   S   s    z.InstallationCandidate.__eq__.<locals>.<lambda>)r<   )r1   r=   r2   r2   r3   __eq__R   s    zInstallationCandidate.__eq__c             C   s   | j |dd S )Nc             S   s   | |kS )Nr2   )r9   r:   r2   r2   r3   r;   V   s    z.InstallationCandidate.__ge__.<locals>.<lambda>)r<   )r1   r=   r2   r2   r3   __ge__U   s    zInstallationCandidate.__ge__c             C   s   | j |dd S )Nc             S   s   | |kS )Nr2   )r9   r:   r2   r2   r3   r;   Y   s    z.InstallationCandidate.__gt__.<locals>.<lambda>)r<   )r1   r=   r2   r2   r3   __gt__X   s    zInstallationCandidate.__gt__c             C   s   | j |dd S )Nc             S   s   | |kS )Nr2   )r9   r:   r2   r2   r3   r;   \   s    z.InstallationCandidate.__ne__.<locals>.<lambda>)r<   )r1   r=   r2   r2   r3   __ne__[   s    zInstallationCandidate.__ne__c             C   s   t |tstS || j|jS )N)
isinstancer+   NotImplementedr0   )r1   r=   methodr2   r2   r3   r<   ^   s    
zInstallationCandidate._compareN)__name__
__module____qualname__r4   r6   r8   r>   r?   r@   rA   rB   rC   r<   r2   r2   r2   r3   r+   <   s   r+   c            	   @   s   e Zd ZdZd!ddZdd Zed"dd	Zd
d Zdd Z	dd Z
dd Zdd Zdd ZejdZdd Zdd Zdd Zdd Zdd  ZdS )#r#   zThis finds packages.

    This is meant to match easy_install's technique for looking for
    packages, by reading pages and looking for appropriate links.
    FNc             C   s   |dkrt dg | _x:|D ]2}|jdrBt|}tjj|rB|}| jj| qW || _g | _	t
 | _|pvtt
 t
 | _dd |r|ng D | _|| _|| _|| _t|	||
|d| _tsx8tj| j| jD ]$}tj|}|jdkrtjd P qW dS )	a  Create a PackageFinder.

        :param format_control: A FormatControl object or None. Used to control
            the selection of source packages / binary packages when consulting
            the index and links.
        :param platform: A string or None. If None, searches for packages
            that are supported by the current system. Otherwise, will find
            packages that can be built on the platform passed in. These
            packages will only be downloaded for distribution: they will
            not be built locally.
        :param versions: A list of strings or None. This is passed directly
            to pep425tags.py in the get_supported() method.
        :param abi: A string or None. This is passed directly
            to pep425tags.py in the get_supported() method.
        :param implementation: A string or None. This is passed directly
            to pep425tags.py in the get_supported() method.
        Nz>PackageFinder() missing 1 required keyword argument: 'session'~c             S   s   g | ]}d |d fqS )r%   r2   ).0hostr2   r2   r3   
<listcomp>   s   z*PackageFinder.__init__.<locals>.<listcomp>)versionsplatformabiimplr$   zipip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.)	TypeError
find_links
startswithr	   ospathexistsappend
index_urlsdependency_linkssetlogged_linksr!   format_controlsecure_originsallow_all_prereleasesprocess_dependency_linkssessionr   
valid_tagsr   	itertoolschainurllib_parseurlparseschemeloggerwarning)r1   rS   rY   r_   trusted_hostsr`   ra   r]   rO   rN   rP   implementationlinknew_linkparsedr2   r2   r3   r4   l   s>    	




zPackageFinder.__init__c             C   s"   | j rtjdt | jj| d S )NzXDependency Links processing has been deprecated and will be removed in a future release.)r`   warningswarnr   rZ   extend)r1   linksr2   r2   r3   add_dependency_links   s
    z"PackageFinder.add_dependency_linksc                s   g  g  fdd}x| D ]}t jj|}|jd}|s>|r|rH|}nt|}t jj|r|rt jj|}x4t j|D ]}|t jj|| qxW q|rƈj	| qt jj
|r|| qtjd| qt|r܈j	| qtjd| qW  fS )zt
        Sort locations into "files" (archives) and "urls", and return
        a pair of lists (files,urls)
        c                s8   t | }tj|ddd dkr*j| n
 j| d S )NF)strictr   z	text/html)r   	mimetypes
guess_typerX   )rV   url)filesurlsr2   r3   	sort_path   s    z0PackageFinder._sort_locations.<locals>.sort_pathzfile:z:Url '%s' is ignored: it is neither a file nor a directory.zQUrl '%s' is ignored. It is either a non-existing path or lacks a specific scheme.)rU   rV   rW   rT   r   isdirrealpathlistdirjoinrX   isfilerh   ri   r   )	locations
expand_dirrz   rw   is_local_pathis_file_urlrV   itemr2   )rx   ry   r3   _sort_locations   s8    



zPackageFinder._sort_locationsc             C   sX   t | j}|jjrHt|jj}|j| js8td|j |j| j }n| }|j	|fS )a[  
        Function used to generate link sort key for link tuples.
        The greater the return value, the more preferred it is.
        If not finding wheels, then sorted by version only.
        If finding wheels, then the sort order is by version, then:
          1. existing installs
          2. wheels ordered via Wheel.support_index_min(self.valid_tags)
          3. source archives
        Note: it was considered to embed this logic into the Link
              comparison operators, but then different sdist links
              with the same version, would have to be considered equal
        zB%s is not a supported wheel for this platform. It can't be sorted.)
lenrb   r/   is_wheelr   filename	supportedr   support_index_minr.   )r1   	candidatesupport_numwheelprir2   r2   r3   _candidate_sort_key   s    

z!PackageFinder._candidate_sort_keyc       	      C   sl  t jt|}|j|j|jf}|d jddd
 }x t| j D ]}||d kr`|d dkr`q@yht	j
t|d tjs|d d kr|d n|d jd}t	jt|d tjr|d n|d jd}W nJ tk
r   |d r|d j |d j kr|d dkrw@Y nX ||kr q@|d |d krP|d dkrP|d d k	rPq@dS W |jd|j|j d	S )Nr   +   r%   utf8   TzThe repository located at %s is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host %s'.F)re   rf   strrg   hostnameportrsplitSECURE_ORIGINSr^   r   
ip_addressrD   r   	text_typedecode
ip_network
ValueErrorlowerri   )	r1   rh   r/   rn   originprotocolsecure_originaddrnetworkr2   r2   r3   _validate_secure_origin  s>    

z%PackageFinder._validate_secure_originc                s    fdd  fdd| j D S )zReturns the locations found via self.index_urls

        Checks the url_name on the main (first in the list) index and
        use this url_name to produce all locations
        c                s,   t j| tjt }|jds(|d }|S )N/)	posixpathr~   re   quoter   endswith)rw   loc)project_namer2   r3   mkurl_pypi_urlh  s    
z?PackageFinder._get_index_urls_locations.<locals>.mkurl_pypi_urlc                s   g | ]} |qS r2   r2   )rK   rw   )r   r2   r3   rM   u  s    z;PackageFinder._get_index_urls_locations.<locals>.<listcomp>)rY   )r1   r   r2   )r   r   r3   _get_index_urls_locationsa  s    z'PackageFinder._get_index_urls_locationsc                s   j |} j|\}} j jdd\}} j j\}}dd tj|||D }	 fddtjdd |D dd |D d	d |D D }
tjd
t|
| x|
D ]}tjd| qW t	|}t
 j|}t|||} jdd  jD |}g }xJ j|
|D ]:}tjd|j t  |j j|j| W dQ R X qW  jdd  jD |}|r|tjddjdd |D   j|	|}|r|jdd tjddjdd |D  || | | S )a  Find all available InstallationCandidate for project_name

        This checks index_urls, find_links and dependency_links.
        All versions found are returned as an InstallationCandidate list.

        See _link_package_versions for details on which files are accepted
        T)r   c             s   s   | ]}t |V  qd S )N)Link)rK   rw   r2   r2   r3   	<genexpr>  s    z4PackageFinder.find_all_candidates.<locals>.<genexpr>c                s   g | ]} j t|r|qS r2   )r   rh   )rK   rl   )r1   r2   r3   rM     s    z5PackageFinder.find_all_candidates.<locals>.<listcomp>c             s   s   | ]}t |V  qd S )N)r   )rK   rw   r2   r2   r3   r     s    c             s   s   | ]}t |V  qd S )N)r   )rK   rw   r2   r2   r3   r     s    c             s   s   | ]}t |V  qd S )N)r   )rK   rw   r2   r2   r3   r     s    z,%d location(s) to search for versions of %s:z* %sc             s   s   | ]}t |d V  qdS )z-fN)r   )rK   rw   r2   r2   r3   r     s    zAnalyzing links from page %sNc             s   s   | ]}t |V  qd S )N)r   )rK   rw   r2   r2   r3   r     s    zdependency_links found: %sz, c             S   s   g | ]}|j jqS r2   )r/   rw   )rK   r.   r2   r2   r3   rM     s    )reversezLocal files found: %sc             S   s   g | ]}t |jjqS r2   )r   r/   rw   )rK   r   r2   r2   r3   rM     s   )r   r   rS   rZ   rc   rd   rh   debugr   r   fmt_ctl_formatsr]   Search_package_versions
_get_pagesrw   r   rq   rr   r~   sort)r1   r   index_locationsindex_file_locindex_url_locfl_file_loc
fl_url_locdep_file_locdep_url_locfile_locationsurl_locationsr/   canonical_nameformatssearchfind_links_versionspage_versionspagedependency_versionsfile_versionsr2   )r1   r3   find_all_candidatesw  sX    


 
z!PackageFinder.find_all_candidatesc                sh  | j |j}t|jjdd |D | jr,| jndd  fdd|D }|r\t|| jd}nd}|jdk	rxt	|jj
}nd}|dkr|dkrtjd|djttd	d
 |D t	d td| d}|r|dks|j
|krd}| o|dk	r|rtjd| ntjd||j
 dS |rDtjd|djt t	dp<d ttjd|j
djt t	d |jS )zTry to find a Link matching req

        Expects req, an InstallRequirement and upgrade, a boolean
        Returns a Link if found,
        Raises DistributionNotFound or BestVersionAlreadyInstalled otherwise
        c             S   s   g | ]}t |jqS r2   )r   r.   )rK   cr2   r2   r3   rM     s    z2PackageFinder.find_requirement.<locals>.<listcomp>N)prereleasesc                s   g | ]}t |j kr|qS r2   )r   r.   )rK   r   )compatible_versionsr2   r3   rM     s    )keyzNCould not find a version that satisfies the requirement %s (from versions: %s)z, c             s   s   | ]}t |jV  qd S )N)r   r.   )rK   r   r2   r2   r3   r     s    z1PackageFinder.find_requirement.<locals>.<genexpr>z%No matching distribution found for %sFTzLExisting installed version (%s) is most up-to-date and satisfies requirementzUExisting installed version (%s) satisfies requirement (most up-to-date version is %s)z=Installed version (%s) is most up-to-date (past versions: %s)nonez)Using version %s (newest of versions: %s))r   namer[   	specifierfilterr_   maxr   satisfied_byr-   r.   rh   criticalr~   sortedr   r   r   r/   )r1   requpgradeall_candidatesapplicable_candidatesbest_candidateinstalled_versionbest_installedr2   )r   r3   find_requirement  sd    


zPackageFinder.find_requirementc             c   sF   t  }x:|D ]2}||krq|j| | j|}|dkr8q|V  qW dS )zp
        Yields (page, page_url) from the given locations, skipping
        locations that have errors.
        N)r[   add	_get_page)r1   r   r   seenr/   r   r2   r2   r3   r   -  s    


zPackageFinder._get_pagesz-py([123]\.?[0-9]?)$c             C   sT   g g  }}t  }x:|D ]2}||kr|j| |jr>|j| q|j| qW || S )z
        Returns elements of links in order, non-egg links first, egg links
        second, while eliminating duplicates
        )r[   r   egg_fragmentrX   )r1   rr   eggsno_eggsr   rl   r2   r2   r3   _sort_links@  s    


zPackageFinder._sort_linksc             C   s:   g }x0| j |D ]"}| j||}|d k	r|j| qW |S )N)r   _link_package_versionsrX   )r1   rr   r   resultrl   vr2   r2   r3   r   P  s    zPackageFinder._package_versionsc             C   s(   || j kr$tjd|| | j j| d S )NzSkipping link %s; %s)r\   rh   r   r   )r1   rl   reasonr2   r2   r3   _log_skipped_linkX  s    
zPackageFinder._log_skipped_linkc       
      C   sJ  d}|j r|j }|j}n|j \}}|s:| j|d dS |tkrV| j|d|  dS d|jkr~|tkr~| j|d|j  dS d|jkr|dkr| j|d dS |tkr&yt	|j
}W n  tk
r   | j|d	 dS X t|j|jkr| j|d
|j  dS |j| js | j|d dS |j}d|jkrR|tkrR| j|d|j  dS |sft||j|}|dkr| j|d
|j  dS | jj|}|r|d|j  }|jd}|tjdd kr| j|d dS yt|j}	W n. tjk
r   tjd|j
|j d}	Y nX |	s.tjd||j dS tjd|| t|j||S )z'Return an InstallationCandidate or NoneNz
not a filezunsupported archive format: %sbinaryzNo binaries permitted for %smacosx10z.zipzmacosx10 onezinvalid wheel filenamezwrong project name (not %s)z%it is not compatible with this PythonsourcezNo sources permitted for %sr      zPython version is incorrectz3Package %s has an invalid Requires-Python entry: %sTz_The package %s is incompatible with the pythonversion in use. Acceptable python versions are:%szFound link %s, version: %s)r   extr   r   r   r   r   suppliedrV   r   r   r   r   r   	canonicalr   rb   r.   egg_info_matches_py_version_rer   startgroupsysr   requires_pythonr   InvalidSpecifierrh   r   r+   )
r1   rl   r   r.   egg_infor   r   match
py_versionsupport_this_pythonr2   r2   r3   r   ]  s    





z$PackageFinder._link_package_versionsc             C   s   t j|| jdS )N)ra   )HTMLPageget_pagera   )r1   rl   r2   r2   r3   r     s    zPackageFinder._get_page)	FNFNNNNNN)F)rG   rH   rI   __doc__r4   rs   staticmethodr   r   r   r   r   r   r   recompiler   r   r   r   r   r   r2   r2   r2   r3   r#   e   s(      
Q1GSc
Mz([a-z0-9_.]+)-([a-z0-9_.!+-]+)c             C   s   |j | }|stjd| dS |dkrB|jd}||jdd S |jdj }|jdd}|j d }|j|r|jdt|d S dS dS )ax  Pull the version part out of a string.

    :param egg_info: The string to parse. E.g. foo-2.1
    :param search_name: The name of the package this belongs to. None to
        infer the name. Note that this cannot unambiguously parse strings
        like foo-2-2 which might be foo, 2-2 or foo-2, 2.
    :param link: The link the string came from, for logging on failure.
    z%Could not parse version from link: %sNr   -_)	r   rh   r   r   indexr   replacerT   r   )r   search_namerl   _egg_info_rer   
full_matchr   look_forr2   r2   r3   r     s    


r   c               @   sx   e Zd ZdZdddZdd Zeddd	Zedd
dZ	edd Z
edd Zedd ZejdejZdd ZdS )r   z'Represents one page, along with its URLNc             C   s\   d }|r2d|kr2t j|d \}}d|kr2|d }|| _tj| j|dd| _|| _|| _d S )NzContent-TypecharsetF)transport_encodingnamespaceHTMLElements)cgiparse_headercontentr   r   rn   rw   headers)r1   r  rw   r  encodingcontent_typeparamsr2   r2   r3   r4     s    
zHTMLPage.__init__c             C   s   | j S )N)rw   )r1   r2   r2   r3   __str__  s    zHTMLPage.__str__Tc             C   sl  |d krt d|j}|jddd }ddlm} x>|jD ]4}|j j|r:|t| dkr:t	j
d|| d S q:W y"|r|j}xHtD ]@}|j|r| j||d}	|	j jd	rP qt	j
d
||	 d S qW t	j
d| tj|\}}
}}}}|dkr6tjjtj|r6|jds|d7 }tj|d}t	j
d| |j|d	ddd}|j  |jjdd}	|	j jd	st	j
d
||	 d S | |j|j|j}W n tjk
r } z| j||| W Y d d }~X n tk
r } z"d| }| j|||t	jd W Y d d }~X n` tj k
r> } z| j|d| | W Y d d }~X n* tj!k
rb   | j|d| Y nX |S d S )Nz9get_page() missing 1 required keyword argument: 'session'#r   r   )
VcsSupportz+:zCannot look at %s URL %s)ra   z	text/htmlz,Skipping page %s because of Content-Type: %szGetting page %sr)   r   z
index.htmlz# file: URL is directory, getting %szmax-age=600)AcceptzCache-Control)r  zContent-Typeunknownz6There was a problem confirming the ssl certificate: %s)methzconnection error: %sz	timed out)"rR   rw   splitpip.vcsr  schemesr   rT   r   rh   r   r   r
   r   _get_content_typere   rf   rU   rV   r{   urllib_requesturl2pathnameurljoingetraise_for_statusr  r  r   	HTTPError_handle_failr   infoConnectionErrorTimeout)clsrl   skip_archivesra   rw   r  rg   r   bad_extr  netlocrV   r  queryfragmentrespinstexcr   r2   r2   r3   r     sp    



$"zHTMLPage.get_pagec             C   s   |d krt j}|d| | d S )Nz%Could not fetch URL %s: %s - skipping)rh   r   )rl   r   rw   r  r2   r2   r3   r#  9  s    zHTMLPage._handle_failc             C   sD   t j| \}}}}}|dkr dS |j| dd}|j  |jjddS )z;Get the Content-Type of the given url, using a HEAD requesthttpr$    T)allow_redirectszContent-Type)r0  r$   )re   urlsplitheadr!  r  r   )rw   ra   rg   r*  rV   r+  r,  r-  r2   r2   r3   r  @  s    zHTMLPage._get_content_typec             C   s@   dd | j jdD }|r6|d jdr6|d jdS | jS d S )Nc             S   s   g | ]}|j d dk	r|qS )hrefN)r   )rK   xr2   r2   r3   rM   Q  s    z%HTMLPage.base_url.<locals>.<listcomp>z.//baser   r5  )rn   findallr   rw   )r1   basesr2   r2   r3   base_urlN  s    zHTMLPage.base_urlc             c   sl   xf| j jdD ]V}|jdr|jd}| jtj| j|}|jd}|rPt|nd}t|| |dV  qW dS )zYields all links in the pagez.//ar5  zdata-requires-pythonN)r   )	rn   r7  r   
clean_linkre   r  r9  r    r   )r1   anchorr5  rw   	pyrequirer2   r2   r3   rr   Y  s    


zHTMLPage.linksz[^a-z0-9$&+,/:;=?@.#%_\\|-]c             C   s   | j jdd |S )zMakes sure a link is fully encoded.  That is, if a ' ' shows up in
        the link, it will be rewritten to %20 (while not over-quoting
        % or other characters).c             S   s   dt | jd S )Nz%%%2xr   )ordr   )r   r2   r2   r3   r;   m  s    z%HTMLPage.clean_link.<locals>.<lambda>)	_clean_resub)r1   rw   r2   r2   r3   r:  h  s    zHTMLPage.clean_link)N)TN)N)rG   rH   rI   r   r4   r  classmethodr   r   r#  r  r   r9  propertyrr   r   r   Ir>  r:  r2   r2   r2   r3   r     s   
Ur   c               @   s   e Zd Zd5d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 Zdd Zedd Zedd Zedd Zedd Zdd Zed d! Zed"d# Zejd$Zed%d& Zejd'Zed(d) Zejd*Zed+d, Zed-d. Zed/d0 Zed1d2 Zed3d4 Z dS )6r   Nc             C   s0   |j drt|}|| _|| _|r&|nd| _dS )a  
        Object representing a parsed link from https://pypi.python.org/simple/*

        url:
            url of the resource pointed to (href of the link)
        comes_from:
            instance of HTMLPage where the link was found, or string.
        requires_python:
            String containing the `Requires-Python` metadata field, specified
            in PEP 345. This may be specified by a data-requires-python
            attribute in the HTML link tag, as described in PEP 503.
        z\\N)rT   r   rw   
comes_fromr   )r1   rw   rC  r   r2   r2   r3   r4   r  s
    
zLink.__init__c             C   s<   | j rd| j  }nd}| jr.d| j| j|f S t| jS d S )Nz (requires-python:%s)r1  z%s (from %s)%s)r   rC  rw   r   )r1   rpr2   r2   r3   r    s    zLink.__str__c             C   s   d|  S )Nz	<Link %s>r2   )r1   r2   r2   r3   r6     s    zLink.__repr__c             C   s   t |tstS | j|jkS )N)rD   r   rE   rw   )r1   r=   r2   r2   r3   r@     s    
zLink.__eq__c             C   s   t |tstS | j|jkS )N)rD   r   rE   rw   )r1   r=   r2   r2   r3   rC     s    
zLink.__ne__c             C   s   t |tstS | j|jk S )N)rD   r   rE   rw   )r1   r=   r2   r2   r3   r>     s    
zLink.__lt__c             C   s   t |tstS | j|jkS )N)rD   r   rE   rw   )r1   r=   r2   r2   r3   r?     s    
zLink.__le__c             C   s   t |tstS | j|jkS )N)rD   r   rE   rw   )r1   r=   r2   r2   r3   rB     s    
zLink.__gt__c             C   s   t |tstS | j|jkS )N)rD   r   rE   rw   )r1   r=   r2   r2   r3   rA     s    
zLink.__ge__c             C   s
   t | jS )N)r7   rw   )r1   r2   r2   r3   r8     s    zLink.__hash__c             C   sJ   t j| j\}}}}}tj|jdp(|}t j|}|sFtd| j |S )Nr   zURL %r produced no filename)re   r3  rw   r   basenamerstripunquoteAssertionError)r1   r  r*  rV   r   r2   r2   r3   r     s
    
zLink.filenamec             C   s   t j| jd S )Nr   )re   r3  rw   )r1   r2   r2   r3   rg     s    zLink.schemec             C   s   t j| jd S )Nr   )re   r3  rw   )r1   r2   r2   r3   r*    s    zLink.netlocc             C   s   t jt j| jd S )Nr   )re   rG  r3  rw   )r1   r2   r2   r3   rV     s    z	Link.pathc             C   s   t tj| jjdS )Nr   )r   r   rE  rV   rF  )r1   r2   r2   r3   r     s    zLink.splitextc             C   s   | j  d S )Nr   )r   )r1   r2   r2   r3   r     s    zLink.extc             C   s*   t j| j\}}}}}t j||||d fS )N)re   r3  rw   
urlunsplit)r1   rg   r*  rV   r+  r,  r2   r2   r3   url_without_fragment  s    zLink.url_without_fragmentz[#&]egg=([^&]*)c             C   s    | j j| j}|sd S |jdS )Nr   )_egg_fragment_rer   rw   r   )r1   r   r2   r2   r3   r     s    zLink.egg_fragmentz[#&]subdirectory=([^&]*)c             C   s    | j j| j}|sd S |jdS )Nr   )_subdirectory_fragment_rer   rw   r   )r1   r   r2   r2   r3   subdirectory_fragment  s    zLink.subdirectory_fragmentz2(sha1|sha224|sha384|sha256|sha512|md5)=([a-f0-9]+)c             C   s    | j j| j}|r|jdS d S )Nr   )_hash_rer   rw   r   )r1   r   r2   r2   r3   r7     s    
z	Link.hashc             C   s    | j j| j}|r|jdS d S )Nr   )rN  r   rw   r   )r1   r   r2   r2   r3   	hash_name  s    
zLink.hash_namec             C   s$   t j| jjddd jddd S )Nr  r   r   ?)r   rE  rw   r  )r1   r2   r2   r3   show_url  s    zLink.show_urlc             C   s
   | j tkS )N)r   r   )r1   r2   r2   r3   r     s    zLink.is_wheelc             C   s    ddl m} | j|jkrdS dS )z
        Determines if this points to an actual artifact (e.g. a tarball) or if
        it points to an "abstract" thing like a path or a VCS location.
        r   )vcsFT)r  rR  rg   all_schemes)r1   rR  r2   r2   r3   is_artifact  s    zLink.is_artifact)NN)!rG   rH   rI   r4   r  r6   r@   rC   r>   r?   rB   rA   r8   rA  r   rg   r*  rV   r   r   rJ  r   r   rK  r   rL  rM  rN  r7   rO  rQ  r   rT  r2   r2   r2   r3   r   p  s8   



r   zno_binary only_binaryc             C   s   | j d}xFd|krP|j  |j  |jd |d |jdd = d|krd S qW x:|D ]2}|dkrn|j  qXt|}|j| |j| qXW d S )N,z:all:r   z:none:)r  clearr   r  r   discard)valuetargetr=   newr   r2   r2   r3   r"     s    




c             C   sj   t ddg}|| jkr"|jd n@|| jkr8|jd n*d| jkrN|jd nd| jkrb|jd t|S )Nr   r   z:all:)r[   only_binaryrW  	no_binary	frozenset)fmt_ctlr   r   r2   r2   r3   r   -  s    




r   c             C   s   t d| j| j d S )Nz:all:)r"   r\  r[  )r^  r2   r2   r3   fmt_ctl_no_binary:  s    r_  c             C   s   t |  tjdtdd d S )Nzf--no-use-wheel is deprecated and will be removed in the future.  Please use --no-binary :all: instead.r   )
stacklevel)r_  ro   rp   r   )r^  r2   r2   r3   fmt_ctl_no_use_wheel?  s
    ra  r   zsupplied canonical formats)r$   r%   r%   )r%   r&   r%   )r%   r'   r%   )r%   r(   r%   )r)   r%   N)r*   r%   r%   )Qr   
__future__r   loggingr  collectionsr   rc   r   rU   r   ru   r   ro   Zpip._vendor.six.moves.urllibr   re   r   r  
pip.compatr   	pip.utilsr   r   r	   r
   r   Zpip.utils.deprecationr   pip.utils.loggingr   pip.utils.packagingr   pip.exceptionsr   r   r   r   pip.downloadr   r   r   r   	pip.wheelr   r   Zpip.pep425tagsr   pip._vendorr   r   r   Zpip._vendor.packaging.versionr-   pip._vendor.packaging.utilsr   Zpip._vendor.packagingr   Zpip._vendor.requests.exceptionsr   Zpip._vendor.distlib.compatr    __all__r   	getLoggerrG   rh   objectr+   r#   r   rB  r   r   r   r!   r"   r   r_  ra  r   r2   r2   r2   r3   <module>   sl   

)    O & !


