
    iLD                    \   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j                  eG      ZHd%dZIeEj                  eEj                  eEj                  gZM edd !      ZN	 	 	 	 d&d"ZO	 	 	 	 	 	 	 	 	 	 d'd#ZP G d$ d e      ZQy)(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)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_kindsc                F    t         j                  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.
     _PIP_IN_BUILD_IGNORE_CONSTRAINTS1)osenvirongetoptionss    P/root/searxng-venv/lib/python3.12/site-packages/pip/_internal/cli/req_command.py!should_ignore_regular_constraintsr5   @   s     ::>><=DD    	_CommandTRequirementCommand)boundc                      ddd fd}|S )zNDecorator for common logic related to managing temporary
    directories.
    c                >    t         D ]  }| j                  |d        y NF)KEEPABLE_TEMPDIR_TYPES
set_delete)registryts     r4   configure_tempdir_registryz0with_cleanup.<locals>.configure_tempdir_registry[   s!    ' 	*A5)	*r6   c                    | j                   J |j                  r | j                          	  | ||      S # t        $ r  | j                           w xY wN)tempdir_registryno_cleanr   )selfr3   argsrA   funcs      r4   wrapperzwith_cleanup.<locals>.wrapper_   sb    $$000&t'<'<=	gt,,$ 	 't'<'<=	s	   	9 A)r?   r*   returnNone)rF   r7   r3   r   rG   	list[str]rJ   int )rH   rI   rA   s   ` @r4   with_cleanuprO   T   s    * Nr6   c                    g }| D ]@  }t        |d|||      D ]+  }t        ||j                  d      }|j                  |       - B |S )NT)
constraintfinderr3   sessionFisolateduser_supplied)r#   r   isolated_modeappend)constraint_filesrR   r3   rS   requirementsfilename
parsed_req
req_to_adds           r4   parse_constraint_filesr^   p   sn     L$ ,,
 	,J = ..#J
 
+	,, r6   c                      e Zd Zd fdZed	d       Ze	 	 d
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Ze	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z	 	 	 	 	 	 	 	 	 	 ddZ	edd       Z
	 	 d	 	 	 	 	 	 	 	 	 ddZ xZS )r8   c                    t        |   |i | | j                  j                  t	        j
                                | j                  j                  t	        j                                y rC   )super__init__cmd_opts
add_optionr   dependency_groupsrE   )rF   rG   kw	__class__s      r4   rb   zRequirementCommand.__init__   sK    $%"%  !=!=!?@  !4!4!67r6   c                "    d| j                   v ryy)zEDetermines which resolver should be used, based on the given options.zlegacy-resolverlegacy
resolvelib)deprecated_features_enabledr2   s    r4   determine_resolver_variantz-RequirementCommand.determine_resolver_variant   s      C CCr6   c	                V   |j                   }	|	J d}
| j                  |      }|dk(  r&d|j                  v }|r=t        j	                  d       n'd}
d}d|j                  v rt        j	                  d       t        |dg       }d|j                  v }d	|j                  v r2t        ||||      }t        ||||t        |j                        
      }nt        |||      }t        |	|j                  ||j                  ||j                  |||j                  ||j                   ||||
      S )zQ
        Create a RequirementPreparer instance for the given parameters.
        Frj   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)rR   build_trackerrn   	verbositywheel_cache)rn    build_constraint_feature_enabled)	build_dirsrc_dirdownload_dirbuild_isolationbuild_isolation_installercheck_build_depsro   rS   progress_barrR   require_hashesuse_user_site
lazy_wheelrp   legacy_resolver)pathrl   features_enabledloggerwarninggetattrr^   r
   r   	cache_dirr   r   rt   rv   rx   ry   rz   )clstemp_build_dirr3   ro   rS   rR   r{   ru   rp   temp_build_dir_pathr}   resolver_variantr|   rn   rr   build_constraint_reqsenv_installers                    r4   make_requirement_preparerz,RequirementCommand.make_requirement_preparer   sd    -11"...99'B|+$(@(@@J" #OJg666Q
 $G-@"E'":":: 	)
 "W%=%==$:!67G%! ?+"7#&w'8'89M @"31QM #)OO%#33&3$55' --"11'!+
 	
r6   c                   t        t        |j                        }| j                  |      }|dk(  rRddl}|j
                  j                  j                  j                  j                  ||||||j                  ||||	|
      S ddl}|j
                  j                  j                  j                  j                  ||||||j                  ||||	|
      S )zF
        Create a Resolver instance for the given parameters.
        )rU   rj   r   N)preparerrR   rq   make_install_reqr{   ignore_dependenciesignore_installedignore_requires_pythonforce_reinstallupgrade_strategypy_version_info)r   r   rW   rl   ,pip._internal.resolution.resolvelib.resolver	_internal
resolutionrj   resolverResolverr   (pip._internal.resolution.legacy.resolverri   )r   r   rR   r3   rq   r{   r   r   r   r   r   r   r   pips                 r4   make_resolverz RequirementCommand.make_resolver   s    " #'**
 99'B |+?==++66??HH!'!1+$+$?$?!1'= /!1 / I   	8}}''..77@@#-' ' ; ;-#9+-+ A 
 	
r6   c                   g }t        |      s)t        |j                  |||      }|j                  |       |D ]I  }|j	                         st        |d|j                  dt        |dd            }|j                  |       K |j                  rCt        |j                        D ]+  }t        ||j                  d      }|j                  |       - |j                  D ]7  }t        |d|j                  t        |dd            }|j                  |       9 |j                  D ]  }	t        |	      rTt         j#                  d       t%        |	|      D ].  \  }
}|j                  t'        |
||	|j(                  d	             0 bt+        |	|||
      D ]S  }t-        ||j                  d|j.                  r|j.                  j1                  d      nd      }|j                  |       U  |j2                  rt5        |j2                        dkD  rt7        d      |j2                  d   }	 t9        |      }|j1                  dd      }|rL|j>                  s@tA        |      }tC        ||jD                        stG        d|d|jH                   d|      |j1                  dg       D ]+  }t        ||j                  d      }|j                  |       - tK        d |D              rd|_&        |s|j                  s|j                  s|j                  s|j2                  std| jN                  i}|jP                  r?t7         djR                  di tU        |djW                  |jP                                    t7         djR                  di |      |S # t:        $ r}t7        |j<                        d}~ww xY w)zS
        Parse command-line arguments into the corresponding requirements.
        NTconfig_settings)
comes_fromrU   rV   r   rT   )rV   rU   r   zUsing pylock.toml as a requirements source is an experimental feature. It may be removed/changed in a future release without prior warning.)rS   )rV   )rR   r3   rS   )rU   rV   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              3  4   K   | ]  }|j                     y wrC   )has_hash_options).0reqs     r4   	<genexpr>z6RequirementCommand.get_requirements.<locals>.<genexpr>  s     <s##<s   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}")rN   ),r5   r^   constraintsextendstripr   rW   r   rX   re   r"   r   	editablesr   rZ   r'   r   r   r(   r   format_controlr#   r   r3   r1   requirements_from_scriptslenr   r!   r    msgr   r   r&   r   r   
py_versionanyrz   r   
find_linksformatdictjoin)rF   rG   r3   rR   rS   rZ   r   r   r]   r[   packagepackage_distr\   scriptscript_metadataexcscript_requires_pythontarget_pythonoptss                      r4   get_requirementsz#RequirementCommand.get_requirements"  s
    24090##VWgK , 
	,C99;. .." '1BD IJ 
+
	, $$.w/H/HI 08$22"&

 ##J/0 $$ 	,C2" .. '1BD I	J 
+	,  ,, "	0H'1- .Lg. )G\ !''7#($#22*. 0' 0
 A$22"& &-- #**../@A!	
 ##J/0+"	0H ,,74459"#VWW66q9F,"1&"9 &5%8%89JB%O"%g.L.L 27 ;,$:!.!>!> 3!&+I(334H=S<VX 
 '**>2> 08$22"&

 ##J/0 <|<<%)G"   ##((00DII&D!!"E >>Dft388G4F4F+GH  #5 ..4f=7;= 
 e # ,"377++,s   .N 	N=#N88N=c                l    | j                   }|j                         }|rt        j                  |       yy)zE
        Trace basic information about the provided objects.
        N)search_scopeget_formatted_locationsr   info)rR   r   	locationss      r4   trace_basic_infoz#RequirementCommand.trace_basic_info  s1     ** 88:	KK	" r6   c                    t        j                  ||      }t        d|j                  |j                  |j
                  |      }t        j                  ||||j                        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   )rF   r3   rS   r   r   r   r   s          r4   _build_package_finderz(RequirementCommand._build_package_finder  sh     '--gwG."11#33!//#9
 ##)+'%77	
 	
r6   )rG   r   rf   r   rJ   rK   )r3   r   rJ   str)Nr   )r   r)   r3   r   ro   r   rS   r   rR   r   r{   boolru   z
str | Nonerp   rM   rJ   r   )NFTFFzto-satisfy-onlyN)r   r   rR   r   r3   r   rq   zWheelCache | Noner{   r   r   r   r   r   r   r   r   r   r   ztuple[int, ...] | NonerJ   r%   )
rG   rL   r3   r   rR   r   rS   r   rJ   list[InstallRequirement])rR   r   rJ   rK   r<   )
r3   r   rS   r   r   zTargetPython | Noner   r   rJ   r   )__name__
__module____qualname__rb   staticmethodrl   classmethodr   r   r   r   r   __classcell__)rg   s   @r4   r8   r8      s   8    $(N
%N
 N
 $	N

 N
 N
 N
 !N
 N
 
N
 N
`  *.#!%', % 1266
%6
 6
 	6

 '6
 6
 6
 !%6
 6
 6
 06
 
6
 6
pNN N 	N
 N 
"N` # # .2',

 
 +	

 !%
 

r6   )r3   r   rJ   r   )rH   -Callable[[_CommandT, Values, list[str]], int]rJ   r   )
rY   rL   rR   r   r3   r   rS   r   rJ   r   )R__doc__
__future__r   loggingr/   	functoolsr   optparser   typingr   r   r   pip._internal.build_envr	   r
   r   pip._internal.cacher   pip._internal.clir   pip._internal.cli.cmdoptionsr   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   pip._internal.req.pep723r    r!   &pip._internal.req.req_dependency_groupr"   pip._internal.req.req_filer#   pip._internal.req.req_installr$   pip._internal.resolution.baser%   pip._internal.utils.packagingr&   pip._internal.utils.pylockr'   r(   pip._internal.utils.temp_dirr)   r*   r+   	getLoggerr   r   r5   	BUILD_ENVEPHEM_WHEEL_CACHE	REQ_BUILDr=   r7   rO   r^   r8   rN   r6   r4   <module>r      s0   #  	   ) ) 
 + ( ; = V 
 8 < E ; 4 E @  F J 9 < 6 ?  
		8	$E ##  K';<	
728  	
 2O
* O
r6   