a
    |Ä#düF  ã                   @   sÞ  d 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	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 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  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- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5m6Z6m7Z7 ddl8m9Z9 e	�r^ddl:m;Z; e <e=¡Z>ed dœdd„Z?G dd„ deƒZ@G d d!„ d!ee@ƒZAe7jBe7jCe7jDgZEddœd"d#„ZFe
e
d$œd%d&„ZGG d'd(„ d(eAƒZHdS ))a  Contains the Command base classes that depend on PipSession.

The classes in this module are in a separate module so the commands not
needing download / PackageFinder capability don't unnecessarily import the
PackageFinder machinery and all its vendored dependencies, etc.
é    N)Úpartial)ÚValues)ÚTYPE_CHECKINGÚAnyÚListÚOptionalÚTuple)Ú
WheelCache)Ú
cmdoptions)ÚCommand)ÚCommandContextMixIn)ÚCommandErrorÚPreviousBuildDirError)ÚLinkCollector)ÚPackageFinder)ÚSelectionPreferences)ÚTargetPython)Ú
PipSession)ÚBuildTracker)ÚRequirementPreparer)Úinstall_req_from_editableÚinstall_req_from_lineÚ#install_req_from_parsed_requirementÚinstall_req_from_req_string)Úparse_requirements)ÚInstallRequirement)ÚBaseResolver)Úpip_self_version_check)ÚTempDirectoryÚTempDirectoryTypeRegistryÚtempdir_kinds)Úrunning_under_virtualenv)Ú
SSLContextr"   ©Úreturnc                  C   sr   t jdk rtdƒ‚zdd l} W n ty<   t d¡ Y d S 0 zdd l}W n tyd   tdƒ‚Y n0 | | j	¡S )N)é   é
   z9The truststore feature is only available for Python 3.10+r   z1Disabling truststore since ssl support is missingz]To use the truststore feature, 'truststore' must be installed into pip's current environment.)
ÚsysÚversion_infor   ÚsslÚImportErrorÚloggerÚwarningÚ
truststorer"   ÚPROTOCOL_TLS_CLIENT)r)   r-   © r/   úT/var/www/html/gsl.tools/lib/python3.9/site-packages/pip/_internal/cli/req_command.pyÚ_create_truststore_ssl_context2   s    

ÿ
r1   c                       sr   e Zd ZdZddœ‡ fdd„Zeeeee	  dœdd„ƒZ
eedœd	d
„Zdeee ee eedœdd„Z‡  ZS )ÚSessionCommandMixinzE
    A class mixin for command classes needing _build_session().
    Nr#   c                    s   t ƒ  ¡  d | _d S ©N)ÚsuperÚ__init__Ú_session)Úself©Ú	__class__r/   r0   r5   M   s    
zSessionCommandMixin.__init__©Ú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/   r0   Ú_get_index_urlsQ   s    

z#SessionCommandMixin._get_index_urlsc                 C   s0   | j du r*|  |  |¡¡| _ | j dus*J ‚| j S )zGet a default-managed session.N)r6   Úenter_contextÚ_build_session)r7   r;   r/   r/   r0   Úget_default_session_   s    
z'SessionCommandMixin.get_default_sessionF)r;   ÚretriesÚtimeoutÚfallback_to_certifir$   c                 C   sì   |j }|rtj |¡sJ ‚d|jv rNz
tƒ }W qR tyJ   |sB‚ d }Y qR0 nd }t|rftj |d¡nd |d urt|n|j	|j
|  |¡|d�}|jrš|j|_|jr¨|j|_|js²|rÆ|d ur¾|n|j|_|jrÜ|j|jdœ|_|j |j_|S )Nr-   Úhttp)ÚcacherJ   Útrusted_hostsrC   Ússl_context)rM   Úhttps)Ú	cache_dirÚosÚpathÚisabsÚfeatures_enabledr1   Ú	Exceptionr   ÚjoinrJ   rO   rF   ÚcertÚverifyÚclient_certrK   ÚproxyÚproxiesÚno_inputÚauthÚ	prompting)r7   r;   rJ   rK   rL   rR   rP   Úsessionr/   r/   r0   rH   i   s:    

û	
þz"SessionCommandMixin._build_session)NNF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r5   Úclassmethodr   r   r   ÚstrrF   r   rI   ÚintÚboolrH   Ú__classcell__r/   r/   r8   r0   r2   G   s      ûúr2   c                   @   s    e Zd ZdZe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.
    Nr:   c                 C   sj   t |dƒsJ ‚|js|jrdS | j|dtd|jƒdd�}|� t||ƒ W d  ƒ n1 s\0    Y  dS )z€
        Do the pip version check if not disabled.

        This overrides the default behavior of not doing the check.
        r<   Nr   é   T)rJ   rK   rL   )ÚhasattrÚdisable_pip_version_checkr<   rH   ÚminrK   r   )r7   r;   ra   r/   r/   r0   Úhandle_pip_version_check¦   s    
ø
z*IndexGroupCommand.handle_pip_version_check)rb   rc   rd   re   r   rp   r/   r/   r/   r0   rk   ž   s   rk   c                   C   sN   t ƒ r
dS ttdƒsdS tjdks,tjdkr0dS t ¡ dkr@dS t d¡ dS )züOutput a warning for sudo users on Unix.

    In a virtual environment, sudo pip still writes to virtualenv.
    On Windows, users may run pip as Administrator without issues.
    This warning only applies to Unix root users outside of virtualenv.
    NÚgetuidÚwin32Úcygwinr   zÔRunning pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv)r!   rm   rS   r'   Úplatformrq   r+   r,   r/   r/   r/   r0   Úwarn_if_run_as_rootÈ   s    
ÿru   )Úfuncr$   c                    s6   t ddœdd„‰ tttt tt dœ‡ ‡fdd„}|S )zNDecorator for common logic related to managing temporary
    directories.
    N)Úregistryr$   c                 S   s   t D ]}|  |d¡ qd S )NF)ÚKEEPABLE_TEMPDIR_TYPESÚ
set_delete)rw   Útr/   r/   r0   Úconfigure_tempdir_registryë   s    z0with_cleanup.<locals>.configure_tempdir_registry)r7   r;   Úargsr$   c                    sP   | j d usJ ‚|jrˆ | j ƒ zˆ| ||ƒW S  tyJ   ˆ | j ƒ ‚ Y n0 d S r3   )Útempdir_registryÚno_cleanr   )r7   r;   r|   ©r{   rv   r/   r0   Úwrapperï   s    

zwith_cleanup.<locals>.wrapper)r   ÚRequirementCommandr   r   r   r   rh   )rv   r€   r/   r   r0   Úwith_cleanupæ   s
    
þr‚   c                       sò   e Zd Zeeddœ‡ fdd„Zeeedœdd„ƒZe	de
eeeeeee eed	œ	d
d„ƒZe	deeeee eeeeeee eeedf  edœdd„ƒZee eeeee dœdd„Zeeddœdd„ƒZdeeee ee edœdd„Z‡  ZS )r�   N)r|   Úkwr$   c                    s&   t ƒ j|i |¤Ž | j t ¡ ¡ d S r3   )r4   r5   Úcmd_optsÚ
add_optionr
   r~   )r7   r|   rƒ   r8   r/   r0   r5     s    zRequirementCommand.__init__r:   c                 C   s   d| j v rdS dS )zEDetermines which resolver should be used, based on the given options.zlegacy-resolverÚlegacyú2020-resolver)Údeprecated_features_enabled©r;   r/   r/   r0   Údetermine_resolver_variant  s    
z-RequirementCommand.determine_resolver_variantr   )	Útemp_build_dirr;   Úbuild_trackerra   ÚfinderÚuse_user_siteÚdownload_dirÚ	verbosityr$   c	                 C   s‚   |j }	|	dusJ ‚|  |¡}
|
dkr>d|jv }|rVt d¡ nd}d|jv rVt d¡ t|	|j||j|j|||j	||j
|||d�S )zQ
        Create a RequirementPreparer instance for the given parameters.
        Nr‡   z	fast-depszÊpip is using lazily downloaded wheels using HTTP range requests to obtain dependency information. This experimental feature is enabled through --use-feature=fast-deps and it is not ready for production.Fz;fast-deps has no effect when used with the legacy resolver.)Ú	build_dirÚsrc_dirr�   Úbuild_isolationÚcheck_build_depsrŒ   ra   Úprogress_barr�   Úrequire_hashesrŽ   Ú
lazy_wheelr�   )rT   rŠ   rV   r+   r,   r   r’   r“   r”   r•   r–   )rB   r‹   r;   rŒ   ra   r�   rŽ   r�   r�   Útemp_build_dir_pathÚresolver_variantr—   r/   r/   r0   Úmake_requirement_preparer  s:    

ÿ
ÿóz,RequirementCommand.make_requirement_preparerFTúto-satisfy-only.)Úpreparerr�   r;   Úwheel_cacherŽ   Úignore_installedÚignore_requires_pythonÚforce_reinstallÚupgrade_strategyÚ
use_pep517Úpy_version_infor$   c                 C   s�   t t|j|
t|ddƒd�}|  |¡}|dkr^ddl}|jjjj	j
||||||j||||	|d�S ddl}|jjjj	j
||||||j||||	|d�S )zF
        Create a Resolver instance for the given parameters.
        Úconfig_settingsN)Úisolatedr¢   r¤   r‡   r   )rœ   r�   r�   Úmake_install_reqrŽ   Úignore_dependenciesrž   rŸ   r    r¡   r£   )r   r   Úisolated_moder?   rŠ   Ú,pip._internal.resolution.resolvelib.resolverÚ	_internalÚ
resolutionÚ
resolvelibÚresolverÚResolverr§   Ú(pip._internal.resolution.legacy.resolverr†   )rB   rœ   r�   r;   r�   rŽ   rž   rŸ   r    r¡   r¢   r£   r¦   r™   Úpipr/   r/   r0   Úmake_resolverD  sH    
ü
õõz RequirementCommand.make_resolver)r|   r;   r�   ra   r$   c                 C   sj  g }|j D ]6}t|d|||d�D ]}t||jdd�}| |¡ q q
|D ].}	t|	d|j|jdt|ddƒd�}| |¡ qF|jD ],}	t	|	d|j|jt|ddƒd�}| |¡ q||j
D ]8}t||||d	�D ]"}t||j|jdd
�}| |¡ qÄq°tdd„ |D ƒƒ�rd|_|�sf|j�sf|j
�sfd| ji}
|j�rRtdjf i t|
d |j¡d�¤Žƒ‚ntdjf i |
¤Žƒ‚|S )zS
        Parse command-line arguments into the corresponding requirements.
        T)Ú
constraintr�   r;   ra   F)r¥   Úuser_suppliedNr¤   )r¥   r¢   r³   r¤   )r³   r¥   r¢   r¤   )r�   r;   ra   )r¥   r¢   r³   c                 s   s   | ]}|j V  qd S r3   )Úhas_hash_options)Ú.0Úreqr/   r/   r0   Ú	<genexpr>½  ó    z6RequirementCommand.get_requirements.<locals>.<genexpr>ÚnamezXYou must give at least one requirement to {name} (maybe you meant "pip {name} {links}"?)ú )ÚlinkszHYou must give at least one requirement to {name} (see "pip help {name}"))Úconstraintsr   r   r¨   r@   r   r¢   r?   Ú	editablesr   ÚrequirementsÚanyr–   r¹   Ú
find_linksr   ÚformatÚdictrX   )r7   r|   r;   r�   ra   r¾   ÚfilenameÚ
parsed_reqÚ
req_to_addr¶   Úoptsr/   r/   r0   Úget_requirements€  sz    

û
ý
ú

û
ÿ
ü
þÿÿÿz#RequirementCommand.get_requirements)r�   r$   c                 C   s    | j }| ¡ }|rt |¡ dS )zE
        Trace basic information about the provided objects.
        N)Úsearch_scopeÚget_formatted_locationsr+   Úinfo)r�   rÈ   Ú	locationsr/   r/   r0   Útrace_basic_infoÑ  s    z#RequirementCommand.trace_basic_info)r;   ra   Útarget_pythonrŸ   r$   c                 C   s6   t j||d�}td|j|j|j|d�}tj|||d�S )zÛ
        Create a package finder appropriate to this requirement command.

        :param ignore_requires_python: Whether to ignore incompatible
            "Requires-Python" values in links. Defaults to False.
        r‰   T)Úallow_yankedÚformat_controlÚallow_all_prereleasesÚprefer_binaryrŸ   )Úlink_collectorÚselection_prefsrÍ   )r   Úcreater   rÏ   ÚprerÑ   r   )r7   r;   ra   rÍ   rŸ   rÒ   rÓ   r/   r/   r0   Ú_build_package_finderÜ  s    ûýz(RequirementCommand._build_package_finder)Nr   )NFTFFr›   NN)NN)rb   rc   rd   r   r5   Ústaticmethodr   rg   rŠ   rf   r   r   r   r   ri   r   rh   r   rš   r	   r   r   r±   r   r   rÇ   rÌ   r   rÖ   rj   r/   r/   r8   r0   r�     sr   	  ÷ö3        ôó=úQ  ûúr�   )Ire   ÚloggingrS   r'   Ú	functoolsr   Úoptparser   Útypingr   r   r   r   r   Úpip._internal.cacher	   Úpip._internal.clir
   Úpip._internal.cli.base_commandr   Ú!pip._internal.cli.command_contextr   Úpip._internal.exceptionsr   r   Úpip._internal.index.collectorr   Ú"pip._internal.index.package_finderr   Ú$pip._internal.models.selection_prefsr   Ú"pip._internal.models.target_pythonr   Úpip._internal.network.sessionr   Ú,pip._internal.operations.build.build_trackerr   Ú pip._internal.operations.preparer   Úpip._internal.req.constructorsr   r   r   r   Zpip._internal.req.req_filer   Zpip._internal.req.req_installr   Úpip._internal.resolution.baser   Ú!pip._internal.self_outdated_checkr   Úpip._internal.utils.temp_dirr   r   r    Úpip._internal.utils.virtualenvr!   r)   r"   Ú	getLoggerrb   r+   r1   r2   rk   Ú	BUILD_ENVÚEPHEM_WHEEL_CACHEÚ	REQ_BUILDrx   ru   r‚   r�   r/   r/   r/   r0   Ú<module>   sL   
W$ý