
    5>qjJ                    h   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
 ddlmZ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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/m0Z0m1Z1m2Z2m3Z3 ddl4m5Z5m6Z6 ddl7m8Z8 ddl9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@Z@ ddlAmBZBmCZC ddlDmEZEmFZFmGZG  ej                  eI      ZJd&dZKeGj                  eGj                  eGj                  gZO ed d!"      ZP	 	 	 	 d'd#ZQ	 	 	 	 	 	 	 	 	 	 d(d$ZR G d% d!e      ZSy))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)Callable)partial)Values)AnyTypeVar)BuildEnvironmentInstallerBuildIsolationMode"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 )ag  
    Whether this process should ignore the regular constraints it inherits.

    The parent pip sets ``_PIP_IN_BUILD_IGNORE_CONSTRAINTS`` whenever it starts
    an isolated build in a subprocess, so that regular constraints the build
    inherits (such as via ``PIP_CONSTRAINT`` or config files) do not affect it.
    Only build constraints apply there.
     _PIP_IN_BUILD_IGNORE_CONSTRAINTS1)osenvironget     \/opt/rentech/trading_bot/.venv/lib/python3.12/site-packages/pip/_internal/cli/req_command.py!should_ignore_regular_constraintsr6   B   s     ::>><=DDr4   	_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     r5   configure_tempdir_registryz0with_cleanup.<locals>.configure_tempdir_registry`   s!    ' 	*A5)	*r4   c                    | j                   J |j                  r | j                          	  | ||      S # t        $ r  | j                           w xY wN)tempdir_registryno_cleanr   )selfoptionsargsrA   funcs      r5   wrapperzwith_cleanup.<locals>.wrapperd   sb    $$000&t'<'<=	gt,,$ 	 't'<'<=	s	   	9 A)r?   r+   returnNone)rF   r7   rG   r   rH   	list[str]rK   intr3   )rI   rJ   rA   s   ` @r5   with_cleanuprO   Y   s    * Nr4   c                    g }| D ]@  }t        |d|||      D ]+  }t        ||j                  d      }|j                  |       - B |S )NT)
constraintfinderrG   sessionFisolateduser_supplied)r$   r   isolated_modeappend)constraint_filesrR   rG   rS   requirementsfilename
parsed_req
req_to_adds           r5   parse_constraint_filesr^   u   sn     L$ ,,
 	,J = ..#J
 
+	,, r4   c                      e Zd Zd fdZedd       Zedd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   rH   kw	__class__s      r5   rb   zRequirementCommand.__init__   sK    $%"%  !=!=!?@  !4!4!67r4   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rG   s    r5   determine_resolver_variantz-RequirementCommand.determine_resolver_variant   s      C CCr4   Nr   )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        |dg       }d|j                  v r2t        ||||      }t        ||||	t        |j                        	      }nt        ||
      }|j                  sd}n6d|j                  v r&d}d|j                  v rt        j	                  d       nd}t        d i d|
d|j                  d|d|d|d|j                  d|d|d|j                  d|d|j                   d|d|d|	d|d|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inprocess-build-deps)rR   build_trackerrq   ro   wheel_cache)rq   offzvenv-isolationvenvzUsing --use-feature 'inprocess-build-deps' and 'venv-isolation' together is currently partially supported. If you encounter broken behaviour, use only one feature.virtual	build_dirsrc_dirrn   build_isolationbuild_isolation_installercheck_build_depsrr   rS   progress_barrR   require_hashesuse_user_site
lazy_wheelro   legacy_resolverallow_editablesr3   )pathrm   features_enabledloggerwarninggetattrr^   r   r   	cache_dirr   ry   r   rx   r{   r|   r}   )clstemp_build_dirrG   rr   rS   rR   r   r~   rn   ro   temp_build_dir_pathr   resolver_variantr   rq   build_constraint_reqsenv_installerry   s                     r5   make_requirement_preparerz,RequirementCommand.make_requirement_preparer   s   " -11"...99'B|+$(@(@@J" #OJg666Q
 $G-@"E "W%=%==$:!67G%! ?+"7#&w'8'89M @"3M
 &&27O!9!99$O%)A)AA? (O" 
)
OO
 &
 ,	

 '4
 %55
 (
 
 !--
 
 #11
 (
 "
  
 ,
  ,!
 	
r4   c                   t        t        |j                        }| j                  |      }|dk(  r]ddl}|j
                  j                  j                  j                  j                  ||||||j                  |j                  ||||	|
      S ddl}|j
                  j                  j                  j                  j                  ||||||j                  |j                  ||||	|
      S )zF
        Create a Resolver instance for the given parameters.
        )rU   rj   r   N)preparerrR   rs   make_install_reqr~   ignore_dependenciesonly_dependenciesignore_installedignore_requires_pythonforce_reinstallupgrade_strategypy_version_info)r   r    rW   rm   ,pip._internal.resolution.resolvelib.resolver	_internal
resolutionrj   resolverResolverr   r   (pip._internal.resolution.legacy.resolverri   )r   r   rR   rG   rs   r~   r   r   r   r   r   r   r   pips                 r5   make_resolverz RequirementCommand.make_resolver   s    " #'**
 99'B |+?==++66??HH!'!1+$+$?$?")";";!1'= /!1 / I   	8}}''..77@@#-' ' ; ;%77-#9+-+ A 
 	
r4   c                .   g }t               rt        |dg       }n|j                  }t        ||||      }|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        |
      rmt         j#                  d       t%        |
|	      D ]G  \  }}t'        |||
d
      \  }	}|j                  |	       |s,|j)                  |j*                  |       I {t-        |
|||      D ]S  }t/        ||j                  d|j0                  r|j0                  j3                  d      nd      }	|j                  |	       U  |j4                  rt7        |j4                        dkD  rt9        d      |j4                  d   }	 t;        |      }|j3                  dd      }|rL|j@                  s@tC        |      }tE        ||jF                        stI        d|d|jJ                   d|      |j3                  dg       D ]+  }t        ||j                  d      }	|j                  |	       - |jL                  r|jN                  rt9        d      |jN                  stQ        d |D              rd|_&        |s|j                  s|j                  s|j                  s|j4                  std| j*                  i}|jR                  r?t9         djT                  di tW        |djY                  |jR                                    t9         djT                  di |      |S # t<        $ r}t9        |j>                        d}~ww xY w)zS
        Parse command-line arguments into the corresponding requirements.
        rq   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   rG   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 dependenciesz?--require-hashes and --no-require-hashes are mutually exclusivec              3  4   K   | ]  }|j                     y wrC   )has_hash_options).0reqs     r5   	<genexpr>z6RequirementCommand.get_requirements.<locals>.<genexpr>  s      1
%(C  1
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}")r3   )-r6   r   constraintsr^   extendstripr   rW   rX   re   r#   r    	editablesr   rZ   r(   r   r   r)   r   add_locked_linkr   r$   r   rG   r2   requirements_from_scriptslenr   r"   r!   msgr   r   r'   r   r   
py_versionr}   no_require_hashesany
find_linksformatdictjoin)rF   rH   rG   rR   rS   rZ   rY   r   r   r]   r[   packagepackage_distlocked_linkr\   scriptscript_metadataexcscript_requires_pythontarget_pythonoptss                        r5   get_requirementsz#RequirementCommand.get_requirements5  sk    24,.  'w0CRH&22,-=vwPWX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. J)G\ /N$ &*	/+J !''
3"..w||[IJ 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&?&?Q  ((S 1
,81
 .
 &*G"   ##((00DII&D!!"E >>Dft388G4F4F+GH  #5 ..4f=7;= 
 w # ,"377++,s   O1 1	P:PP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      r5   trace_basic_infoz#RequirementCommand.trace_basic_info  s1     ** 88:	KK	" r4   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.
        rl   T)allow_yankedformat_controlrelease_controlprefer_binaryr   )link_collectorselection_prefsr   uploaded_prior_to)r   creater   r   r   r   r   r   )rF   rG   rS   r   r   r   r   s          r5   _build_package_finderz(RequirementCommand._build_package_finder  sh     '--gwG."11#33!//#9
 ##)+'%77	
 	
r4   )rH   r   rf   r   rK   rL   )rG   r   rK   str)r   r*   rG   r   rr   r   rS   r   rR   r   r   boolr~   r   rn   z
str | Nonero   rN   rK   r   )NFTFFzto-satisfy-onlyN)r   r   rR   r   rG   r   rs   zWheelCache | Noner~   r   r   r   r   r   r   r   r   r   r   ztuple[int, ...] | NonerK   r&   )
rH   rM   rG   r   rR   r   rS   r   rK   list[InstallRequirement])rR   r   rK   rL   r<   )
rG   r   rS   r   r   zTargetPython | Noner   r   rK   r   )__name__
__module____qualname__rb   staticmethodrm   classmethodr   r   r   r   r   __classcell__)rg   s   @r5   r8   r8      s   8    $(Z
%Z
 Z
 $	Z

 Z
 Z
 Z
 Z
 !Z
 Z
 
Z
 Z
x  *.#!%', % 1268
%8
 8
 	8

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

 !%
 

r4   )rK   r   )rI   -Callable[[_CommandT, Values, list[str]], int]rK   r   )
rY   rM   rR   r   rG   r   rS   r   rK   r   )T__doc__
__future__r   loggingr0   collections.abcr   	functoolsr   optparser   typingr   r   pip._internal.build_envr	   r
   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   r6   	BUILD_ENVEPHEM_WHEEL_CACHE	REQ_BUILDr=   r7   rO   r^   r8   r3   r4   r5   <module>r     s0   #  	 $     + ( ; = V 
 8 < E ; 4 E @  F J 9 < 6 ?  
		8	$
E ##  K';<	
728  	
 2j
* j
r4   