
    \Ziy                       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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JrJrJrJrJrJ r   SSK!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,J-r-J.r.  SSK/J0r0  SSK1J2r2  SSK1J3r4  SSK5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>J?r?  SSK@JArAJBrB  SSKCJDrD  SSKEJFrF  SSKGJHrH  SSKIJJrJ  SSKKJLrL  SSKMJNrNJOrO  \(       a$  SSKPJQrQ  SSKJRrRJSrSJTrT  SS KUJVrV  SS!K+JWrW  \T" S"5      rX\" \Y5      rZ " S# S$\[5      r\ " S% S&\5      r] " S' S(\\S)9r^      S,S* jr_S-S+ jr`g).z@Tools for managing the packages installed within an environment.    )annotationsN)UserDict)datetimetimezone)	getLogger)basenamelexists)Path)S_ISDIR)TYPE_CHECKING)
frozendict   )
CONDA_ENV_VARS_UNSET_VARPREFIX_CREATION_TIMESTAMP_FILEPREFIX_FROZEN_FILEPREFIX_MAGIC_FILEPREFIX_NAME_DISALLOWED_CHARSPREFIX_PINNED_FILEPREFIX_STATE_FILERESERVED_ENV_NAMESRESERVED_ENV_VARSROOT_ENV_NAME)contextlocate_prefix_by_name)on_macon_win)NULL)time_recorder)expandpaths_equalstrip_pkg_extension)json)mask_anaconda_token)remove_auth)
BasicClobberError
CondaErrorCondaValueErrorCorruptedEnvironmentError"DirectoryNotACondaEnvironmentErrorEnvironmentIsFrozenErrorEnvironmentLocationNotFoundEnvironmentNameNotFoundEnvironmentNotWritableErrormaybe_raise)first_writable_envs_dirwrite_as_json_to_file)rm_rf)file_path_is_writable)PackageType	MatchSpec)PrefixGraph)PackageRecordPrefixRecord)Iterable)AnySelfTypeVar)_Null)PathTypeTc                  @   ^  \ rS rSrSr S     SU 4S jjjrSrU =r$ )PrefixDataTypeH   z-Basic caching of PrefixData instance objects.c                  > [        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_pathinteroperability	cache_keyprefix_data_instance	__class__s        6lib/python3.13/site-packages/conda/core/prefix_data.pyrJ   PrefixDataType.__call__K   s    
 k:..;'  + 55 	
  1	
***%%i00#(7#3K#R ,@Jy)''     rD   )rL   r>   rM   bool | NonereturnrF   )__name__
__module____qualname____firstlineno____doc__rJ   __static_attributes____classcell__)rP   s   @rQ   rA   rA   H   s1    7
 )-(( &( 
	( (rS   rA   c                  "    \ rS rSrSrSS jrSrg)PrefixRecordDicta   z,Lazily convert dict entries to PrefixRecord.c                    U R                   U   n[        U[        5      (       d  [        S0 UD6=U R                   U'   nU$ )NrT   )datarE   r8   )selfpackage_namerecords      rQ   __getitem__PrefixRecordDict.__getitem__d   s=    <(&,///;/Ef/EEDIIl#frS   rT   N)rd   strrV   r8   )rW   rX   rY   rZ   r[   rf   r\   rT   rS   rQ   r_   r_   a   s
    6rS   r_   c                  `   \ rS rSr% Sr0 rS\S'    S3   S4S jjr\S5S j5       r	\S6S7S jj5       r
\S8S	 j5       rS9S
 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S6S=S jjrS6S>S jjr\S?S j5       r\S?S j5       rS@S jr\" \ S9S<S j5       rSAS jrSBS jrSCSDS jjr SES jr!\"4SFS jjr#SGS  jr$SGS! jr%SHS" jr&SIS# jr'    SJS$ jr(SKS% jr)SKS& jr*\SLS' j5       r+SMS( jr,SNS) jr-SOS* jr.SPS+ jr/SQS, jr0    SRS- jr1SSS. jr2S<S/ jr3S<S0 jr4STS1 jr5S2r6g)UrF   k   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]rH   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 rD   )r
   rL   r   _magic_filer   _frozen_file_PrefixData__prefix_recordsr   _PrefixData__is_writabler   rG   rM   )rc   rL   rM   s      rQ   __init__PrefixData.__init__|   sq     "&k!2!%!1!14E!E"&"2"25G"G@D26  +  	 55 	rS   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/   )rK   namekwargss      rQ   	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                  40 UD6nU(       a   UR                  5         UR                  5         U$ )a  
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.
:param kwargs: Additional keyword arguments to pass to the constructor.
)r   target_prefixvalidate_pathru   )rK   validaterw   insts       rQ   from_contextPrefixData.from_context   s9     7((3F3  rS   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.
 )	rF   r   root_prefixr   	envs_dirsr    rL   parentrv   )rc   envs_dirs     rQ   rv   PrefixData.name   s[     :g1122  ))H8%5%5%<%<=='',,, * rS   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)rE   rF   rL   existssamefileresolve)rc   others     rQ   __eq__PrefixData.__eq__   s    %,,""$$  ''))''001B1BCC%%'' ##++-1B1B1J1J1LLLrS   c                X     U R                   R                  5       $ ! [         a     gf = f)z>
Check whether the PrefixData path exists and is a directory.
F)rL   is_dirOSErrorrc   s    rQ   r   PrefixData.exists   s.    	##**,, 		    
))c                X     U R                   R                  5       $ ! [         a     gf = f)z
Check whether the PrefixData path is a valid conda environment.

This is assessed by checking if `conda-meta/history` marker file exists.
F)rl   is_filer   r   s    rQ   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)rm   r   r   r   s    rQ   	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    rh   rL   r   r   r   s    rQ   is_basePrefixData.is_base   s"     3t//0'2E2EFFrS   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)ro   r   r   r2   rl   )rc   is_writables     rQ   r   PrefixData.is_writable   sH     %&&(("3D4D4DE!,!!!rS   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)r   r+   rL   r   s    rQ   assert_existsPrefixData.assert_exists  s%     {{}}-d.>.>?? rS   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)   rL   r   s    rQ   assert_environmentPrefixData.assert_environment  s5     	""$$4T5E5EFF %rS   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   r2   rl   r-   rL   r   s    rQ   assert_writablePrefixData.assert_writable  s7     	!$T%5%566-d.>.>?? 7rS   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.
Nr   message)	r   r   rm   	read_textr"   loadsgetr*   rL   )rc   r   contentss      rQ   assert_not_frozenPrefixData.assert_not_frozen%  sj     	!~~$$..0jj*..y"=G&t'7'7AArS   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)rh   rL   r   r
   ospathsepr'   logwarningrP   r   r   )rc   expand_path
prefix_strr   s       rQ   r|   PrefixData.validate_path5  s     ))*

+J#J/D::#!4RZZLZLXYZ  *KKK  0 0 7 78  ""!a  #rS   c                    U(       d-  U R                   [        ;   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
    (`/`, ` `, `:`, `#`).
r   z ' is a reserved environment namez:Environment names cannot contain any of these characters: N)rv   r   r'   r   intersectionrL   )rc   
allow_bases     rQ   ru   PrefixData.validate_nameX  sj     dii+==!Adii[0P"QRR'44T5E5E5J5JKK!L/02  LrS   c                     U R                   S-  R                  5       n[        UR                  5      (       d  g [        (       d  [
        (       a  [        USUR                  5      nO UR                  n["        R$                  " U[&        R(                  S9$ ! [         aZ     U R                   [        -  n[        UR                  5       R                  5       5      n Nj! [        [        [         4 a      gf = ff = f! [*         a     gf = f)a  
Returns the time when the environment was created, as evidenced by the `conda-meta`
directory creation time (if available). Falls back to `conda-meta/created_at`.

This may return None in the following cases:

- If the environment doesn't exist.
- If the creation time cannot be determined. This can happen for existing environments
  created with conda versions before 25.11 in Linux systems, where the 'birthtime' metadata
  is only available in kernels 4.11+, and not implemented in Python as of Python 3.14.

conda-metaNst_birthtimetz)rL   statr   st_moder   r   getattrst_ctimer   AttributeErrorr   floatr   stripr   
ValueError	TypeErrorr   fromtimestampr   utcFileNotFoundError)rc   r   creation_time	magicfiles       rQ   createdPrefixData.createdl  s    	J$$|399;D4<<(( ) v 'ndmm L$$($5$5M ))-HLLII & $$$($4$47U$U	(-i.A.A.C.I.I.K(L#Z; $#$$! ! 		s;   7D  *B 
C=$:C  C95C=8C99C= 
DDc                     U R                   R                  5       n[        R                  " UR                  [
        R                  S9$ ! [         a     gf = f)z
Returns the time when the environment was last modified, as evidenced by the
`conda-meta/history` file modification time. If the environment does not exist, returns
None.
r   N)rl   r   r   r   st_mtimer   r   r   )rc   r   s     rQ   last_modifiedPrefixData.last_modified  sM    	J##((*D ))$--HLLII ! 		s   A	 	
AAc                   SnU R                  5        H   nXR                  U R                  5      -  nM"     U R                  S-  nU R                  5       (       aI   UR	                  5        H2  nUR
                  S:X  a  M   XR                  5       R                  -  nM4     U$ U$ ! [         a     MG  f = f! [         a     U$ f = f)z
Compute the total size of a conda environment prefix.

This aggregates the installed size of all packages in the environment,
plus the size of non-manifest files under conda-meta (history, markers,
etc.)

:returns: Total size in bytes.
r   r   .json)	iter_recordspackage_sizerL   r   iterdirsuffixr   st_sizer   )rc   
total_sizere   conda_meta_dir	meta_files        rQ   sizePrefixData.size  s     
 '')F--d.>.>??J * ))L8;;==	!/!7!7!9I ''72 "nn&6&>&>>
	 ": z #  s6   %B7 B&B7 &
B40B7 3B44B7 7
CC)module_namec                v   [        5       U l        U R                  S-  n[        U5      (       a7  S [        R
                  " U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 )Nr   c              3     #    U  HU  nUR                   R                  S 5      (       d  M%  UR                   R                  S5      (       a  MG  UR                  v   MW     g7f)r   z._N)rv   endswith
startswithpath).0entrys     rQ   	<genexpr>"PrefixData.load.<locals>.<genexpr>  sF      %8E::&&w/ 8=

8M8Md8S 

8s   $AAA)r_   rn   rL   r	   r   scandir_load_single_recordrM   r   plugin_managerget_prefix_data_loaders)rc   _conda_meta_dirconda_meta_json_pathsr   loaders        rQ   loadPrefixData.load  s     0 2**\9?##%ZZ8%!
 3	((3 3  !00HHJt'')>)>? K !rS   c                &    U R                  5         U $ rD   )r   r   s    rQ   reloadPrefixData.reload  s    		rS   c                    UR                   n[        U5      u  p4U(       d*  UR                  S5      (       a  US [        S5      *  nUS-   $ U(       d  [	        SU 35      eUS-   $ )Nz
.dist-infoz:Attempted to make prefix record for unknown package type: r   )fnr!   r   lenr   )rc   prefix_recordr   strippedexts        rQ   _get_json_fnPrefixData._get_json_fn  su    +B/r{{<00.S../H
 '!!	 LRDQ  '!!rS   c                   UR                   U R                  ;   a  [        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 )NzPrefix record 'z1' already exists. Try `conda clean --all` to fix.r   )source_pathtarget_pathr   url)rv   _prefix_recordsr&   rL   r  r	   r.   r%   r   r1   dumpurl_remove_authr#   r  r0   )rc   r   r$   prefix_record_json_pathprefix_record_jsons        rQ   insertPrefixData.insert  s    !5!55!-"4"4!5 62 3  |+d.?.?.NN 	  *++! $ 7#
  )*!.!3!3!5(7#M$5$56)u% "/5J3@]//0rS   c                    U R                   R                  U5      nU(       d  [        SU S35      eU R                  S-  U R	                  U5      -  nU R
                  (       a  [        U5        U R                   U	 g )NzPackage z is not in prefix.r   )r  r   r   rL   r  r   r1   )rc   rd   r   r  s       rQ   removePrefixData.remove  sw    ,,00>x~5GHII |+d.?.?.NN 	  )*  .rS   c                Z     U R                   U   $ ! [         a    U[        La  Us $ e f = frD   )r  KeyErrorr   )rc   rd   defaults      rQ   r   PrefixData.get  s7    	''55 	d"		s    **c                H    [        U R                  R                  5       5      $ rD   )iterr  valuesr   s    rQ   r   PrefixData.iter_records  s    D((//122rS   c                ^    [        U R                  5       5      n[        UR                  5      $ rD   )r6   r   r  graph)rc   prefix_graphs     rQ   iter_records_sortedPrefixData.iter_records_sorted   s&    "4#4#4#67L&&''rS   c                ,    [        U R                  5      $ )z[
Map the records to a frozendict of name -> record.

:return: A mapping of name -> record.
)r   r  r   s    rQ   map_recordsPrefixData.map_records$  s     $..//rS   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)rc   subdir_urlsr   r%  s       rQ   all_subdir_urlsPrefixData.all_subdir_urls,  sZ    e!..0M&..99Jzj;		7S
+	 1
 rS   c                  ^ Um[        T[        5      (       a  [        T5      m[        T[        5      (       a  TR                  (       a\  TR                  S:w  aL  U R	                  TR                  S 5      =n(       a)  TR                  U5      (       a
  S U4 5       $ S S 5       $ U4S jU R                  5        5       $ [        T[        5      (       d  [        S5      eU4S jU R                  5        5       $ )N*c              3  $   #    U  H  ov   M     g 7frD   rT   )r   rs     rQ   r   #PrefixData.query.<locals>.<genexpr>E  s     1y!Ay   c              3  $   #    U  H  ov   M     g 7frD   rT   )r   _s     rQ   r   r/  F  s     2a2r0  rT   c              3  X   >#    U  H  nTR                  U5      (       d  M  Uv   M!     g 7frD   )matchr   
prefix_recparams     rQ   r   r/  G  s&      "5J;;z* 
"5s   *	*z2`package_ref_or_match_spec` is not a valid record.c              3  6   >#    U  H  oT:X  d  M
  Uv   M     g 7frD   rT   r5  s     rQ   r   r/  N  s     X-@zRWDW

-@s   		)	rE   rh   r5   rv   r   r4  r   r7   r   )rc   package_ref_or_match_specre   r7  s      @rQ   queryPrefixData.query5  s     *eS!!e$EeY''

JJ#%#xx

D99V9;;v&& 2y11&2&"&"3"3"5 
 E=11PQQXT->->-@XXrS   c                    S[         R                  [         R                  1nU R                  5        Vs/ s H  nUR                  U;   d  M  UPM     nn[        US S9$ s  snf )zYGet conda packages sorted alphabetically by name.

:return: Sorted conda package records
Nc                    U R                   $ rD   rv   xs    rQ   <lambda>/PrefixData.get_conda_packages.<locals>.<lambda>[  s    AFFrS   key)r3   NOARCH_GENERICNOARCH_PYTHONr   package_typesorted)rc   conda_typesre   conda_packagess       rQ   get_conda_packagesPrefixData.get_conda_packagesP  sj    
 [779R9RS ++-
-""k1 - 	 

 n*:;;
s   AAc                    [         R                  [         R                  [         R                  1nU R	                  5        Vs/ s H  nUR
                  U;   d  M  UPM     nn[        US S9$ s  snf )zoGet Python packages (installed via pip) sorted alphabetically by name.

:return: Sorted Python package records
c                    U R                   $ rD   r>  r?  s    rQ   rA  0PrefixData.get_python_packages.<locals>.<lambda>l  s    QVVrS   rC  )r3   VIRTUAL_PYTHON_WHEELVIRTUAL_PYTHON_EGG_MANAGEABLEVIRTUAL_PYTHON_EGG_UNMANAGEABLEr   rG  rH  )rc   python_typesre   python_packagess       rQ   get_python_packagesPrefixData.get_python_packages]  st     ,,5577
 ++-
-""l2 - 	 

 o+;<<
s   A-A-c                n    U R                   =(       d#    U R                  5       =(       d    U R                   $ rD   )rn   r   r   s    rQ   r  PrefixData._prefix_recordsn  s$    $$L		Lt7L7LLrS   c                   [        U5       n [        R                  " U5      n[        U5      S S R                  SS5      u  pEnXEU4US   US   US   4:w  a   [        R                  SU5         S S S 5        g X0R                  U'   S S S 5        g ! [        [        R                  4 a    [        U R                  U5      ef = f! , (       d  f       g = f)N-r   rv   versionbuildz'Ignoring malformed prefix record at: %s)openr"   r   UnicodeDecodeErrorJSONDecodeErrorr(   rL   r   rsplitr   r   rn   )rc   r  fhrb   rv   r\  r]  s          rQ   r   PrefixData._load_single_recordr  s    )*byy} $,,C#DSb#I#P#PQTVW#X D5u%$v,Yg)WW=?V % +** +/!!$'+ +* '(<(<=  0$$&=  +*s(   CBAC9C1CC
C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rD   )rL   r   r	   r^  r"   r   read)rc   env_vars_filefprefix_states       rQ   _get_environment_state_file&PrefixData._get_environment_state_file  sg    ((+<<=!!m$#zz!&&(3 %  L	 %$ s   %A""
A1c                r    U R                   [        -  nUR                  [        R                  " USS95        g )NF)ensure_ascii)rL   r   
write_textr"   dumps)rc   staterf  s      rQ   _write_environment_state_file(PrefixData._write_environment_state_file  s,    ((+<<  E!FGrS   c           
         [          Vs/ s H  o"U;   d  M
  UPM     nnU(       aK  SR                  U5      n[        R                  " SU SU R                   SSR                  U5       S35        ggs  snf )z
Ensure that the set of env_var_names does not contain any reserved env vars.
Will raise an OperationNotAllowed if a reserved env var is found.
z, zMWARNING: the given environment variable(s) are reserved and will be ignored: z. Setting these environment variables may produce unexpected results.

Remove the invalid configuration with `conda env config vars unset -p r   z`.N)r   joinwarningswarnrL   )rc   env_vars_namesvarinvalid_varsprint_reserved_varss        rQ   _ensure_no_reserved_env_vars'PrefixData._ensure_no_reserved_env_vars  s~    
 (9R'8><Q'8R"&))L"9MM$$7#8 9 &&'q,)?(@	D  Ss
   	A1A1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)ri  dictr   itemsr   )rc   rh  env_vars_allkvr~  s         rQ   get_environment_env_vars#PrefixData.get_environment_env_vars  sg    779L,,Z<=)//1
1TQQ:R5RDAD1 	 
 
s   AAc                    U R                  UR                  5       5        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      $ r}  )rz  keysri  r   updaterp  )rc   r~  env_state_filecurrent_env_varss       rQ   set_environment_env_vars#PrefixData.set_environment_env_vars  so     	))(--/:99;)--j9##H-)1:&**>:!!*--rS   c                   U R                  5       nUR                  S5      nU(       aT  U H=  nXCR                  5       ;   d  M  U[        ;   a  UR	                  U5        M5  [
        X4'   M?     U R                  U5        UR                  S5      $ r}  )ri  r   r  r   popr   rp  )rc   r~  r  r  env_vars        rQ   unset_environment_env_vars%PrefixData.unset_environment_env_vars  s~    99;)--j9#3355"33(,,W54L(1 $ ..~>!!*--rS   c                B   U R                   =(       dE    U R                  =(       d2    [        R                  " [        R
                  5      R                  5       nU R                  [        -  nUR                  R                  SSS9  UR                  [        U5      5        g)z}
Writes a .creation-time file in conda-meta with the current timestamp, meant
to be used by .created property as a fallback.
Tparentsexist_okN)r   r   r   nowr   r   	timestamprL   r   r   mkdirrm  rh   )rc   r  timestamp_files      rQ   set_creation_timePrefixData.set_creation_time  st     LLXD..X(,,x||2L2V2V2X 	 )),JJ##D4#@!!#i.1rS   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	.nonadminTr  N)r   r
   r   r   r   rL   r  touchr   s    rQ   set_nonadminPrefixData.set_nonadmin  sZ    6d7..<DDFF""4$"?+224 G6rS   c                6   U R                   [        -  nUR                  5       (       aM  UR                  5        nS UR	                  5       R                  5       R                  5        5       nSSS5        OSn[        S W 5       5      $ ! , (       d  f       N = f)z<Find pinned specs from file and return a tuple of MatchSpec.c              3     #    U  H6  nU(       d  M  UR                  5       R                  S 5      (       a  M2  Uv   M8     g7f)#N)r   r   )r   is     rQ   r   .PrefixData.get_pinned_specs.<locals>.<genexpr>  s5      : !"!5!5c!: A:s   A "A 	A NrT   c              3  6   #    U  H  n[        US S9v   M     g7f)T)optionalNr4   )r   specs     rQ   r   r    s     J	Ytd3	s   )rL   r   r   r^  re  r   
splitlinestuple)rc   pin_filerg  	from_files       rQ   get_pinned_specsPrefixData.get_pinned_specs  sw    ##&88??AVVX^^-88:	 ! IJ	JJJ !s   4B


B)__is_writable__prefix_recordsrm   rl   rM   rL   rD   )rL   r>   rM   rU   )rv   rh   rV   rF   )F)r}   boolrV   rF   )rV   rh   )r   r:   rV   r  )rV   r  )rV   zbool | None | _Null)rV   None)r   r  rV   r  )r   r  rV   r  )rV   zdatetime | None)rV   int)rV   r;   )r   r8   rV   rh   )T)r   r8   r$   r  rV   r  )rd   rh   rV   r  )rd   rh   r  r?   rV   zPackageRecord | T)rV   Iterable[PrefixRecord])rV   zfrozendict[str, PrefixRecord])rV   zset[str])r9  zPackageRecord | MatchSpec | strrV   r  )rV   zlist[PrefixRecord])rV   zdict[str, PrefixRecord] | None)r  r>   rV   r  )rV   dict[str, dict[str, str]])ro  r  rV   r  )rv  zIterable[str]rV   r  )rV   z#dict[str, str] | dict[bytes, bytes])r~  zdict[str, str]rV   dict[str, str] | None)r~  z	list[str]rV   r  )rV   ztuple[MatchSpec])7rW   rX   rY   rZ   r[   rH   __annotations__rp   classmethodrx   r   propertyrv   r   r   r   r   r   r   r   r   r   r   r|   ru   r   r   r   r   r   r   r  r  r  r   r   r   r  r   r)  r:  rK  rU  r  r   ri  rp  rz  r  r  r  r  r  r  r\   rT   rS   rQ   rF   rF   k   s    ;=G7<
 )-

 &
$ H H"  "  "M		G " ""@G@B !F( (J (JT J JF x(@ )@
"A>/ 37 3(0Y)HY	Y6<=" M M/6H .&.	..
25KrS   rF   )	metaclassc           	     \   Sn0 n[         R                  " SR                  [         R                  " U 5      SR	                  S U 5       5      5      [
        (       a  [         R                  OSS9R                  nU H  n/ nUR                   H@  n[
        (       a  UR                  SS5      nU" U5      (       d  M/  UR                  U5        MB     [        U5      S	:  a9  [        U[        S
9n[        R                  SUR                  5       U5        XSU'   M  U(       d  M  XSU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rD   )reescape)r   r   s     rQ   r   5get_conda_anchor_files_and_records.<locals>.<genexpr>  s     B.Abiimm.As   #%r   )flagsrt   rs      rC  z7Package %s has multiple python anchor files.
  Using %s)r  compileformatr  rs  r   
IGNORECASEr4  filesreplaceappendr   maxr   info	record_id)	site_packages_short_pathpython_recordsanchor_file_endingsconda_python_packagesmatcherr   anchor_pathsfpathanchor_paths	            rQ   "get_conda_anchor_files_and_recordsr    s    Sjj""II./IIB.ABB	
  &vbmm1 e  ("((EvdC0u~~##E*	 )
 |q l4KHHJ'')
 2?+.\5B,q/2! ($ ! rS   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   rT   rC  s    rQ   rA  0delete_prefix_from_linked_data.<locals>.<lambda>  s    #a&rS   )reverserD  F)r
   rH  rF   rH   relative_tor   )r   prefixrM   s      rQ   delete_prefix_from_linked_datar    sk    :D$*D.@% 	V$""F#=>%   		s   #A
A"!A")r  r>   r  r  rV   zdict[PathType, PrefixRecord])r   zstr | os.PathLike | PathrV   r  )ar[   
__future__r   r   r  rt  collectionsr   r   r   loggingr   os.pathr   r	   pathlibr
   r   r   typingr   r   base.constantsr   r   r   r   r   r   r   r   r   r   base.contextr   r   common.compatr   r   common.constantsr   	common.ior   common.pathr   r    r!   common.serializer"   
common.urlr#   r$   r
  
exceptionsr%   r&   r'   r(   r)   r*   r+   r,   r-   r.   gateways.disk.creater/   r0   gateways.disk.deleter1   gateways.disk.testr2   models.enumsr3   models.match_specr5   models.prefix_graphr6   models.recordsr7   r8   collections.abcr9   r:   r;   r<   auxlibr=   r>   r?   rW   r   typerA   r_   rF   r  r  rT   rS   rQ   <module>r     s    G " 	 	    '  %     !   : * # % B B # , 7   R ( 6 & ) - 8())&A(T (2x @
K> @
KJ'!&'!8N'!!'!TrS   