o
    jLD                     @  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/m0Z0m1Z1 ddl2m3Z3m4Z4 ddl5m6Z6 ddl7m8Z8 ddl9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@Z@mAZA ddlBmCZCmDZDmEZE eFeGZHd5d"d#ZIeEjJeEjKeEjLgZMed$d%d&ZNd6d)d*ZOd7d2d3ZPG d4d% d%eZQdS )8zContains 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_pylock_packageinstall_req_from_req_string)PEP723Exceptionpep723_metadata)parse_dependency_groups)parse_requirements)InstallRequirement)BaseResolver)check_requires_python)is_valid_pylock_filenameselect_from_pylock_path_or_url)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+    r3   ^/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/pip/_internal/cli/req_command.py!should_ignore_regular_constraints@   s   r5   	_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)r;   tr3   r3   r4   configure_tempdir_registry[   s   z0with_cleanup.<locals>.configure_tempdir_registryselfr6   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   )rB   r+   rC   rA   r9   r3   r4   wrapper_   s   

zwith_cleanup.<locals>.wrapperN)r;   r)   r,   r<   )rB   r6   r+   r   rC   rD   r,   rE   r3   )r9   rJ   r3   rI   r4   with_cleanupT   s   
rK   constraint_filesrD   finderr   sessionr   list[InstallRequirement]c                 C  sD   g }| D ]}t |d|||dD ]}t||jdd}|| qq|S )NT)
constraintrM   r+   rN   Fisolateduser_supplied)r"   r   isolated_modeappend)rL   rM   r+   rN   requirementsfilename
parsed_req
req_to_addr3   r3   r4   parse_constraint_filesp   s"   
rZ   c                      s   e Zd Zd9 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d@d3d4Z
		 dAdBd7d8Z  ZS )Cr7   rC   r   kwr,   r<   c                   s6   t  j|i | | jt  | jt  d S rF   )super__init__cmd_opts
add_optionr   dependency_groupsrH   )rB   rC   r[   	__class__r3   r4   r]      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_enabledr2   r3   r3   r4   determine_resolver_variant   s   
z-RequirementCommand.determine_resolver_variantNr   temp_build_dirr(   build_trackerr   rN   r   rM   r   use_user_siter-   download_dir
str | None	verbosityrE   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 }d
|jv rSt||||}t||||t|j	d}nt
|||d}t|	|j||j||j|||j||j||||
dS )zQ
        Create a RequirementPreparer instance for the given parameters.
        NFre   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)rM   ri   rn   rm   wheel_cache)rn    build_constraint_feature_enabled)	build_dirsrc_dirrk   build_isolationZbuild_isolation_installercheck_build_depsri   rN   progress_barrM   require_hashesrj   
lazy_wheelrm   legacy_resolver)pathrg   features_enabledloggerwarninggetattrrZ   r	   r   	cache_dirr
   r   rr   rs   rt   ru   rv   )clsrh   r+   ri   rN   rM   rj   rk   rm   temp_build_dir_pathrx   resolver_variantrw   rn   rp   Zbuild_constraint_reqsZenv_installerr3   r3   r4   make_requirement_preparer   sj   



z,RequirementCommand.make_requirement_preparerFTto-satisfy-onlypreparerro   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.
        )rR   re   r   N)r   rM   ro   make_install_reqrj   ignore_dependenciesr   r   r   r   r   )r   r   rT   rg   ,pip._internal.resolution.resolvelib.resolver	_internal
resolutionre   resolverResolverr   (pip._internal.resolution.legacy.resolverrd   )r   r   rM   r+   ro   rj   r   r   r   r   r   r   r   pipr3   r3   r4   make_resolver   sD   
z RequirementCommand.make_resolverrD   rO   c                 C  s  g }t |st|j|||}|| |D ]}| sqt|d|jdt|ddd}|| q|j	rHt
|j	D ]}t||jdd}|| q8|jD ]}t|d|jt|ddd}|| qK|jD ]F}	t|	rtd t|	|dD ]\}
}|t|
||	|jdd	 qtqct|	|||d
D ]}t||jd|jr|jdndd}|| qqc|jrt|jdkrtd|jd }zt|}W n ty } zt|jd}~ww |dd}|r|jst |}t!||j"dst#d|d|j$ d||dg D ]}t||jdd}|| q t%dd |D rd|_&|sV|jsV|jsV|j	sV|jsVd| j'i}|j(rLtdj)di t*|d+|j(dtdj)di ||S )zS
        Parse command-line arguments into the corresponding requirements.
        NTconfig_settings)
comes_fromrR   rS   r   rQ   )rS   rR   r   zUsing pylock.toml as a requirements source is an experimental feature. It may be removed/changed in a future release without prior warning.)rN   )rS   )rM   r+   rN   )rR   rS   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 rF   )has_hash_options).0reqr3   r3   r4   	<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}")r3   ),r5   rZ   constraintsextendstripr   rT   r}   rU   r`   r!   r   	editablesr   rV   r&   r{   r|   r'   r   format_controlr"   r   r+   r1   Zrequirements_from_scriptslenr   r    r   msgr   r   r%   r   r   
py_versionanyrv   r   
find_linksformatdictjoin)rB   rC   r+   rM   rN   rV   r   r   rY   rW   packageZpackage_distrX   scriptZscript_metadataexcZscript_requires_pythontarget_pythonoptsr3   r3   r4   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)rM   r   	locationsr3   r3   r4   trace_basic_info  s
   z#RequirementCommand.trace_basic_infor   TargetPython | Nonec                 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.
        r2   T)allow_yankedr   release_controlprefer_binaryr   )link_collectorselection_prefsr   uploaded_prior_to)r   creater   r   r   r   r   r   )rB   r+   rN   r   r   r   r   r3   r3   r4   _build_package_finder  s   z(RequirementCommand._build_package_finder)rC   r   r[   r   r,   r<   )r+   r   r,   rc   )Nr   )rh   r(   r+   r   ri   r   rN   r   rM   r   rj   r-   rk   rl   rm   rE   r,   r   )NFTFFr   N)r   r   rM   r   r+   r   ro   r   rj   r-   r   r-   r   r-   r   r-   r   rc   r   r   r,   r$   )
rC   rD   r+   r   rM   r   rN   r   r,   rO   )rM   r   r,   r<   r=   )
r+   r   rN   r   r   r   r   r-   r,   r   )__name__
__module____qualname__r]   staticmethodrg   classmethodr   r   r   r   r   __classcell__r3   r3   ra   r4   r7      s0    	P
8 )r+   r   r,   r-   )r9   r:   r,   r:   )
rL   rD   rM   r   r+   r   rN   r   r,   rO   )R__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   ,pip._internal.operations.build.build_trackerr    pip._internal.operations.preparer   pip._internal.req.constructorsr   r   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%   Zpip._internal.utils.pylockr&   r'   pip._internal.utils.temp_dirr(   r)   r*   	getLoggerr   r{   r5   	BUILD_ENVEPHEM_WHEEL_CACHE	REQ_BUILDr>   r6   rK   rZ   r7   r3   r3   r3   r4   <module>   sP    



