
    c fG                     8   d Z ddl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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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 ddl8m9Z9 e	rddl:m;Z;  ejx                  e=      Z>ded   fdZ? G d de      Z@ G d d ee@      ZAe7j                  e7j                  e7j                  gZEd&d!ZFd"e
de
fd#ZG G d$ d%eA      ZHy)'a  Contains the Command base classes that depend on PipSession.

The classes in this module are in a separate module so the commands not
needing download / PackageFinder capability don't unnecessarily import the
PackageFinder machinery and all its vendored dependencies, etc.
    N)partial)Values)TYPE_CHECKINGAnyListOptionalTuple)
WheelCache)
cmdoptions)Command)CommandContextMixIn)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_requirements)InstallRequirement)BaseResolver)pip_self_version_check)TempDirectoryTempDirectoryTypeRegistrytempdir_kinds)running_under_virtualenv)
SSLContextreturnr#   c                     t         j                  dk  rt        d      	 dd l} 	 ddlm} |j                  | j                        S # t        $ r t
        j                  d       Y y w xY w# t        $ r}t        d|       d }~ww xY w)N)   
   z9The truststore feature is only available for Python 3.10+r   z1Disabling truststore since ssl support is missing)
truststorez'The truststore feature is unavailable: )sysversion_infor   sslImportErrorloggerwarningpip._vendorr(   r#   PROTOCOL_TLS_CLIENT)r+   r(   es      W/var/www/html/py/new-venv/lib/python3.12/site-packages/pip/_internal/cli/req_command.py_create_truststore_ssl_contextr3   2   s    
'!VWW
J*   !8!899  JK  JDQCHIIJs(   A A* A'&A'*	B3BBc                        e Zd ZdZd fdZededeee	      fd       Z
dedefdZ	 	 	 ddedee   dee   d	edef
d
Z xZS )SessionCommandMixinzE
    A class mixin for command classes needing _build_session().
    r$   c                 0    t         |           d | _        y N)super__init___session)self	__class__s    r2   r9   zSessionCommandMixin.__init__J   s    .2    optionsc                     g }t        |dd      s t        |dd      }|r|j                  |       t        |dd      }|r|j                  |       |xs dS )z7Return a list of index urls from user-provided options.no_indexF	index_urlNextra_index_urls)getattrappendextend)clsr>   
index_urlsurlurlss        r2   _get_index_urlsz#SessionCommandMixin._get_index_urlsN   s_     
w
E2';5C!!#&w 2D9d#!T!r=   c                     | j                   3| j                  | j                  |            | _         | j                   J | j                   S )zGet a default-managed session.)r:   enter_context_build_session)r;   r>   s     r2   get_default_sessionz'SessionCommandMixin.get_default_session\   sE    ==  ..t/B/B7/KLDM ==,,,}}r=   retriestimeoutfallback_to_certific                    |j                   }|r!t        j                  j                  |      sJ d|j                  v r	 t               }nd }t        |r t        j                  j                  |d      nd ||n|j                  |j                  | j                  |      |      }|j                  r|j                  |_        |j                  r|j                  |_        |j                  s|r||n|j                  |_        |j                   r|j                   |j                   d|_        |j$                   |j&                  _        |j*                  |j&                  _        |S # t        $ r	 |s d }Y *w xY w)Nr(   zhttp-v2)cacherO   trusted_hostsrG   ssl_context)httphttps)	cache_dirospathisabsfeatures_enabledr3   	Exceptionr   joinrO   rT   rJ   certverifyclient_certrP   proxyproxiesno_inputauth	promptingkeyring_provider)r;   r>   rO   rP   rQ   rX   rU   sessions           r2   rM   z"SessionCommandMixin._build_sessionf   sE    %%	i 8887333#<> K8A"'',,y)4t&2G!//++G4#
 <<$\\GN "..GL ??g)0)<g'//GO == GO &-%5%5!5(/(@(@%M  #*"#s   
E% %E76E7r$   N)NNF)__name__
__module____qualname____doc__r9   classmethodr   r   r   strrJ   r   rN   intboolrM   __classcell__r<   s   @r2   r5   r5   D   s    3 "f "$s)1D " "6 j  "&!%$)33 #3 #	3
 "3 
3r=   r5   c                        e Zd ZdZdeddfdZy)IndexGroupCommandz
    Abstract base class for commands with the index_group options.

    This also corresponds to the commands that permit the pip version check.
    r>   r$   Nc                     t        |d      sJ |j                  s|j                  ry| j                  |dt	        d|j
                        d      }|5  t        ||       ddd       y# 1 sw Y   yxY w)z
        Do the pip version check if not disabled.

        This overrides the default behavior of not doing the check.
        r@   Nr      T)rO   rP   rQ   )hasattrdisable_pip_version_checkr@   rM   minrP   r   )r;   r>   rh   s      r2   handle_pip_version_checkz*IndexGroupCommand.handle_pip_version_check   s|     w
+++,,0@0@ %%7??+
 !% & 	
  	5"7G4	5 	5 	5s   A))A2)rj   rk   rl   rm   r   r{    r=   r2   ru   ru      s    5 54 5r=   ru   c                      t               ryt        t        d      syt        j                  dk(  st        j                  dk(  ryt        j
                         dk7  ryt        j                  d       y)zOutput a warning for sudo users on Unix.

    In a virtual environment, sudo pip still writes to virtualenv.
    On Windows, users may run pip as Administrator without issues.
    This warning only applies to Unix root users outside of virtualenv.
    Ngetuidwin32cygwinr   zRunning pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv)r"   rx   rY   r)   platformr~   r-   r.   r|   r=   r2   warn_if_run_as_rootr      sX      !2x  ||w#,,(":	yy{a
NN	,r=   funcc           	      |     dt         ddfddt        dt        dt        t           dt
        t           f fd}|S )	zNDecorator for common logic related to managing temporary
    directories.
    registryr$   Nc                 >    t         D ]  }| j                  |d        y )NF)KEEPABLE_TEMPDIR_TYPES
set_delete)r   ts     r2   configure_tempdir_registryz0with_cleanup.<locals>.configure_tempdir_registry   s!    ' 	*A5)	*r=   r;   r>   argsc                     | j                   J |j                  r | j                          	  | ||      S # t        $ r  | j                           w xY wr7   )tempdir_registryno_cleanr   )r;   r>   r   r   r   s      r2   wrapperzwith_cleanup.<locals>.wrapper   sd     $$000&t'<'<=	gt,,$ 	 't'<'<=	s	   	9 A)r    RequirementCommandr   r   r   r   rp   )r   r   r   s   ` @r2   with_cleanupr      sK    
*-F *4 * +19=c	#  Nr=   c                   h    e Zd Zdededdf fdZededefd       Ze		 	 dde
ded	ed
edededee   dedefd       Ze		 	 	 	 	 	 	 	 ddedededee   dedededededee   deeedf      defd       Zdee   deded
edee   f
dZededdfd       Z	 	 d ded
edee   dee   def
dZ xZS )!r   r   kwr$   Nc                 ~    t        |   |i | | j                  j                  t	        j
                                y r7   )r8   r9   cmd_opts
add_optionr   r   )r;   r   r   r<   s      r2   r9   zRequirementCommand.__init__  s0    $%"%  !4!4!67r=   r>   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_enabledr>   s    r2   determine_resolver_variantz-RequirementCommand.determine_resolver_variant  s      C CCr=   temp_build_dirbuild_trackerrh   finderuse_user_sitedownload_dir	verbosityc	                    |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        |	|j                  ||j                  |j                  |||j                  ||j                  ||||
      S )zQ
        Create a RequirementPreparer instance for the given parameters.
        Fr   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_dirsrc_dirr   build_isolationcheck_build_depsr   rh   progress_barr   require_hashesr   
lazy_wheelr   legacy_resolver)rZ   r   r\   r-   r.   r   r   r   r   r   r   )rF   r   r>   r   rh   r   r   r   r   temp_build_dir_pathr   resolver_variantr   s                r2   make_requirement_preparerz,RequirementCommand.make_requirement_preparer  s     -11"...99'B|+$(@(@@J" #OJg666Q #)OO%#33$55' --"11'!+
 	
r=   preparerwheel_cacheignore_installedignore_requires_pythonforce_reinstallupgrade_strategy
use_pep517py_version_info.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.
        )isolatedr   r   r   N)r   r   r   make_install_reqr   ignore_dependenciesr   r   r   r   r   )r   r   isolated_moder   ,pip._internal.resolution.resolvelib.resolver	_internal
resolutionr   resolverResolverr   (pip._internal.resolution.legacy.resolverr   )rF   r   r   r>   r   r   r   r   r   r   r   r   r   r   pips                  r2   make_resolverz RequirementCommand.make_resolverE  s    $ #'**!

 99'B |+?==++66??HH!'!1+$+$?$?!1'= /!1 / I   	8}}''..77@@#-' ' ; ;-#9+-+ A 
 	
r=   c                 *   g }|j                   D ]@  }t        |d|||      D ]+  }t        ||j                  d      }|j	                  |       - B |D ]C  }	t        |	d|j                  |j                  dt        |dd            }|j	                  |       E |j                  D ]B  }	t        |	d|j                  |j                  t        |dd            }|j	                  |       D |j                  D ]r  }t        ||||	      D ]^  }t        ||j                  |j                  d|j                  r|j                  j                  d      nd
      }|j	                  |       ` t t        d |D              rd|_        |s|j                  s|j                  std| j                  i}
|j                   r?t#         dj$                  di t'        |
dj)                  |j                                     t#         dj$                  di |
      |S )zS
        Parse command-line arguments into the corresponding requirements.
        T)
constraintr   r>   rh   F)r   user_suppliedNconfig_settings)
comes_fromr   r   r   r   )r   r   r   r   )r   r>   rh   )r   r   r   r   c              3   4   K   | ]  }|j                     y wr7   )has_hash_options).0reqs     r2   	<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}")r|   )constraintsr   r   r   rD   r   r   rC   	editablesr   requirementsr>   getanyr   r   
find_linksr   formatdictr^   )r;   r   r>   r   rh   r   filename
parsed_req
req_to_addr   optss              r2   get_requirementsz#RequirementCommand.get_requirements  sW    24++ 	0H0 0
 A$22"'

 ##J/0	0  		,C. .."--" '1BD IJ 
+		, $$ 	,C2" .."-- '1BD IJ 
+	,  ,, 	0H0' 0
 A$22&11"&!)) %/$6$6$:$:;L$M
 ##J/0	0  <|<<%)G"))W-A-ADII&D!!"E >>Dft388G4F4F+GH  #5 ..4f=7;= 
 r=   c                 l    | j                   }|j                         }|rt        j                  |       yy)zE
        Trace basic information about the provided objects.
        N)search_scopeget_formatted_locationsr-   info)r   r   	locationss      r2   trace_basic_infoz#RequirementCommand.trace_basic_info  s1     ** 88:	KK	" r=   target_pythonc                     t        j                  ||      }t        d|j                  |j                  |j
                  |      }t        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.
        r   T)allow_yankedformat_controlallow_all_prereleasesprefer_binaryr   )link_collectorselection_prefsr   )r   creater   r   prer   r   )r;   r>   rh   r   r   r   r   s          r2   _build_package_finderz(RequirementCommand._build_package_finder  s]     '--gwG."11")++!//#9
 ##)+'
 	
r=   )Nr   )NFTFFzto-satisfy-onlyNN)NN)rj   rk   rl   r   r9   staticmethodr   ro   r   rn   r   r   r   r   rq   r   rp   r   r   r
   r	   r   r   r   r   r   r   r   r   rr   rs   s   @r2   r   r      s!   8c 8 8 8
 F s    '+4
%4
 4
 $	4

 4
 4
 4
 sm4
 4
 
4
 4
l  -1#!%', % 1%)598
%8
 8
 	8

 j)8
 8
 8
 !%8
 8
 8
 TN8
 "%S/28
 
8
 8
tR3iR R 	R
 R 
 	!Rh # #4 # # 1515

 
  -	

 !)
 

r=   r   ri   )Irm   loggingrY   r)   	functoolsr   optparser   typingr   r   r   r   r	   pip._internal.cacher
   pip._internal.clir   pip._internal.cli.base_commandr   !pip._internal.cli.command_contextr   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   pip._internal.req.req_filer   pip._internal.req.req_installr   pip._internal.resolution.baser   !pip._internal.self_outdated_checkr   pip._internal.utils.temp_dirr   r    r!   pip._internal.utils.virtualenvr"   r+   r#   	getLoggerrj   r-   r3   r5   ru   	BUILD_ENVEPHEM_WHEEL_CACHE	REQ_BUILDr   r   r   r   r|   r=   r2   <module>r     s    	 
   < < * ( 2 A H 7 < E ; 4 E @  : < 6 D 
 D			8	$:(> :$U- Up 5!4  5H ## <s s 8y
* y
r=   