3
gl8                 @   s  U 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mZm	Z	m
Z
mZmZ d dl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 dd	lmZmZmZmZmZmZ d
ddddddddddgZ ej!e"Z#ej$j%drej&Z'nej(Z'e)eddZ*e+*ej,dDkZ-e.dddZ/ee+e+f e.dddZ0e j1dd e.dd!d"Z2e j1dd e.dd#d$Z3e j1dd e.dd%d&Z4e j1dd e.dd'd(Z5ee+ e	e+ d)d*d+Z6e j1dd ej7ej7e+dd,d-d.Z8ej7ej7e+e.d,d/d0Z9e j1dd d1dddd2e.ee+ ee+ ee+ dd3d4d5Z:dEe+e.ee+ ee+ e.ee+ ed6d7dZ;e+dd8dZ<e+dd9dZ=e+e.d:d;d<Z>e+dd=dZ?e+dd>dZ@e+e+e
e+ d?d@dAZAe+e
e+ dBdCdZBdS )F    N)AnyDictIteratorListOptionalTuple)SCHEME_KEYSScheme)WINDOWS)
deprecated)running_under_virtualenv   )
_distutils
_sysconfig)USER_CACHE_DIRget_major_minor_versionget_src_prefixis_osx_frameworksite_packages	user_siter   get_bin_prefixget_bin_userr   get_platlibget_prefixed_libsget_purelib
get_schemer   r   r   Z"_PIP_LOCATIONS_NO_WARN_ON_MISMATCH
platlibdirlib   
   )returnc              C   s:   ddl m}  y| d d }W n tk
r0   dS X |dkS )zsThe resolution to bpo-44860 will change this incorrect platlib.

    See <https://bugs.python.org/issue44860>.
    r   )INSTALL_SCHEMESZ	unix_userplatlibFz	$usersite)distutils.command.installr!   KeyError)r!   Zunix_user_platlib r%   ^/var/www/tester-filtro-web/env/lib/python3.6/site-packages/pip/_internal/locations/__init__.py_looks_like_bpo_448603   s    r'   )schemer    c             C   s\   | d }d|kr0t tdr0|jddtj d}d|kr<dS |jdd}|jdd	| d
 kS )Nr"   z/$platlibdir/r   /z/lib64/Fz/lib/z
$platbase/z$base/purelib)hasattrsysreplacer   )r(   r"   Z	unpatchedr%   r%   r&   +_looks_like_red_hat_patched_platlib_purelibA   s    r.   )maxsizec                  s"   ddl m  t fdddD S )zRed Hat patches platlib in unix_prefix and unix_home, but not purelib.

    This is the only way I can see to tell a Red Hat-patched Python.
    r   )r!   c             3   s"   | ]}| kot  | V  qd S )N)r.   ).0k)r!   r%   r&   	<genexpr>T   s   z*_looks_like_red_hat_lib.<locals>.<genexpr>unix_prefix	unix_home)r3   r4   )r#   r!   allr%   r%   )r!   r&   _looks_like_red_hat_libK   s    
r6   c              C   s   ddl m}  d| kod| kS )z#Debian adds two additional schemes.r   )r!   Z
deb_systemZ
unix_local)r#   r!   )r!   r%   r%   r&   _looks_like_debian_schemeZ   s    r7   c              C   s^   ddl m}  ddlm} | | }|j  |jtjjt	j dko\|j
tjjt	j
 dkS )a\  Red Hat patches ``sys.prefix`` and ``sys.exec_prefix``.

    Red Hat's ``00251-change-user-install-location.patch`` changes the install
    command's ``prefix`` and ``exec_prefix`` to append ``"/local"``. This is
    (fortunately?) done quite unconditionally, so we create a default command
    object without any configuration to detect this.
    r   )install)Distributionz/local)r#   r8   Zdistutils.distr9   Zfinalize_optionsexec_prefixospathnormpathr,   prefix)r8   r9   cmdr%   r%   r&   _looks_like_red_hat_schemeb   s    	
r@   c                  s.   t jddd tdd  fddd	D D S )
a  MSYS2 patches distutils and sysconfig to use a UNIX-like scheme.

    However, MSYS2 incorrectly patches sysconfig ``nt`` scheme. The fix is
    likely going to be included in their 3.10 release, so we ignore the warning.
    See msys2/MINGW-packages#9319.

    MSYS2 MINGW's patch uses lowercase ``"lib"`` instead of the usual uppercase,
    and is missing the final ``"site-packages"``.
    ntF)expandc             s   s*   | ]"}d |ko d|ko |j d V  qdS )ZLibr   zsite-packagesN)endswith)r0   pr%   r%   r&   r2      s   z1_looks_like_msys2_mingw_scheme.<locals>.<genexpr>c             3   s   | ]} | V  qd S )Nr%   )r0   key)pathsr%   r&   r2      s    r"   r*   )r"   r*   )	sysconfig	get_pathsr5   r%   r%   )rF   r&   _looks_like_msys2_mingw_schemev   s    rI   )partsr    c             c   sr   t jd}ttdd }| s.| s.|j| r<| E d H  d S x0| D ](}|j|rd|d dt|  }|V  qBW d S )N	LDVERSIONabiflagsr   )rG   get_config_vargetattrr,   rC   len)rJ   Z	ldversionrL   partr%   r%   r&   _fix_abiflags   s    



rQ   )oldnewrE   r    c            C   s    d}d}t jt|||| | d S )Nz(https://github.com/pypa/pip/issues/10151zSValue for %s does not match. Please report this to <%s>
distutils: %s
sysconfig: %s)loggerlog_MISMATCH_LEVEL)rR   rS   rE   Z	issue_urlmessager%   r%   r&   _warn_mismatched   s    rX   c            C   s   | |krdS t | ||d dS )NF)rE   T)rX   )rR   rS   rE   r%   r%   r&   _warn_if_mismatch   s    rY   F)userhomerootr>   )rZ   r[   r\   r>   r    c             C   s,   dddddg}t jtdj|| ||| d S )NzAdditional context:z	user = %rz	home = %rz	root = %rzprefix = %r
)rT   rU   rV   join)rZ   r[   r\   r>   rJ   r%   r%   r&   _log_context   s    	r_   )	dist_namerZ   r[   r\   isolatedr>   r    c          	      s  t j| |||||d}tr|S tj| |||||dg }xtD ]}tjt|}	tjt||}
|	|
krpq@tj	j
dko|d k	o|dko|	j|
jko|	j
jdo|
j
jd}|rq@|ot o|dko|	jj|
jko|	jj
jd}|rq@|dkrt rq@|o,|dko,t o,tjdko,td	ko,t }|r6q@|pL|pL|pLt  o|	jd
d dkot|
jd
ko|
jd
 dkot|
jdk s|
jd dkot pt }|rq@tjdk ot o|dkott|	j|
jk}|rq@to
|d ko
t }|rq@tjddo0t o0|d!k}|r:q@|j|	|
d| f q@W |s^S tj| |||||dd t fddtD rt dd d d S x"|D ]\}	}
}t!|	|
|d qW t"||||d S )"N)rZ   r[   r\   ra   r>   pypyr"   r*   pythonheadersr   	   r   r   usrlocal      T)
check_homeincludeplatincludezscheme.)Zignore_config_filesc             3   s    | ]} | t |kV  qd S )N)rN   )r0   r1   )default_oldrR   r%   r&   r2   O  s    zget_scheme.<locals>.<genexpr>zConfiguring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621)reasonreplacementgone_in)rE   )rZ   r[   r\   r>   )r"   r*   )r   re   )rf   rg   )r   ri   )rd   r"   r*   )r"   r*   )rd   rk   rl   )#r   r   _USE_SYSCONFIGr   r   pathlibPathrN   r,   implementationnameparent
startswithr   r6   r
   version_info_PLATLIBDIRr'   r   rJ   rO   r@   r7   tuplerQ   rI   rG   is_python_buildappendZdistutils_schemeanyr   rX   r_   )r`   rZ   r[   r\   ra   r>   rS   Zwarning_contextsr1   Zold_vZnew_vZskip_pypy_special_caseZ$skip_osx_framework_user_special_caseZskip_bpo_44860Zskip_linux_system_special_caseZskip_sysconfig_abiflag_bugZskip_msys2_mingw_bugZskip_cpython_buildrE   r%   )rm   rR   r&   r      s    

 
c              C   s<   t j } tr| S tj }ttj|tj| ddr8t  |S )NZ
bin_prefix)rE   )r   r   rq   r   rY   rr   rs   r_   )rS   rR   r%   r%   r&   r   d  s    c               C   s   t jdddjS )N T)rZ   )r   r   scriptsr%   r%   r%   r&   r   o  s    )valuer    c             C   s   t  s
dS | dkrdS dS )a  Check if the value is Debian's APT-controlled dist-packages.

    Debian's ``distutils.sysconfig.get_python_lib()`` implementation returns the
    default package path controlled by APT, but does not patch ``sysconfig`` to
    do the same. This is similar to the bug worked around in ``get_scheme()``,
    but here the default is ``deb_system`` instead of ``unix_local``. Ultimately
    we can't do anything about this Debian bug, and this detection allows us to
    skip the warning when needed.
    Fz/usr/lib/python3/dist-packagesT)r7   )r   r%   r%   r&   $_looks_like_deb_system_dist_packagess  s
    
r   c              C   sH   t j } tr| S tj }t|r$|S ttj|tj| ddrDt  |S )z,Return the default pure-Python lib location.r*   )rE   )	r   r   rq   r   r   rY   rr   rs   r_   )rS   rR   r%   r%   r&   r     s    c              C   sH   t j } tr| S tj }t|r$|S ttj|tj| ddrDt  |S )z0Return the default platform-shared lib location.r"   )rE   )	r   r   rq   r   r   rY   rr   rs   r_   )rS   rR   r%   r%   r&   r     s    )v1v2r    c             C   s   | |kr| gS | |gS )zDeduplicate values from a list.r%   )r   r   r%   r%   r&   _deduplicated  s    r   )r>   r    c             C   sz   t j| \}}trt||S tj| \}}ttj|tj|ddttj|tj|ddg}t|rpt	| d t||S )z*Return the lib locations under ``prefix``.zprefixed-purelib)rE   zprefixed-platlib)r>   )
r   r   rq   r   r   rY   rr   rs   r}   r_   )r>   Znew_pureZnew_platZold_pureZold_platZwarnedr%   r%   r&   r     s    


)r   r   )FNNFN)C	functoolsloggingr;   rr   r,   rG   typingr   r   r   r   r   r   Zpip._internal.models.schemer   r	   pip._internal.utils.compatr
   pip._internal.utils.deprecationr   pip._internal.utils.virtualenvr   r~   r   r   baser   r   r   r   r   r   __all__	getLogger__name__rT   environgetDEBUGrV   WARNINGrN   ry   strrx   rq   boolr'   r.   	lru_cacher6   r7   r@   rI   rQ   rs   rX   rY   r_   r   r   r   r   r   r   r   r   r%   r%   r%   r&   <module>   s      










     !