
    <Bha                    b   S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJ	r	J
r
  SSKJr  SSKJr  SS	KJrJrJrJrJrJrJr  SS
KJrJr  SSKJr  SSKJr  SSKJr  SSK J!r!J"r"  SSK#J$r$  SSK%J&r&  SSK%J'r(  SSK)J*r*  SSK+J,r,J-r-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5  SSK6J7r7J8r8  SSK9J:r:  SSK;J<r<  SSK=J>r>  SSK?J@r@  SSKAJBrBJCrC  \(       a"  SSKDJErE  SSKJFrFJGrG  SSKHJIrI  SSK JJrJ  \G" S5      rK\" \L5      rM " S S \N5      rO " S! S"\OS#9rP      S-S$ jrQ\*" S%S&S'S(9S.S) j5       rR\*" S%S&S*S(9S/S+ j5       rSS0S, jrTg)1z@Tools for managing the packages installed within an environment.    )annotationsN)	getLogger)basenamelexists)Path)TYPE_CHECKING   )CONDA_ENV_VARS_UNSET_VARCONDA_PACKAGE_EXTENSIONSPREFIX_FROZEN_FILEPREFIX_MAGIC_FILEPREFIX_NAME_DISALLOWED_CHARSPREFIX_STATE_FILEROOT_ENV_NAME)contextlocate_prefix_by_name)on_win)NULL)time_recorder)expandpaths_equal)	json_load)mask_anaconda_token)remove_auth)
deprecated)
BasicClobberErrorCondaDependencyErrorCondaValueErrorCorruptedEnvironmentError"DirectoryNotACondaEnvironmentErrorEnvironmentIsFrozenErrorEnvironmentLocationNotFoundEnvironmentNameNotFoundEnvironmentNotWritableErrormaybe_raise)first_writable_envs_dirwrite_as_json_to_file)rm_rf)file_path_is_writable)	MatchSpec)PrefixGraph)PackageRecordPrefixRecord)Iterable)AnyTypeVar)_Null)PathTypeTc                  l   ^  \ rS rSrSr\R                  " SSSSS9 S
     SU 4S jjj5       rS	rU =r	$ )PrefixDataTypeC   z-Basic caching of PrefixData instance objects.25.926.3pip_interop_enabledinteroperabilityrenamec                  > [        U[        5      (       a  U$ [        U5      nUb  UO[        R                  nX4nU[        R
                  ;   a  [        R
                  U   $ [        TU ]  X5      nU[        R
                  U'   U$ N)
isinstance
PrefixDatar   r   prefix_data_interoperability_cache_super__call__)clsprefix_pathr:   	cache_keyprefix_data_instance	__class__s        6lib/python3.13/site-packages/conda/core/prefix_data.pyrD   PrefixDataType.__call__F   s     k:..;'  + 55 	
  1	
***%%i00#(7#3K#R ,@Jy)''     r>   )rF   str | os.PathLike | Pathr:   bool | Nonereturnr@   )
__name__
__module____qualname____firstlineno____doc__r   argumentrD   __static_attributes____classcell__)rI   s   @rJ   r5   r5   C   sO    7-6H )-(-( &( 
	((rL   r5   c                     \ rS rSr% Sr0 rS\S'   \R                  " SSSSS	9 S6   S7S jj5       r	\
S8S j5       r\
S9S:S jj5       r\S;S j5       rS<S jrS=S jrS=S jrS=S jrS=S jr\S>S j5       rS?S jrS?S jrS?S jrS?S jrS9S@S jjrS9SAS jjr\" \ S9S?S j5       rSBS jr\\" SSSS9S  5       5       rSCS! jrSDSES" jjr SFS# jr!\"4SGS$ jjr#SHS% jr$SHS& jr%SIS' jr&    SJS( jr'\SKS) j5       r(SLS* jr)\\" SSS+S9SMS, j5       5       r*\" SSS-S9SNS. j5       r+SOS/ jr,SPS0 jr-SQS1 jr.    SRS2 jr/    SRS3 jr0S?S4 jr1S5r2g
)Sr@   _   a(  
The PrefixData class aims to be the representation of the state
of a conda environment on disk. The directory where the environment
lives is called prefix.

This class supports different types of tasks:

- Reading and querying `conda-meta/*.json` files as `PrefixRecord` objects
- Reading and writing environment-specific configuration (env vars, state file,
  nonadmin markers, etc)
- Existence checks and validations of name, path, and magic files / markers
- Exposing non-conda packages installed in prefix as `PrefixRecord`, via the plugin system
z*dict[tuple[Path, bool | None], PrefixData]rB   r7   r8   r9   r:   r;   Nc                    [        U5      U l        U R                  [        -  U l        U R                  [        -  U l        S U l        [        U l        Ub  UU l        g [        R                  U l        g r>   )r   rF   r   _magic_filer   _frozen_file_PrefixData__prefix_recordsr   _PrefixData__is_writabler   rA   r:   )selfrF   r:   s      rJ   __init__PrefixData.__init__p   sq     "&k!2!%!1!14E!E"&"2"25G"G@D26  +  	 55 	rL   c                    SU;   d  SU;   a  [        S5      e U " [        U5      5      $ ! [         a4    U " U5      R                  5         U " [	        [        5       U5      40 UD6s $ f = f)a  
Creates a PrefixData instance from an environment name.

The name will be validated with `PrefixData.validate_name()` if it does not exist.

:param name: The name of the environment. Must not contain path separators (/, \).
:raises CondaValueError: If `name` contains a path separator.
/\z0Environment names cannot contain path separators)r   r   r#   validate_namer   r&   )rE   namekwargss      rJ   	from_namePrefixData.from_name   sp     $;$$,!"TUU	H,T233& 	HI##%t35t<GGG	Hs   * ;A('A(c                    U " [         R                  5      nU(       a   UR                  5         UR                  5         U$ )aU  
Creates a PrefixData instance from the path specified by `context.target_prefix`.

The path and name will be validated with `PrefixData.validate_path()` and
`PrefixData.validate_name()`, respectively, if `validate` is `True`.

:param validate: Whether the path and name should be validated. Useful for environments
    about to be created.
)r   target_prefixvalidate_pathrf   )rE   validateinsts      rJ   from_contextPrefixData.from_context   s4     7(()  rL   c                    U [        [        R                  5      :X  a  [        $ [        R                   H?  n[        XR                  R                  5      (       d  M)  U R                  R                  s  $    g)z
Returns the name of the environment, if available.

If the environment doesn't live in one the configured `envs_dirs`, an empty
string is returned. The construct `prefix_data.name or prefix_data.prefix_path` can
be helpful in those cases.
 )	r@   r   root_prefixr   	envs_dirsr   rF   parentrg   )r`   envs_dirs     rJ   rg   PrefixData.name   s[     :g1122  ))H8%5%5%<%<=='',,, * rL   c                   [        U[        5      (       d  gU R                  R                  5       (       aE  UR                  R                  5       (       a%  U R                  R	                  UR                  5      $ gUR                  R                  5       (       a  gU R                  R                  5       UR                  R                  5       :H  $ )NF)r?   r@   rF   existssamefileresolve)r`   others     rJ   __eq__PrefixData.__eq__   s    %,,""$$  ''))''001B1BCC%%'' ##++-1B1B1J1J1LLLrL   c                X     U R                   R                  5       $ ! [         a     gf = f)z>
Check whether the PrefixData path exists and is a directory.
F)rF   is_dirOSErrorr`   s    rJ   rz   PrefixData.exists   s.    	##**,, 		    
))c                X     U R                   R                  5       $ ! [         a     gf = f)z
Check whether the PrefixData path is a valida conda environment.

This is assessed by checking if `conda-meta/history` marker file exists.
F)r\   is_filer   r   s    rJ   is_environmentPrefixData.is_environment   s.    	##++-- 		r   c                X     U R                   R                  5       $ ! [         a     gf = f)z
Check whether the environment is marked as frozen, as per CEP 22.

This is assessed by checking if `conda-meta/frozen` marker file exists.
F)r]   r   r   r   s    rJ   	is_frozenPrefixData.is_frozen   s.    	$$,,.. 		r   c                \    [        [        U R                  5      [        R                  5      $ )zE
Check whether the configured path refers to the `base` environment.
)r   strrF   r   rt   r   s    rJ   is_basePrefixData.is_base   s"     3t//0'2E2EFFrL   c                    U R                   [        :X  a3  U R                  5       (       d  SnO[        U R                  5      nXl         U R                   $ )a"  
Check whether the configured path is writable. This is assessed by checking
whether `conda-meta/history` is writable. It if is, it is assumed that the rest
of the directory tree is writable too.

Note: The value is cached in the instance. Use `.assert_writable()` for a non-
cached check.
N)r_   r   r   r)   r\   )r`   is_writables     rJ   r   PrefixData.is_writable   sH     %&&(("3D4D4DE!,!!!rL   c                X    U R                  5       (       d  [        U R                  5      eg)zn
Check whether the environment path exists.

:raises EnvironmentLocationNotFound: If the check returns False.
N)rz   r"   rF   r   s    rJ   assert_existsPrefixData.assert_exists   s%     {{}}-d.>.>?? rL   c                x    U R                  5         U R                  5       (       d  [        U R                  5      eg)z
Check whether the environment path exists and is a valid conda environment.

:raises DirectoryNotACondaEnvironmentError: If the check returns False.
N)r   r   r    rF   r   s    rJ   assert_environmentPrefixData.assert_environment  s5     	""$$4T5E5EFF %rL   c                    U R                  5         [        U R                  5      (       d  [        U R                  5      eg)z
Check whether the environment path is a valid conda environment and is writable.

:raises EnvironmentNotWritableError: If the check returns False.
N)r   r)   r\   r$   rF   r   s    rJ   assert_writablePrefixData.assert_writable  s7     	!$T%5%566-d.>.>?? 7rL   c                   U R                  5         U R                  5       (       d  gSnU R                  R                  5       nU(       a&  [        R
                  " U5      R                  SS5      n[        U R                  U5      e)z
Check whether the environment path is a valid conda environment and is not marked
as frozen (as per CEP 22).

:raises EnvironmentIsFrozenError: If the environment is marked as frozen.
Nrs   message)	r   r   r]   	read_textjsonloadsgetr!   rF   )r`   r   contentss      rJ   assert_not_frozenPrefixData.assert_not_frozen  sj     	!~~$$..0jj*..y"=G&t'7'7AArL   c                   [        U R                  5      nU(       a  [        U5      n[        U5      U l        [        R
                  U;   a   [        S[        R
                   SU S35      eSU;   a  [        R                  SU5        U R                  U R                  R                  5      nUR                  5       (       a  [        S5      eg)a  
Validate the path of the environment.

It runs the following checks:

- Make sure the path does not contain `:` or `;` (OS-dependent).
- Disallow immediately nested environments (e.g. `$CONDA_ROOT` and `$CONDA_ROOT/my-env`).
- Warn if there are spaces in the path.

:param expand_path: Whether to process `~` and environment variables in the string.
    The expanded value will replace `.prefix_path`.
:raises CondaValueError: If the environment contains `:`, `;`, or is nested.
z"Environment paths cannot contain 'z'. Prefix: '' z9Environment paths should not contain spaces. Prefix: '%s'zOEnvironment paths cannot be immediately nested under another conda environment.N)r   rF   r   r   ospathsepr   logwarningrI   rv   r   )r`   expand_path
prefix_strrv   s       rJ   rm   PrefixData.validate_path+  s     ))*

+J#J/D::#!4RZZLZLXYZ  *KKK  0 0 7 78  ""!a  #rL   c                    U(       d/  U R                   [        S4;   a  [        SU R                    S35      e[        R                  " U R
                  R                   5      (       a  [        S[         35      eg)z
Validate the name of the environment.

:param allow_base: Whether to allow `base` as a valid name.
:raises CondaValueError: If the name is protected, or if it contains disallowed characters
    (`/`, ` `, `:`, `#`).
rootr   z ' is a reserved environment namez:Environment names cannot contain any of these characters: N)rg   r   r   r   intersectionrF   )r`   
allow_bases     rJ   rf   PrefixData.validate_nameN  sn     diiM6+BB!Adii[0P"QRR'44T5E5E5J5JKK!L/02  LrL   )module_namec                p   0 U l         U R                  S-  n[        U5      (       a<  S S [        R                  " U5      5       5       nU H  nU R                  U5        M     U R                  (       aC  [        R                  R                  5        H   nU" U R                  U R                   5        M"     g g )N
conda-metac              3  <   #    U  H  nUS S S:X  d  M  Uv   M     g7f)N.jsonrM   ).0ps     rJ   	<genexpr>"PrefixData.load.<locals>.<genexpr>g  s'      %NARS6W$ Ns   	c              3  8   #    U  H  oR                   v   M     g 7fr>   )path)r   entrys     rJ   r   r   i  s     N2M**2Ms   )
r^   rF   r   r   scandir_load_single_recordr:   r   plugin_managerget_prefix_data_loaders)r`   _conda_meta_dirconda_meta_json_paths	meta_fileloaders        rJ   loadPrefixData.loadb  s     "**\9?##%N"**_2MN%!
 3	((3 3  !00HHJt'')>)>? K !rL   c                &    U R                  5         U $ r>   )r   r   s    rJ   reloadPrefixData.reloadr  s    		rL   z Use PrefixData.interoperability.addendumc                    U R                   $ r>   )r:   r   s    rJ   _pip_interop_enabledPrefixData._pip_interop_enabledv  s     $$$rL   c                    UR                   nSn[        S-    H,  nUR                  U5      (       d  M  US [        U5      *  nSnM.     U(       d  [	        SU 35      eUS-   $ )NF)z
.dist-infoTz:Attempted to make prefix record for unknown package type: r   )fnr   endswithlen
ValueError)r`   prefix_recordr   	known_extexts        rJ   _get_json_fnPrefixData._get_json_fn{  sn    	+o=C{{33s8)_ 	 > LRDQ  G|rL   c                   UR                   U R                  ;  d   SUR                    S35       eU R                  S-  U R                  U5      -  n[	        U5      (       a(  [        [        S U[        S9[        5        [        U5        U(       a2  UR                  5       n[        [        UR                  5      5      US'   OUn[        X45        XR                  UR                   '   g )Nz2Prefix record insertion error: a record with name zp already exists in the prefix. This is a bug in conda. Please report it at https://github.com/conda/conda/issuesr   )source_pathtarget_pathr   url)rg   _prefix_recordsrF   r   r   r%   r   r   r(   dumpurl_remove_authr   r   r'   )r`   r   r   prefix_record_json_pathprefix_record_jsons        rJ   insertPrefixData.insert  s    !!)=)== 	
@ASAS@T U4 4	
= |+d.?.?.NN 	  *++! $ 7#
  )*!.!3!3!5(7#M$5$56)u% "/5J3@]//0rL   c                    XR                   ;   d   eU R                   U   nU R                  S-  U R                  U5      -  nU R                  (       a  [	        U5        U R                   U	 g )Nr   )r   rF   r   r   r(   )r`   package_namer   r   s       rJ   removePrefixData.remove  sk    33333,,\: |+d.?.?.NN 	  )*  .rL   c                Z     U R                   U   $ ! [         a    U[        La  Us $ e f = fr>   )r   KeyErrorr   )r`   r   defaults      rJ   r   PrefixData.get  s7    	''55 	d"		s    **c                H    [        U R                  R                  5       5      $ r>   )iterr   valuesr   s    rJ   iter_recordsPrefixData.iter_records  s    D((//122rL   c                ^    [        U R                  5       5      n[        UR                  5      $ r>   )r+   r   r   graph)r`   prefix_graphs     rJ   iter_records_sortedPrefixData.iter_records_sorted  s&    "4#4#4#67L&&''rL   c                    [        5       nU R                  5        HP  nUR                  R                  nU(       d  M"  X1;  d  M)  [        R                  SX25        UR                  U5        MR     U$ )Nzadding subdir url %s for %s)setr   channel
subdir_urlr   debugadd)r`   subdir_urlsr   r   s       rJ   all_subdir_urlsPrefixData.all_subdir_urls  sZ    e!..0M&..99Jzj;		7S
+	 1
 rL   c                  ^ Um[        T[        5      (       a  [        T5      m[        T[        5      (       a  U4S jU R                  5       5       $ [        T[        5      (       d   eU4S jU R                  5       5       $ )Nc              3  X   >#    U  H  nTR                  U5      (       d  M  Uv   M!     g 7fr>   )matchr   
prefix_recparams     rJ   r   #PrefixData.query.<locals>.<genexpr>  s&      "5J;;z* 
"5s   *	*c              3  6   >#    U  H  oT:X  d  M
  Uv   M     g 7fr>   rM   r  s     rJ   r   r
    s      -@zRWDW

-@s   		)r?   r   r*   r   r,   )r`   package_ref_or_match_specr	  s     @rJ   queryPrefixData.query  sy     *eS!!e$EeY''"&"3"3"5  e]3333-1->->-@ rL   c                n    U R                   =(       d#    U R                  5       =(       d    U R                   $ r>   )r^   r   r   s    rJ   r   PrefixData._prefix_records  s$    $$L		Lt7L7LLrL   c                d   [         R                  SU5        [        U5       n [        UR	                  5       5      n[        S0 UD6n [        U5      S S R                  SS5      u  pVnXVU4UR                  UR                  UR                  4:w  a
  [!        5       e X@R$                  UR                  '   S S S 5        g ! [
        [        R                  4 a    [        U R                  U5      ef = f! [          a!    [         R#                  SU5         S S S 5        g f = f! , (       d  f       g = f)Nzloading prefix record %sr   -r	   z'Ignoring malformed prefix record at: %srM   )r   r   openr   readUnicodeDecodeErrorr   JSONDecodeErrorr   rF   r-   r   rsplitrg   versionbuildr   r   r^   )r`   r   fh	json_datar   nvbs           rJ   r   PrefixData._load_single_record  s2   		,.EF)*b%bggi0	 )595M"#:;CR@GGQOa!9!&&!))!''! 
 %,& 9F!!-"4"45? +* '(<(<=  0$$&= *  =?V ; +*01 +*sF   D!B?D!	AC3D!?1C00D!3 DD!DD!!
D/zUse PrefixData.get('python').c                V    [        S U R                  R                  5       5       S5      $ )z0Return the prefix record for the package python.c              3  J   #    U  H  nUR                   S :X  d  M  Uv   M     g7fpythonNrg   )r   r   s     rJ   r   0PrefixData._python_pkg_record.<locals>.<genexpr>  s'      %CM %%1 %C   #	#N)nextr^   r   r   s    rJ   _python_pkg_recordPrefixData._python_pkg_record  s2     %)%:%:%A%A%C
 
 	
rL   zHUse 'conda.plugins.prefix_data_loaders.pypi.load_site_packages' instead.c                H    SSK Jn  U" U R                  U R                  5      $ )Nr	   )load_site_packages) plugins.prefix_data_loaders.pypir+  rF   r^   )r`   r+  s     rJ   _load_site_packagesPrefixData._load_site_packages  s!     	J!$"2"2D4I4IJJrL   c                    U R                   [        -  n[        U5      (       a:  [        U5       n[        R
                  " UR                  5       5      nS S S 5        U$ 0 nU$ ! , (       d  f       W$ = fr>   )rF   r   r   r  r   r   r  )r`   env_vars_filefprefix_states       rJ   _get_environment_state_file&PrefixData._get_environment_state_file%  sg    ((+<<=!!m$#zz!&&(3 %  L	 %$ s   %A""
A1c                v    U R                   [        -  nUR                  [        R                  " USS S95        g )NFc                    U R                   $ r>   )__dict__)xs    rJ   <lambda>:PrefixData._write_environment_state_file.<locals>.<lambda>1  s    AJJrL   )ensure_asciir   )rF   r   
write_textr   dumps)r`   stater0  s      rJ   _write_environment_state_file(PrefixData._write_environment_state_file.  s2    ((+<<  JJu5:NO	
rL   c                    U R                  5       n[        UR                  S0 5      5      nUR                  5       VVs0 s H  u  p4U[        :w  d  M  X4_M     nnnU$ s  snnf Nenv_vars)r3  dictr   itemsr
   )r`   r2  env_vars_allkr  rC  s         rJ   get_environment_env_vars#PrefixData.get_environment_env_vars4  sg    779L,,Z<=)//1
1TQQ:R5RDAD1 	 
 
s   AAc                    U R                  5       nUR                  S5      nU(       a  UR                  U5        OXS'   U R                  U5        UR                  S5      $ rB  )r3  r   updater?  )r`   rC  env_state_filecurrent_env_varss       rJ   set_environment_env_vars#PrefixData.set_environment_env_vars<  s[     99;)--j9##H-)1:&**>:!!*--rL   c                    U R                  5       nUR                  S5      nU(       a7  U H   nXCR                  5       ;   d  M  [        X4'   M"     U R	                  U5        UR                  S5      $ rB  )r3  r   keysr
   r?  )r`   rC  rL  rM  env_vars        rJ   unset_environment_env_vars%PrefixData.unset_environment_env_varsH  si     99;)--j9#33550H$- $ ..~>!!*--rL   c                    [         (       af  [        [        R                  S5      R	                  5       (       a8  U R
                  R                  SSS9  U R
                  S-  R                  5         ggg)zFCreates $PREFIX/.nonadmin if sys.prefix/.nonadmin exists (on Windows).z	.nonadminT)parentsexist_okN)r   r   r   rt   r   rF   mkdirtouchr   s    rJ   set_nonadminPrefixData.set_nonadminT  sZ    6d7..<DDFF""4$"?+224 G6rL   )__is_writable__prefix_recordsr]   r\   r:   rF   r>   )rF   zstr | os.PathLike[str] | Pathr:   rO   )rg   r   rP   r@   )F)rn   boolrP   r@   )rP   r   )r}   r/   rP   r^  )rP   r^  )rP   zbool | None | _Null)rP   None)r   r^  rP   r_  )r   r^  rP   r_  )rP   r@   )r   r-   rP   r   )T)r   r-   r   r^  rP   r_  )r   r   rP   r_  )r   r   r   r3   rP   zPackageRecord | T)rP   Iterable[PrefixRecord])rP   zset[str])r  zPackageRecord | MatchSpec | strrP   r`  )rP   zdict[str, PrefixRecord] | None)r   r2   rP   r_  )rP   PrefixRecord | None)rP   zdict[str, PrefixRecord])rP   dict[str, dict[str, str]])r>  rb  rP   r_  )rP   z#dict[str, str] | dict[bytes, bytes])rC  zdict[str, str]rP   zdict[str, str] | None)3rQ   rR   rS   rT   rU   rB   __annotations__r   rV   ra   classmethodri   rp   propertyrg   r~   rz   r   r   r   r   r   r   r   r   rm   rf   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r   r(  r-  r3  r?  rH  rN  rS  rZ  rW   rM   rL   rJ   r@   r@   _   s    ;=G7<-6H )-
2
 &

$ H H"     "M		G " ""@G@B !F( x(@ )@ )KL% M %A>/ 37 3()H	& M M!FL )HI	
 J 	
 [
K
K

.&
.	
.
.&
.	
.5rL   r@   )	metaclassc           	       ^ Sn0 n[         R                  " SR                  [         R                  " U 5      SR	                  S U5       5      5      5      R
                  mU H|  n[        U4S jUR                  5       5      n[        U5      S:  a<  [        U[        S9S   n[        R                  S	UR                  5       U5        XCU'   Ml  U(       d  Mu  XCUS   '   M~     U$ )
zAReturn the anchor files for the conda records of python packages.)z.egg-info/PKG-INFOz.dist-info/RECORDz	.egg-infoz^{}/[^/]+(?:{})$|c              3  N   #    U  H  n[         R                  " U5      v   M     g 7fr>   )reescape)r   r   s     rJ   r   5get_conda_anchor_files_and_records.<locals>.<genexpr>g  s     B.Abiimm.As   #%c              3  F   >#    U  H  nT" U5      (       d  M  Uv   M     g 7fr>   rM   )r   fpathmatchers     rJ   r   rl  l  s     V0Cuwu~UU0Cs   !	!   keyr   z7Package %s has multiple python anchor files.
  Using %s)rj  compileformatrk  joinr  tuplefilesr   sortedr   info	record_id)site_packages_short_pathpython_recordsanchor_file_endingsconda_python_packagesr   anchor_pathsanchor_pathro  s          @rJ   "get_conda_anchor_files_and_recordsr  ]  s     Sjj""II./IIB.ABB	

 e  (V0C0CVV|q  37:KHHJ'')
 2?+.\5B,q/2 ( ! rL   r7   r8   z-Use `PrefixData.get('python', None)` instead.r   c                    S [        U 5      R                  5       5       n[        US5      nUb  [        US5      nUb  [        SU  35      eU$ )z]
For the given conda prefix, return the PrefixRecord of the Python installed
in that prefix.
c              3  J   #    U  H  nUR                   S :X  d  M  Uv   M     g7fr"  r$  )r   records     rJ   r   +python_record_for_prefix.<locals>.<genexpr>  s%      7F;;(" 	7r&  Nz(multiple python records found in prefix )r@   r   r'  r   )prefixpython_record_iteratorr  next_records       rJ   python_record_for_prefixr  {  sf     (557
 ($/F148"&:6(C  MrL   z/Use `PrefixData.get('python').version` instead.c                    [        U 5      nUb@  UR                  S   R                  5       (       a  UR                  SS $ UR                  SS $ g)z[
For the given conda prefix, return the version of the Python installation
in that prefix.
N      )r  r  isdigit)r  r  s     rJ   get_python_version_for_prefixr    sS     &f-F>>!$$&&>>"1%%>>"1%%	 rL   c                    [        U 5      n [        [        R                  SS S9 H)  u  p U R	                  U5        [        R                  X4	   g   g! [
         a     M;  f = f)z=Here, path may be a complete prefix or a dist inside a prefixTc                    U S   $ )Nr   rM   rq  s    rJ   r9  0delete_prefix_from_linked_data.<locals>.<lambda>  s    #a&rL   )reverserr  F)r   rx  r@   rB   relative_tor   )r   r  r:   s      rJ   delete_prefix_from_linked_datar    sk    :D$*D.@% 	V$""F#=>%   		s   #A
A"!A")r{  r2   r|  r`  rP   zdict[PathType, PrefixRecord])r  os.PathLikerP   ra  )r  r  rP   z
str | None)r   rN   rP   r^  )UrU   
__future__r   r   r   rj  loggingr   os.pathr   r   pathlibr   typingr   base.constantsr
   r   r   r   r   r   r   base.contextr   r   common.compatr   common.constantsr   	common.ior   common.pathr   r   common.serializer   
common.urlr   r   r   deprecationsr   
exceptionsr   r   r   r   r    r!   r"   r#   r$   r%   gateways.disk.creater&   r'   gateways.disk.deleter(   gateways.disk.testr)   models.match_specr*   models.prefix_graphr+   models.recordsr,   r-   collections.abcr.   r/   r0   auxlibr1   r2   r3   rQ   r   typer5   r@   r  r  r  r  rM   rL   rJ   <module>r     s   G "  	 	  %      : " # % ) , 7 %   R ( 6 ) - 8(#&A(T (8y5> y5|!&!8N!!!< FF%TU V( FF%VW& X&rL   