o
    Ti5                     @  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 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 e8e9Z:d(ddZ;e7j<e7j=e7j>gZ?ed d!d"Z@d)d%d&ZAG d'd! d!eZBdS )*zContains 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)#SubprocessBuildEnvironmentInstaller)
WheelCache)
cmdoptions)IndexGroupCommand)SessionCommandMixin)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_dependency_groups)parse_requirements)InstallRequirement)BaseResolver)TempDirectoryTempDirectoryTypeRegistrytempdir_kindsoptionsr   returnboolc                 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!    r)   ]/var/www/html/evchargy.com/venv/lib/python3.10/site-packages/pip/_internal/cli/req_command.py!should_ignore_regular_constraints0   s   r+   	_CommandTRequirementCommand)boundfunc-Callable[[_CommandT, Values, list[str]], int]c                   s   ddd d fdd}|S )zNDecorator for common logic related to managing temporary
    directories.
    registryr   r"   Nonec                 S  s   t D ]}| |d qd S )NF)KEEPABLE_TEMPDIR_TYPES
set_delete)r1   tr)   r)   r*   configure_tempdir_registryK   s   z0with_cleanup.<locals>.configure_tempdir_registryselfr,   r!   r   args	list[str]intc                   sH   | j d usJ |jr | j  z| ||W S  ty#    | j   w N)tempdir_registryno_cleanr   )r7   r!   r8   r6   r/   r)   r*   wrapperO   s   

zwith_cleanup.<locals>.wrapperN)r1   r   r"   r2   )r7   r,   r!   r   r8   r9   r"   r:   r)   )r/   r?   r)   r>   r*   with_cleanupD   s   
r@   c                      s   e Zd Zd: fddZed;ddZe		d<d=ddZe		 	!	 	 	"	d>d?d-d.Zd@d1d2Z	edAd3d4Z
		dBdCd8d9Z  ZS )Dr-   r8   r   kwr"   r2   c                   s6   t  j|i | | jt  | jt  d S r;   )super__init__cmd_opts
add_optionr
   dependency_groupsr=   )r7   r8   rA   	__class__r)   r*   rC   a   s   zRequirementCommand.__init__r!   r   strc                 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_enabledr(   r)   r)   r*   determine_resolver_variantg   s   
z-RequirementCommand.determine_resolver_variantNr   temp_build_dirr   build_trackerr   sessionr   finderr   use_user_siter#   download_dir
str | None	verbosityr:   r   c	              	   C  s   |j }	|	dus	J d}
| |}|dkr!d|jv }|r td nd}
d}d|jv r/td t|dg }d	|jv }tdi d
|	d|jd|d|jdt	|||dd|j
d|d|d|jd|d|jd|d|d|d|
d|jS )zQ
        Create a RequirementPreparer instance for the given parameters.
        NFrK   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-constraint	build_dirsrc_dirrS   build_isolationZbuild_isolation_installer)rV    build_constraint_feature_enabledcheck_build_depsrO   rP   progress_barrQ   require_hashesrR   
lazy_wheelrU   legacy_resolverresume_retriesr)   )pathrM   features_enabledloggerwarninggetattrr   rX   rY   r   r[   r\   r]   r`   )clsrN   r!   rO   rP   rQ   rR   rS   rU   temp_build_dir_pathr_   resolver_variantr^   rV   rZ   r)   r)   r*   make_requirement_preparero   sr   



z,RequirementCommand.make_requirement_preparerFTto-satisfy-onlypreparerwheel_cacheWheelCache | Noneignore_installedignore_requires_pythonforce_reinstallupgrade_strategypy_version_infotuple[int, ...] | Noner   c                 C  s   t t|j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.
        )isolatedrK   r   N)rk   rQ   rl   make_install_reqrR   ignore_dependenciesrn   ro   rp   rq   rr   )r   r   isolated_moderM   ,pip._internal.resolution.resolvelib.resolver	_internal
resolutionrK   resolverResolverrv   (pip._internal.resolution.legacy.resolverrJ   )rf   rk   rQ   r!   rl   rR   rn   ro   rp   rq   rr   ru   rh   pipr)   r)   r*   make_resolver   sD   
z RequirementCommand.make_resolverr9   list[InstallRequirement]c              
   C  s  g }t |s%|jD ]}t|d|||dD ]}t||jdd}|| qq	|D ]}	t|	d|jdt|ddd}|| q'|jrUt	|jD ]}	t
|	|jdd}|| qE|jD ]}	t|	d|jt|ddd}|| qX|jD ]$}t||||d	D ]}t||jd|jr|jdndd
}|| qzqptdd |D rd|_|s|js|js|jsd| ji}
|jrtdjdi t|
d|jdtdjdi |
|S )zS
        Parse command-line arguments into the corresponding requirements.
        T)
constraintrQ   r!   rP   F)rt   user_suppliedNconfig_settings)
comes_fromrt   r   r   )r   rt   r   )rQ   r!   rP   )rt   r   r   c                 s  s    | ]}|j V  qd S r;   )has_hash_options).0reqr)   r)   r*   	<genexpr>5  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)   )r+   constraintsr   r   rw   appendr   re   rF   r   r   	editablesr   requirementsr!   r'   anyr]   r   
find_linksr   formatdictjoin)r7   r8   r!   rQ   rP   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_locationsrc   info)rQ   r   	locationsr)   r)   r*   trace_basic_infoN  s
   z#RequirementCommand.trace_basic_infotarget_pythonTargetPython | Nonebool | Nonec                 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_binaryro   )link_collectorselection_prefsr   )r   creater   r   prer   r   )r7   r!   rP   r   ro   r   r   r)   r)   r*   _build_package_finderY  s   z(RequirementCommand._build_package_finder)r8   r   rA   r   r"   r2   )r!   r   r"   rI   )Nr   )rN   r   r!   r   rO   r   rP   r   rQ   r   rR   r#   rS   rT   rU   r:   r"   r   )NFTFFrj   N)rk   r   rQ   r   r!   r   rl   rm   rR   r#   rn   r#   ro   r#   rp   r#   rq   rI   rr   rs   r"   r   )
r8   r9   r!   r   rQ   r   rP   r   r"   r   )rQ   r   r"   r2   )NN)
r!   r   rP   r   r   r   ro   r   r"   r   )__name__
__module____qualname__rC   staticmethodrM   classmethodri   r   r   r   r   __classcell__r)   r)   rG   r*   r-   `   s.    	B
8c)r!   r   r"   r#   )r/   r0   r"   r0   )C__doc__
__future__r   loggingr%   	functoolsr   optparser   typingr   r   r   pip._internal.build_envr   pip._internal.cacher	   pip._internal.clir
   Zpip._internal.cli.index_commandr   r   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_dependency_groupr   Zpip._internal.req.req_filer   Zpip._internal.req.req_installr   pip._internal.resolution.baser   pip._internal.utils.temp_dirr   r   r    	getLoggerr   rc   r+   	BUILD_ENVEPHEM_WHEEL_CACHE	REQ_BUILDr3   r,   r@   r-   r)   r)   r)   r*   <module>   sF    


