a
    b3jb@                     @  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 )1zContains 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   z/www/wwwroot/dpstar/app/297b3aabda72fedb274352021c2dd8b5_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 rt||||}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-depszpip 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	rt
|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}|| qq|jrt|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st|}t||jdstd|d|j d||dg D ] }t||jdd}|| qtdd |D rd|_ |s|js|js|j	s|jsd| 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 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   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   
