o
    ñ‘Ojü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>ded fdd„Z?G dd„ deƒZ@G d d!„ d!ee@ƒZAe7jBe7jCe7jDgZEd)d"d#„ZFd$e
de
f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)Ú
SSLContextÚreturnr"   c                  C   sn   t jdk r	tdƒ‚zdd l} W n ty   t d¡ Y d S w zdd l}W n ty0   tdƒ‚w | | 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.   úc/var/www/html/pharmsmart-cdr-gen/venv/lib/python3.10/site-packages/pip/_internal/cli/req_command.pyÚ_create_truststore_ssl_context2   s    

þÿÿr0   c                       s€   e Zd ZdZd‡ fdd„Zededeee	  fdd„ƒZ
dedefd	d
„Z			ddedee dee dedef
dd„Z‡  ZS )ÚSessionCommandMixinzE
    A class mixin for command classes needing _build_session().
    r#   Nc                    s   t ƒ  ¡  d | _d S ©N)ÚsuperÚ__init__Ú_session)Úself©Ú	__class__r.   r/   r4   M   s   

zSessionCommandMixin.__init__Úoptionsc                 C   sL   g }t |ddƒst |ddƒ}|r| |¡ t |ddƒ}|r"| |¡ |p%dS )z7Return a list of index urls from user-provided options.Úno_indexFÚ	index_urlNÚextra_index_urls)ÚgetattrÚappendÚextend)Úclsr9   Ú
index_urlsÚurlÚurlsr.   r.   r/   Ú_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)r5   Úenter_contextÚ_build_session)r6   r9   r.   r.   r/   Úget_default_session_   s   
z'SessionCommandMixin.get_default_sessionFÚretriesÚtimeoutÚfallback_to_certific                 C   sê   |j }|rtj |¡sJ ‚d|jv r&ztƒ }W n ty%   |s!‚ d }Y nw d }t|r2tj |d¡nd |d ur9|n|j	|j
|  |¡|d�}|jrL|j|_|jrS|j|_|jsX|rb|d ur^|n|j|_|jrm|j|jdœ|_|j |j_|S )Nr,   Úhttp)ÚcacherH   Útrusted_hostsrA   Ússl_context)rK   Úhttps)Ú	cache_dirÚosÚpathÚisabsÚfeatures_enabledr0   Ú	Exceptionr   ÚjoinrH   rM   rD   ÚcertÚverifyÚclient_certrI   ÚproxyÚproxiesÚno_inputÚauthÚ	prompting)r6   r9   rH   rI   rJ   rP   rN   Úsessionr.   r.   r/   rF   i   s<   

ýû	
þz"SessionCommandMixin._build_session©r#   N)NNF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r4   Úclassmethodr   r   r   ÚstrrD   r   rG   ÚintÚboolrF   Ú__classcell__r.   r.   r7   r/   r1   G   s(    ûþýüûúr1   c                   @   s"   e Zd ZdZdeddf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.
    r9   r#   Nc                 C   sl   t |dƒsJ ‚|js|jrdS | j|dtd|jƒdd�}|� t||ƒ W d  ƒ dS 1 s/w   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)rH   rI   rJ   )ÚhasattrÚdisable_pip_version_checkr:   rF   ÚminrI   r   )r6   r9   r_   r.   r.   r/   Úhandle_pip_version_check¦   s   
ø
"ÿz*IndexGroupCommand.handle_pip_version_check)ra   rb   rc   rd   r   ro   r.   r.   r.   r/   rj   ž   s    rj   c                   C   sN   t ƒ rdS ttdƒsdS tjdkstjdkrd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!   rl   rQ   r&   Úplatformrp   r*   r+   r.   r.   r.   r/   Úwarn_if_run_as_rootÈ   s   
ÿrt   Úfuncc              	      s>   dt ddfdd„‰ dtdtdtt dtt f‡ ‡fd	d
„}|S )zNDecorator for common logic related to managing temporary
    directories.
    Úregistryr#   Nc                 S   s   t D ]}|  |d¡ qd S )NF)ÚKEEPABLE_TEMPDIR_TYPESÚ
set_delete)rv   Útr.   r.   r/   Úconfigure_tempdir_registryë   s   ÿz0with_cleanup.<locals>.configure_tempdir_registryr6   r9   Úargsc                    sH   | j d usJ ‚|jrˆ | j ƒ zˆ| ||ƒW S  ty#   ˆ | j ƒ ‚ w r2   )Útempdir_registryÚno_cleanr   )r6   r9   r{   ©rz   ru   r.   r/   Úwrapperï   s   

ûzwith_cleanup.<locals>.wrapper)r   ÚRequirementCommandr   r   r   r   rg   )ru   r   r.   r~   r/   Úwith_cleanupæ   s   ÿÿÿþr�   c                       sH  e Zd Zdededdf‡ fdd„Zededefdd	„ƒZe			
d)de
dedededededee dedefdd„ƒZe									d*dedededee dedededededee deeedf  defd d!„ƒZdee dedededee f
d"d#„Zededdfd$d%„ƒZ		d+deded&ee dee def
d'd(„Z‡  ZS ),r€   r{   Úkwr#   Nc                    s&   t ƒ j|i |¤Ž | j t ¡ ¡ d S r2   )r3   r4   Úcmd_optsÚ
add_optionr
   r}   )r6   r{   r‚   r7   r.   r/   r4     s   zRequirementCommand.__init__r9   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©r9   r.   r.   r/   Údetermine_resolver_variant  s   
z-RequirementCommand.determine_resolver_variantr   Útemp_build_dirÚbuild_trackerr_   ÚfinderÚuse_user_siteÚdownload_dirÚ	verbosityc	                 C   s‚   |j }	|	dus	J ‚|  |¡}
|
dkrd|jv }|rt d¡ nd}d|jv r+t 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‹   r_   Úprogress_barrŒ   Úrequire_hashesr�   Ú
lazy_wheelr�   )rR   r‰   rT   r*   r+   r   r‘   r’   r“   r”   r•   )r@   rŠ   r9   r‹   r_   rŒ   r�   rŽ   r�   Útemp_build_dir_pathÚresolver_variantr–   r.   r.   r/   Úmake_requirement_preparer  s<   

ÿ€
ÿóz,RequirementCommand.make_requirement_preparerFTúto-satisfy-onlyÚpreparerÚwheel_cacheÚignore_installedÚignore_requires_pythonÚforce_reinstallÚupgrade_strategyÚ
use_pep517Úpy_version_info.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…   )r@   r›   rŒ   r9   rœ   r�   r�   rž   rŸ   r    r¡   r¢   r¥   r˜   Úpipr.   r.   r/   Úmake_resolverD  sH   
ü
õõz RequirementCommand.make_resolverc                 C   s^  g }|j D ]}t|d|||d�D ]}t||jdd�}| |¡ qq|D ]}	t|	d|j|jdt|ddƒd�}| |¡ q#|jD ]}	t	|	d|j|jt|ddƒd�}| |¡ q>|j
D ]}t||||d	�D ]}t||j|jdd
�}| |¡ qbqXtdd„ |D ƒƒr�d|_|s­|js­|j
s­d| ji}
|jr£tdjdi t|
d |j¡d�¤Žƒ‚tdjdi |
¤Žƒ‚|S )zS
        Parse command-line arguments into the corresponding requirements.
        T)Ú
constraintrŒ   r9   r_   F)r¤   Úuser_suppliedNr£   )r¤   r¡   r²   r£   )r²   r¤   r¡   r£   )rŒ   r9   r_   )r¤   r¡   r²   c                 s   s   � | ]}|j V  qd S r2   )Úhas_hash_options)Ú.0Úreqr.   r.   r/   Ú	<genexpr>½  s   € 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}")r.   )Úconstraintsr   r   r§   r>   r   r¡   r=   Ú	editablesr   ÚrequirementsÚanyr•   r·   Ú
find_linksr   ÚformatÚdictrV   )r6   r{   r9   rŒ   r_   r¼   ÚfilenameÚ
parsed_reqÚ
req_to_addrµ   Úoptsr.   r.   r/   Úget_requirements€  s†   


ûýô
ú

û

ÿü÷
ÿþÿÿÿÿz#RequirementCommand.get_requirementsc                 C   s$   | j }| ¡ }|rt |¡ dS dS )zE
        Trace basic information about the provided objects.
        N)Úsearch_scopeÚget_formatted_locationsr*   Úinfo)rŒ   rÆ   Ú	locationsr.   r.   r/   Útrace_basic_infoÑ  s
   ÿz#RequirementCommand.trace_basic_infoÚtarget_pythonc                 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   )r6   r9   r_   rË   rž   rÐ   rÑ   r.   r.   r/   Ú_build_package_finderÜ  s   ûýz(RequirementCommand._build_package_finder)Nr   )NFTFFrš   NN)NN)ra   rb   rc   r   r4   Ústaticmethodr   rf   r‰   re   r   r   r   r   rh   r   rg   r   r™   r	   r   r   r°   r   r   rÅ   rÊ   r   rÔ   ri   r.   r.   r7   r/   r€     s¬    	÷þýüûúùø	÷
ö3ôþýüûúùø	÷
öõôó;þýüû
úQûþýüûúr€   r`   )Ird   ÚloggingrQ   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   Úpip._internal.req.req_filer   Ú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"   Ú	getLoggerra   r*   r0   r1   rj   Ú	BUILD_ENVÚEPHEM_WHEEL_CACHEÚ	REQ_BUILDrw   rt   r�   r€   r.   r.   r.   r/   Ú<module>   sN    
W$ý
