a
    <Bìjb@  ã                   @  sì  d Z ddlm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 ddl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 ddl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' ddl(m)Z) ddl*m+Z+ ddl,m-Z-m.Z.m/Z/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z= ddl>m?Z?m@Z@mAZA e BeC¡ZDdddœd d!„ZEeAjFeAjGeAjHgZIed"d#d$�ZJd%d%d&œd'd(„ZKd)d*dd+d,d-œd.d/„ZLG d0d#„ d#eƒZMdS )1zðContains the RequirementCommand base class.

This class is in a separate module so the commands that do not always
need PackageFinder capability don't unnecessarily import the
PackageFinder machinery and all its vendored dependencies, etc.
é    )ÚannotationsN)Úpartial)ÚValues)ÚAnyÚCallableÚTypeVar)ÚBuildEnvironmentInstallerÚ"InprocessBuildEnvironmentInstallerÚ#SubprocessBuildEnvironmentInstaller)Ú
WheelCache)Ú
cmdoptions)Úmake_target_python)ÚIndexGroupCommand)ÚSessionCommandMixin)ÚCommandErrorÚPreviousBuildDirErrorÚUnsupportedPythonVersion)Ú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)ÚPEP723ExceptionÚpep723_metadata)Úparse_dependency_groups)Úparse_requirements)ÚInstallRequirement)ÚBaseResolver)Úcheck_requires_python)ÚTempDirectoryÚTempDirectoryTypeRegistryÚtempdir_kindsr   Úbool©ÚoptionsÚreturnc                 C  s   t j d¡dkS )zº
    Check if regular constraints should be ignored because
    we are in a isolated build process and build constraints
    feature is enabled but no build constraints were passed.
    Z _PIP_IN_BUILD_IGNORE_CONSTRAINTSÚ1)ÚosÚenvironÚget©r*   © r1   ú\/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/pip/_internal/cli/req_command.pyÚ!should_ignore_regular_constraints;   s    r3   Ú	_CommandTÚRequirementCommand)Úboundz-Callable[[_CommandT, Values, list[str]], int])Úfuncr+   c                   s.   dddœdd„‰ dddd	d
œ‡ ‡fdd„}|S )zNDecorator for common logic related to managing temporary
    directories.
    r&   ÚNone)Úregistryr+   c                 S  s   t D ]}|  |d¡ qd S )NF)ÚKEEPABLE_TEMPDIR_TYPESÚ
set_delete)r9   Útr1   r1   r2   Úconfigure_tempdir_registryV   s    z0with_cleanup.<locals>.configure_tempdir_registryr4   r   ú	list[str]Úint)Úselfr*   Úargsr+   c                   sP   | j d usJ ‚|jrˆ | j ƒ zˆ| ||ƒW S  tyJ   ˆ | j ƒ ‚ Y n0 d S ©N)Útempdir_registryÚno_cleanr   )r@   r*   rA   ©r=   r7   r1   r2   ÚwrapperZ   s    

zwith_cleanup.<locals>.wrapperr1   )r7   rF   r1   rE   r2   Úwith_cleanupO   s    rG   r>   r   r   úlist[InstallRequirement])Úconstraint_filesÚfinderr*   Úsessionr+   c                 C  sD   g }| D ]6}t |d|||d�D ]}t||jdd�}| |¡ qq|S )NT)Ú
constraintrJ   r*   rK   F©ÚisolatedÚuser_supplied)r!   r   Úisolated_modeÚappend)rI   rJ   r*   rK   ÚrequirementsÚfilenameÚ
parsed_reqÚ
req_to_addr1   r1   r2   Úparse_constraint_filesk   s     û
ýrV   c                      sÈ   e Zd Zddddœ‡ fdd„Zedddœd	d
„ƒZed.ddddddddddœ	dd„ƒZed/ddddddddddddœdd „ƒZd!dddd"d#œd$d%„Z	eddd&œd'd(„ƒZ
d0ddd)d*dd+œd,d-„Z‡  ZS )1r5   r   r8   )rA   Úkwr+   c                   s6   t ƒ j|i |¤Ž | j t ¡ ¡ | j t ¡ ¡ d S rB   )ÚsuperÚ__init__Úcmd_optsÚ
add_optionr   Údependency_groupsrD   )r@   rA   rW   ©Ú	__class__r1   r2   rY   …   s    zRequirementCommand.__init__r   Ústrr)   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Ú
resolvelib)Údeprecated_features_enabledr0   r1   r1   r2   Údetermine_resolver_variant‹   s    
z-RequirementCommand.determine_resolver_variantNr   r%   r   r   r   r(   z
str | Noner?   r   )	Útemp_build_dirr*   Úbuild_trackerrK   rJ   Úuse_user_siteÚdownload_dirÚ	verbosityr+   c	                 C  sä   |j }	|	dusJ ‚d}
|  |¡}|dkrBd|jv }|r^t d¡ nd}
d}d|jv r^t d¡ t|dg ƒ}d	|jv }d
|jv r¦t||||ƒ}t||||t|j	ƒd�}nt
|||d�}t|	|j||j||j|||j||j||||
d�S )zQ
        Create a RequirementPreparer instance for the given parameters.
        NFra   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.Tz;fast-deps has no effect when used with the legacy resolver.Úbuild_constraintszbuild-constraintzinprocess-build-deps)rJ   re   ri   rh   Úwheel_cache)ri   Ú build_constraint_feature_enabled)Ú	build_dirÚsrc_dirrg   Úbuild_isolationZbuild_isolation_installerÚcheck_build_depsre   rK   Úprogress_barrJ   Úrequire_hashesrf   Ú
lazy_wheelrh   Úlegacy_resolver)Úpathrc   Úfeatures_enabledÚloggerÚwarningÚgetattrrV   r	   r   Ú	cache_dirr
   r   rm   rn   ro   rp   rq   )Úclsrd   r*   re   rK   rJ   rf   rg   rh   Útemp_build_dir_pathrs   Úresolver_variantrr   ri   rk   Zbuild_constraint_reqsZenv_installerr1   r1   r2   Úmake_requirement_preparer“   sh    

ÿ
ÿÿ
ÿûýñz,RequirementCommand.make_requirement_preparerFTúto-satisfy-onlyzWheelCache | Noneztuple[int, ...] | Noner#   )ÚpreparerrJ   r*   rj   rf   Úignore_installedÚignore_requires_pythonÚforce_reinstallÚupgrade_strategyÚpy_version_infor+   c                 C  s„   t t|jd�}|  |¡}|dkrRd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.
        )rN   ra   r   N)r   rJ   rj   Úmake_install_reqrf   Úignore_dependenciesr€   r�   r‚   rƒ   r„   )r   r   rP   rc   Ú,pip._internal.resolution.resolvelib.resolverÚ	_internalÚ
resolutionra   ÚresolverÚResolverr†   Ú(pip._internal.resolution.legacy.resolverr`   )rz   r   rJ   r*   rj   rf   r€   r�   r‚   rƒ   r„   r…   r|   Úpipr1   r1   r2   Úmake_resolverä   sD    þ
õõz RequirementCommand.make_resolverr>   rH   )rA   r*   rJ   rK   r+   c              
   C  s„  g }t |ƒs&t|j|||ƒ}| |¡ |D ]4}| ¡ s8q*t|d|jdt|ddƒd�}| |¡ q*|j	r�t
|j	ƒD ]}t||jdd�}| |¡ qp|jD ](}t|d|jt|ddƒd�}| |¡ q–|jD ]H}	t|	|||d�D ]2}
t|
|jd|
jrú|
j d¡ndd�}| |¡ qÚqÆ|j�rôt|jƒd	k�r0td
ƒ‚|jd }zt|ƒ}W n0 t�yv } zt|jƒ‚W Y d}~n
d}~0 0 | dd¡}|�rÆ|j�sÆt|ƒ}t||jd��sÆtd|›d|j› d|›�ƒ‚| dg ¡D ] }t||jdd�}| |¡ �qÒtdd„ |D ƒƒ�rd|_ |�s€|j�s€|j�s€|j	�s€|j�s€d| j!i}|j"�rltdj#f i t$|d %|j"¡d�¤Žƒ‚ntdj#f i |¤Žƒ‚|S )zS
        Parse command-line arguments into the corresponding requirements.
        NTÚconfig_settings)Ú
comes_fromrN   rO   r�   rM   )rO   rN   r�   )rJ   r*   rK   )rN   rO   r�   é   z1--requirements-from-script can only be given oncer   zrequires-pythonÚ )Úrequires_pythonÚversion_infozScript z requires a different Python: z not in Zdependenciesc                 s  s   | ]}|j V  qd S rB   )Úhas_hash_options)Ú.0Úreqr1   r1   r2   Ú	<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}"))&r3   rV   ÚconstraintsÚextendÚstripr   rP   rx   rQ   r\   r    r   Ú	editablesr   rR   r!   r   r*   r/   Zrequirements_from_scriptsÚlenr   r   r   Úmsgr�   r   r$   r„   r   Ú
py_versionÚanyrq   rš   Ú
find_linksÚformatÚdictÚjoin)r@   rA   r*   rJ   rK   rR   r�   r—   rU   rS   rT   ÚscriptZscript_metadataÚexcZscript_requires_pythonÚtarget_pythonÚoptsr1   r1   r2   Úget_requirements  sÈ    

ÿ

ûý

ü
ÿ
ÿù

 þÿÿÿýÿþýüû
þÿÿÿz#RequirementCommand.get_requirements)rJ   r+   c                 C  s    | j }| ¡ }|rt |¡ dS )zE
        Trace basic information about the provided objects.
        N)Úsearch_scopeÚget_formatted_locationsrv   Úinfo)rJ   r®   Ú	locationsr1   r1   r2   Útrace_basic_info™  s    z#RequirementCommand.trace_basic_infozTargetPython | Nonezbool | None)r*   rK   r«   r�   r+   c                 C  s:   t j||d�}td|j|j|j|d�}tj||||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.
        r0   T)Úallow_yankedÚformat_controlÚrelease_controlÚprefer_binaryr�   )Úlink_collectorÚselection_prefsr«   Úuploaded_prior_to)r   Úcreater   r´   rµ   r¶   r   r¹   )r@   r*   rK   r«   r�   r·   r¸   r1   r1   r2   Ú_build_package_finder¤  s    ûüz(RequirementCommand._build_package_finder)Nr   )NFTFFr~   N)NN)Ú__name__Ú
__module__Ú__qualname__rY   Ústaticmethodrc   Úclassmethodr}   rŽ   r­   r²   r»   Ú__classcell__r1   r1   r]   r2   r5   „   s,   	  ÷"P       õ&8|  û)NÚ__doc__Ú
__future__r   Úloggingr-   Ú	functoolsr   Úoptparser   Útypingr   r   r   Úpip._internal.build_envr   r	   r
   Úpip._internal.cacher   Zpip._internal.clir   Zpip._internal.cli.cmdoptionsr   Zpip._internal.cli.index_commandr   r   Úpip._internal.exceptionsr   r   r   Úpip._internal.index.collectorr   Ú"pip._internal.index.package_finderr   Ú$pip._internal.models.selection_prefsr   Ú"pip._internal.models.target_pythonr   Úpip._internal.network.sessionr   Z,pip._internal.operations.build.build_trackerr   Ú pip._internal.operations.preparer   Úpip._internal.req.constructorsr   r   r   r   Zpip._internal.req.pep723r   r   Z&pip._internal.req.req_dependency_groupr    Zpip._internal.req.req_filer!   Zpip._internal.req.req_installr"   Úpip._internal.resolution.baser#   Úpip._internal.utils.packagingr$   Úpip._internal.utils.temp_dirr%   r&   r'   Ú	getLoggerr¼   rv   r3   Ú	BUILD_ENVÚEPHEM_WHEEL_CACHEÚ	REQ_BUILDr:   r4   rG   rV   r5   r1   r1   r1   r2   Ú<module>   sL   
ý