a
    <BìjT  ã                   @  sì   d Z ddlm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 ddlmZ dd	lmZ er˜dd
lmZ ddlmZ ddlmZ e e¡Zeddœdd„ƒZG dd„ deƒZddddœdd„ZG dd„ deeƒZdS )a&  
Contains command classes which may interact with an index / the network.

Unlike its sister module, req_command, this module still uses lazy imports
so commands which don't always hit the network (e.g. list w/o --outdated or
--uptodate) don't need waste time importing PipSession and friends.
é    )ÚannotationsN)Ú	lru_cache)ÚValues)ÚTYPE_CHECKING)Úcertifi)ÚCommand)ÚCommandContextMixIn)Ú
SSLContext)ÚNormalizedName©Ú
PipSessionzSSLContext | None©Úreturnc                  C  s’   t jdk rt d¡ d S zdd l} W n tyB   t d¡ Y d S 0 zddlm} W n tyr   t d¡ Y d S 0 | 	| j
¡}| t ¡ ¡ |S )N)é   é
   z7Disabling truststore because Python version isn't 3.10+r   z1Disabling truststore since ssl support is missing)Ú
truststorez5Disabling truststore because platform isn't supported)ÚsysÚversion_infoÚloggerÚdebugÚsslÚImportErrorÚwarningÚpip._vendorr   r	   ÚPROTOCOL_TLS_CLIENTÚload_verify_locationsr   Úwhere)r   r   Úctx© r   ú^/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/pip/_internal/cli/index_command.pyÚ_create_truststore_ssl_context!   s     



r    c                      s`   e Zd ZdZddœ‡ fdd„Zedddœd	d
„ƒZdddœdd„Zddddddœdd„Z‡  Z	S )ÚSessionCommandMixinzE
    A class mixin for command classes needing _build_session().
    ÚNoner   c                   s   t ƒ  ¡  d | _d S )N)ÚsuperÚ__init__Ú_session)Úself©Ú	__class__r   r   r$   =   s    
zSessionCommandMixin.__init__r   zlist[str] | None©Úoptionsr   c                 C  sL   g }t |ddƒs*t |ddƒ}|r*| |¡ t |ddƒ}|rD| |¡ |pJdS )z7Return a list of index urls from user-provided options.Úno_indexFÚ	index_urlNÚextra_index_urls)ÚgetattrÚappendÚextend)Úclsr*   Ú
index_urlsÚurlÚurlsr   r   r   Ú_get_index_urlsA   s    

z#SessionCommandMixin._get_index_urlsr   c                 C  s0   | j du r*|  |  |¡¡| _ | j dus*J ‚| j S )zGet a default-managed session.N)r%   Úenter_contextÚ_build_session)r&   r*   r   r   r   Úget_default_sessionO   s    
z'SessionCommandMixin.get_default_sessionNz
int | None)r*   ÚretriesÚtimeoutr   c                 C  sò   ddl m} |j}|r&tj |¡s&J ‚d|jvr8tƒ }nd }||rPtj |d¡nd |d ur^|n|j	|j
|j|  |¡|d�}|jrˆ|j|_|jr–|j|_|js |r´|d ur¬|n|j|_|jrØ|j|jdœ|_d|_|j|_|j |j_|j|j_|S )Nr   r   zlegacy-certszhttp-v2)Úcacher9   Úresume_retriesÚtrusted_hostsr2   Ússl_context)ÚhttpÚhttpsF)Úpip._internal.network.sessionr   Ú	cache_dirÚosÚpathÚisabsÚdeprecated_features_enabledr    Újoinr9   r<   r=   r5   ÚcertÚverifyÚclient_certr:   ÚproxyÚproxiesÚ	trust_envZ	pip_proxyÚno_inputÚauthÚ	promptingZkeyring_provider)r&   r*   r9   r:   r   rB   r>   Úsessionr   r   r   r7   Y   s:    
ú

þ
z"SessionCommandMixin._build_session)NN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r$   Úclassmethodr5   r8   r7   Ú__classcell__r   r   r'   r   r!   8   s     ür!   r   r   r"   )rQ   r*   r   c                 C  s   ddl m} || |ƒ d S )Nr   )Úpip_self_version_check)Ú!pip._internal.self_outdated_checkrX   )rQ   r*   Úcheckr   r   r   Ú_pip_self_version_checkŽ   s    r[   c                   @  s2   e Zd ZdZddddœdd„Zddd	œd
d„ZdS )ÚIndexGroupCommandz–
    Abstract base class for commands with the index_group options.

    This also corresponds to the commands that permit the pip version check.
    r   r
   Úbool)r*   Úpackage_namer   c                 C  s.   |j r*|j  |¡}|du rdS |du r*dS dS )zM
        Determine if pre-releases should be excluded for a package.
        TF)Zrelease_controlZallows_prereleases)r&   r*   r^   Úallow_prereleasesr   r   r   Úshould_exclude_prerelease›   s    z+IndexGroupCommand.should_exclude_prereleaser"   r)   c                 C  s˜   t |dƒsJ ‚|js|jrdS zJ| j|dtd|jƒd�}|� t||ƒ W d  ƒ n1 s\0    Y  W n* ty’   t 	d¡ tj
ddd	� Y n0 dS )
z€
        Do the pip version check if not disabled.

        This overrides the default behavior of not doing the check.
        r+   Nr   é   )r9   r:   z6There was an error checking the latest version of pip.zSee below for errorT)Úexc_info)ÚhasattrÚdisable_pip_version_checkr+   r7   Úminr:   r[   Ú	Exceptionr   r   r   )r&   r*   rQ   r   r   r   Úhandle_pip_version_check¬   s    
ý,
z*IndexGroupCommand.handle_pip_version_checkN)rR   rS   rT   rU   r`   rg   r   r   r   r   r\   ”   s   r\   )rU   Ú
__future__r   ÚloggingrC   r   Ú	functoolsr   Úoptparser   Útypingr   r   r   Úpip._internal.cli.base_commandr   Ú!pip._internal.cli.command_contextr   r   r	   Zpip._vendor.packaging.utilsr
   rA   r   Ú	getLoggerrR   r   r    r!   r[   r\   r   r   r   r   Ú<module>   s(   
V