+
    Cj                    V   R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHtHtHt ^ RIHt ^ R	IHt ^ R
IHtHtHt ^ RIHtHtHt ^ RIHt ^ RIH t  ^ RI!H"t" ^ RI#H$t$ ^ RI%H&t& ^ RI'H(t(H)t) ^ RI*H+t+H,t,H-t-H.t.H/t/ ^ RI0H"t1 ^ RI0H2t2H3t3H4t4H5t5 ^RI6H7t7 ]'       dA   ^ RI8H9t9H:t: ^ RIH;t;H<t< ^ RI=H>t> ^ RI?H@t@ ^ RIAHBtB ^ RICHDtE ^ RI'HFtF ^ RI*HGtG ^RIHHItI ^RIJHKtK ]P                  ! R]M 24      tN] ! R  R!4      4       tOR" tP]Q! ]5R#4      tRR(R$ R% lltS ! R& R'4      tTR# ))a  
This module provides a convenient interface between `libmamba.Solver`
and conda's `PrefixData`. In other words, it allows to expose channels
loaded in `conda` to the `libmamba` machinery without using the
`libmamba` networking stack.

Internally, the `libmamba`'s index is made of:

- A 'Pool' object, exposed to libsolv.
- The pool is made of `Repo` objects.
- Each repo corresponds to a repodata.json file.
- Each repodata comes from a channel+subdir combination.

Some notes about channels
-------------------------

In a way, conda channels are an abstraction over a collection of
channel subdirs. For example, when the user wants 'conda-forge', it
actually means 'repodata.json' files from the configured platform subdir
and 'noarch'. Some channels are actually 'MultiChannel', which provide
a collection of channels. The most common example is 'defaults', which
includes 'main', 'r' and 'msys2'.

So, for conda-forge on Linux amd64 we get:

- https://conda.anaconda.org/conda-forge/linux-64
- https://conda.anaconda.org/conda-forge/noarch

For defaults on macOS with Apple Silicon (M1 and friends):

- https://repo.anaconda.org/main/osx-arm64
- https://repo.anaconda.org/main/noarch
- https://repo.anaconda.org/r/osx-arm64
- https://repo.anaconda.org/r/noarch
- https://repo.anaconda.org/msys2/osx-arm64
- https://repo.anaconda.org/msys2/noarch

However, users will just say 'defaults' or 'conda-forge', for convenience.
This means that we need to deal with several formats of channel information,
which ultimately lead to a collection of subdir-specific URLs:

- Channel names from the CLI or configuration files / env-vars
- Channel URLs if names are not available (channel not served in anaconda.org)
- conda.models.channel.Channel objects

Their origins can be:

- Specified by the user on the command-line (-c arguments)
- Specified by the configuration files (.condarc) or environment vars (context object)
- Added from channel-specific MatchSpec (e.g. `conda-forge::python`)
- Added from installed packages in target environment (e.g. a package that was installed
  from a non-default channel remembers where it comes from)

Also note that a channel URL might have authentication in the form:

- https://user:password@server.com/channel
- https://server.com/t/your_token_goes_here/channel

Finally, a channel can be mounted in a local directory and referred to via
a regular path, or a file:// URL, with or without normalization on Windows.

The approach
------------
We pass the subdir-specific, authenticated URLs to conda's 'SubdirData.repo_patch',
which download the JSON files but do not process them to PackageRecords.
Once the cache has been populated, we can instantiate 'libmamba.Repo' objects directly.
We maintain a map of subdir-specific URLs to `conda.model.channel.Channel`
and `libmamba.Repo` objects.
)annotationsN)	dataclass)partial)Path)TYPE_CHECKING)KNOWN_SUBDIRSREPODATA_FNChannelPriority)context)on_win)DummyExecutorThreadLimitedThreadPoolExecutortime_recorder)path_to_urlremove_authsplit_anaconda_token)PackageCacheData)
SubdirData)Channel)	MatchSpec)PackageRecord)MambaNativeExceptionQuery)DatabasePackageTypesPipAsPythonDependency
PrioritiesRepodataOrigin)ChannelResolveParamsCondaURL
NoArchTypePackageInfo)logger_callback)CallableIterable)AnyLiteral)	PathsType)RepodataState)BuildRepodataSubset)Shards)QueryResult)RepoInfo)PackageRecordDict)SolverInputStatezconda.c                  Z    ] tR t^t$ RtR]R&   R]R&   R]R&   R]R&   ]R	 R
 l4       tRtR# )_ChannelRepoInfoz;A dataclass mapping conda Channels, libmamba Repos and URLszChannel | Nonechannelr,   repostr
url_w_credurl_no_credc                   V ^8  d   QhRR/# )   returnr3    )formats   "L/root/miniconda3/lib/python3.14/site-packages/conda_libmamba_solver/index.py__annotate___ChannelRepoInfo.__annotate__   s           c                	    V P                   '       d   V P                   P                  # V P                  P                  R 4      pVR,          \        9   d
   VR,          # VR,          # )/)r1   canonical_namer5   splitr   )self	url_partss   & r;   rC   _ChannelRepoInfo.canonical_name   sQ    <<<<<...$$**3/	R=M)R= }r>   r9   N)	__name__
__module____qualname____firstlineno____doc____annotations__propertyrC   __static_attributes__r9   r>   r;   r0   r0      s-    A
NO r>   r0   c                     R# )z;
Flag to see whether we should check for sharded repodata.
Tr9   r9   r>   r;   _is_sharded_repodata_enabledrQ      s    
 r>   python_site_packages_pathc          
     ,    V ^8  d   QhRRRRRRRRRR/# )	r7   recordr-   filenamer3   url
channel_idr8   r!   r9   )r:   s   "r;   r<   r<      sA     H HHH 
H 	H Hr>   c           
     v   V P                  R4      ;pR 9   d   \        VP                  4       4      pM\        R4      p\        '       d   RV P                  R4      ;'       g    R/pM/ pV P                  R4      ;'       g    . pV'       dQ   \	        V\
        4      '       d;   VP                  RR4      P                  R4      p\        R	 R
 V 4        4       4      p\        V P                  R4      ;'       g    . 4      pV'       d>   V R,          R8X  d0   V R,          P                  R!4      '       d   VP                  R4       \        R"/ RV R,          bRV R,          bRV P                  RR4      bRV P                  R^ 4      bRVbRVbRV P                  R4      ;'       g    RbRVbRV P                  R4      ;'       g    RbRV P                  R4      ;'       g    RbRV P                  R4      ;'       g    RbRV P                  R4      ;'       g    RbRVbRVbR\        V P                  R4      ;'       g    . 4      bR\        V P                  R4      ;'       g    . 4      bRVbRV P                  R4      ;'       g    ^ bR\        V P                  R4      ;'       g    ^ R,          4      bVB # )#z]
Build libmamba PackageInfo from an unprocessed repodata "packages", "packages.conda" entry.
noarchpythonNorR    track_features ,c              3  8   "   T F  q'       g   K  Vx  K  	  R # 5iNr9   ).0fs   & r;   	<genexpr>2_package_info_from_package_dict.<locals>.<genexpr>   s     T)NARSaa)Ns   	
c              3  @   "   T F  qP                  4       x  K  	  R # 5ira   )strip)rb   ffs   & r;   rd   re      s     )N~((**~s   dependsnameversionpipbuild_stringbuildbuild_numberr1   package_urlplatformsubdirrU   licensemd5sha256
signatures
constrainsdefaulted_keyssize	timestamp  rZ   generic)z2.z3.r9   )getr    title_SUPPORTS_PYTHON_SITE_PACKAGES
isinstancer3   replacerD   list
startswithappendr!   int)	rT   rU   rV   rW   add_pip_as_python_dependencyrY   extrar]   ri   s	   &&&&&    r;   _package_info_from_package_dictr      s    **X&&+@@FLLN+D!%%'4O)P)V)VTV
  ZZ 0177RN*^S99'//S9??DT)N~)NTT 6::i(..B/G$6Nh&9((66u F^y! ZZ, ZZ2	
   H%++  

9%++ JJu## zz(#))r ::l+11r &   

<066B7!" FJJ'78>>B?#$ %& ZZ$$1'( ZZ$))T1
 / r>   c                     ] tR t^tRtR6]R6R6R3RR/R R lllt]R R l4       tR7R R	 llt	R
 R lt
R R ltR8R R lltR R ltR R lt]R R l4       t]R R l4       tR R ltR R ltR9R R lltR R ltR  R! ltR" R# lt]! ] R$7      R% R& l4       tR' R( ltR) R* ltR:R+ R, lltR;R- R. lltR;R/ R0 lltR1 R2 ltR:R3 R4 llt R5t!R# )<LibMambaIndexHelpera  
Interface between conda and libmamba for the purpose of building the "index".
The index is the collection of package records that can be part of a solution.
It is built by collecting all the repodata.json files from channels and their
subdirs. For existing environments, the installed packages are also added to
the index (this helps with simplifying solutions and outputs). The local cache
can also be added as a "channel", which is useful in offline mode or with no
channels configured.
Nbuild_repodata_subsetc               4    V ^8  d   QhRRRRRRRRR	R
RRRR/# )r7   channelszIterable[Channel]subdirsIterable[str]repodata_fnr3   installed_recordsIterable[PackageRecord]	pkgs_dirsr'   in_statezSolverInputState | Noner   zBuildRepodataSubset | Noner9   )r:   s   "r;   r<    LibMambaIndexHelper.__annotate__   sP     )4 )4#)4 )4 	)4
 3)4 )4 *)4  :)4r>   c               	$   . pV F  p	V	P                   '       df   \        P                  R V	P                   V	4       \        R/ V	P	                  4       P                  4        U
Uu/ uF  w  rV
R8w  g   K  WbK  	  upp
B p	VP                  V	4       K  	  Wn        T;'       g    \        P                  V n	        W0n
        W`n        \        P                  V n        Wpn        V P                  4       V n        V P#                  4       V n        V'       d+   V P$                  P'                  V P)                  V4      4       V'       d+   V P$                  P                  V P+                  V4      4       V P-                  4        WPn        W@n        R# u upp
i )zrPlatform-aware channels are not supported. Ignoring platform %s from channel %s. Use subdirs keyword if necessary.rq   Nr9   )rq   loginfor   dumpitemsr   r   r
   r   r   r   r   _add_pip_as_python_dependencyr   _init_dbdb_load_channelsreposextend_load_pkgs_cache_load_installed_set_repo_priorities
_pkgs_dirs_installed_records)rE   r   r   r   r   r   r   r   platform_less_channelsr1   kvs   &&&&&&&$    r;   __init__LibMambaIndexHelper.__init__   sA    13G8 $$ "aglln6J6J6L$`6LdaPQU_P_TQT6L$`a"))'2   /11'//& -4-Q-Q*%:"--/-1-@-@-B
JJd33I>?JJd223DEF!!# $"3' %as   #F3Fc                    V ^8  d   QhRRRR/# )r7   r1   r   r8   r   r9   )r:   s   "r;   r<   r   #  s     ; ;' ;>Q ;r>   c           
     	   VP                   '       g   \        R V R24      hVP                   p\        R/ VP                  4       P	                  4        UUu/ uF  w  r4VR8w  g   K  W4bK  	  uppB pV ! V3V3R7      # u uppi )zChannel z" must define 'platform' attribute.rq   )r   r   r9   )rq   
ValueErrorr   r   r   )clsr1   rr   r   r   s   &&   r;   from_platform_aware_channel/LibMambaIndexHelper.from_platform_aware_channel"  s~    xy0RSTT!!Yglln.B.B.DX.DdaZTQT.DXYWJ	:: Ys   A>&A>c               $    V ^8  d   QhRRRRRR/# )r7   r   zIterable[RepoInfo] | Nonefilter_zCallable | Noner8   r   r9   )r:   s   "r;   r<   r   *  s(      ( ! 
	r>   c                	d   T;'       g&    V P                    Uu. uF  q3P                  NK  	  upp^ pV Fs  pV'       d>   V P                  P                  V4       F  pV! V4      '       g   K  V^,          pK  	  KH  V\	        V P                  P                  V4      4      ,          pKu  	  V# u upi )    )r   r2   r   packages_in_repolen)rE   r   r   	repo_infocountr2   pkgs   &&&    r;   
n_packagesLibMambaIndexHelper.n_packages*  s    
 EE$**E*Y..*ED7733D9Cs||
 : TWW55d;<<   Fs   B-c                    V ^8  d   QhRRRR/# )r7   r1   r   r8   Noner9   )r:   s   "r;   r<   r   :  s     $ $g $$ $r>   c                	   / pVP                  R V P                  R7       F|  pV P                   Fi  pVP                  V8X  g   K  \        P                  RVP                  4       WVP                  &   V P                  P                  VP                  4       Kk  	  K~  	  V P                  VR R7       FD  pV P                   F1  pVP                  VP                  8X  g   K   VP                  Vn	        K3  	  KF  	  V P                  4        R# )Fwith_credentialsr   zReloading repo %stry_solvN)urlsr   r   r5   r   debugr4   r   remove_repor2   r   r   )rE   r1   r   rV   r   new_repo_infos   &&    r;   reload_channel"LibMambaIndexHelper.reload_channel:  s    <<<MC!ZZ	((C/II193H3HI18--.GG''	7	 ( N "000FM!ZZ	((M,E,EE%2%7%7IN ( G 	!!#r>   c                   V ^8  d   QhRR/# )r7   r8   r   r9   )r:   s   "r;   r<   r   H  s     ) )( )r>   c                	"   / V P                    Uu/ uF:  qP                  \        P                  P                  8w  g   K-  VP                  VbK<  	  upC\        P
                  CpVP                  4        UUu/ uFi  w  r4VP                  '       g   K  V\        \        P                  ! VP                  P                  R R4      4      V\        V P                  4      R7      bKk  	  ppp\        P                  P                  4        UUUu/ uF  w  rVTV Uu. uF  pVP                  '       g   K  VP                  VP                  \        \        P                  ! VP                  P                  R R4      4      VP                  \        V P                  4      R7      4      NK  	  upbK  	  pppp\!        \        V P                  4      \        P                  ! \#        \        P                  4      4      \         P$                  ! V4      \         P&                  ! V4      \#        \(        P*                  ! 4       4      \,        P.                  ! 4       R7      p\1        V4      p	V	P3                  \4        4       V	# u upi u uppi u upi u upppi )r^   %20)rV   display_name	platforms)r   channel_aliascustom_channelscustom_multichannelshome_dircurrent_working_dir)r   locationr
   r   rj   r   r   base_urlLibmambaChannelr   parser   setr   r   r~   r   r3   
ChannelMapMultiChannelMapr   homeosgetcwdr   
set_loggerr"   )
rE   cr   rj   r1   channel_namer   r   paramsr   s
   &         r;   r   LibMambaIndexHelper._init_dbH  s   
 #'--`-Q::AVAVA_A_3_yqvvqy-`
 %%	
 $3#8#8#:
 $;D/NN7#3#3#;#;C#GH!dll+ 
 $; 	 
, +2*F*F*L*L*N 
 +O&   (  (G####LL#$NN7+;+;+C+CC+OP%,\\"%dll"3  (  +O 	  
 &$,,'"..W-B-B)CD0;;OL!5!E!EFZ![% "		
 f
o&	K a
 
s6   *I:I:7I?AI?J
J0A7J'J
J
c               $    V ^8  d   QhRRRRRR/# )r7   urls_to_channelzdict[str, Channel] | Noner   boolr8   list[_ChannelRepoInfo]r9   )r:   s   "r;   r<   r   s  s-     L L2L L 
 	Lr>   c                	:   Vf'   V P                  V P                  V P                  4      pV P                  V4      pV P                  '       d?   V P
                  '       d-   V P                  V4      pVe   V# \        P                  R4       V P                  W4      # )Nz=No sharded channels available. Fall back to non-sharded path.)
_channel_urlsr   r   _encoded_urls_to_channelsr   r   _load_channel_repo_info_shardsr   r   _load_channel_repo_info_json)rE   r   r   channel_repos_infos   &&& r;   r   "LibMambaIndexHelper._load_channelss  s    
 ""00t}}MO88I ===T777 "&!D!D_!U!-))IIUV 00KKr>   c                    V ^8  d   QhRRRR/# )r7   r   dict[str, Channel]r8   zlist[_ChannelRepoInfo] | Noner9   )r:   s   "r;   r<   r     s     " "1"	&"r>   c                    V P                   f   R# . V P                  P                  P                  4       OV P                  P                  O5pV P                  W!4      pVf   R# V P                  V4      pV# )z:
Load repository information from sharded repodata cache.
N)r   r   	installedkeys	requested"_load_repo_info_from_repodata_dict)rE   r   root_packageschannel_datachannel_repo_infoss   &&   r;   r   2LibMambaIndexHelper._load_channel_repo_info_shards  so     %%-S$--11668S4==;R;RS11-Q!DD\R!!r>   c               $    V ^8  d   QhRRRRRR/# )r7   r   r   r   r   r8   r   r9   )r:   s   "r;   r<   r     s$     " "1"=A"	"r>   c           
     f   V P                  \        VP                  4       4      4      p. pVP                  4        Fr  w  pw  rg\	        V4      w  r\        V4      p
T P                  TT
TT;'       d    V P                  '       * R7      pVP                  \        W,          VVV
R7      4       Kt  	  V# )z7
Load repository information from repodata.json files.
r   r1   r2   r4   r5   )
_fetch_repodata_jsonstupler   r   r   r   _load_repo_info_from_json_pathr   r   r0   )rE   r   r   urls_to_json_path_and_stater   r4   	json_pathstateurl_no_token_r5   r2   s   &&&         r;   r   0LibMambaIndexHelper._load_channel_repo_info_json  s     '+&@&@G[G[G]A^&_#.I.O.O.Q*J*2:>OL%l3K66"884=='8	 7 D %% +7) +	 /R" "!r>   c               $    V ^8  d   QhRRRRRR/# )r7   r   r   r   zlist[Channel]r8   r   r9   )r:   s   "r;   r<   r     s"      }  J\ r>   c           	        / p\        4       p. pV F7  pVP                  RV R7       F  pVP                  \        V4      4       K  	  K9  	  V EF  pVP                  RR7       Uu. uF'  qfP	                  VP
                  4      '       g   K%  VNK)  	  ppVP                  V4      '       d   K`  VP                  RR7       Uu. uF7  pVP	                  \        V 4      4      '       g   K%  VP                  RR4      NK9  	  ppWx8w  d5   TP                  V Uu/ uF  qfVbK  	  up4       VP                  V4       K  V F   pWc9  g   K  WRV&   VP                  V4       K"  	  EK  	  V# u upi u upi u upi )z*Map authenticated URLs to channel objects.Tr   F)r   r^   r   )r   r   r   r   endswithrr   
issupersetr   r   updateadd)	r   r   r   seen_noauthchannels_with_subdirsr1   rV   noauth_urls	auth_urlss	   &&       r;   r   !LibMambaIndexHelper._channel_urls  sb    e "G||T7|K%,,WS\: L   -G&||U|CC||T[TbTbGcC   %%k22 #<<<>>C<<g/ (C'>  
 'Y?Yc'\Y?@"";/ #) 'IOOC( #% -, +
 @s   &"E(E("E-)E-E2
c                    V ^8  d   QhRRRR/# )r7   r   r   r8   r9   )r:   s   "r;   r<   r     s     ' '3E 'J\ 'r>   c                    / pV P                  4        F2  w  r#VP                  R4      '       d   VP                  RR4      pW1V&   K4  	  V# )z{
Return copy of urls_to_channel with %-encoded spaces.

Usage: _encoded_urls_to_channels(_channel_urls(subdirs, channels))
zfile://r^   r   )r   r   r   )r   encoded_urls_to_channelrV   r1   s   &   r;   r   -LibMambaIndexHelper._encoded_urls_to_channels  sN     79+113LC~~i((kk#u-+2C( 4 '&r>   c                    V ^8  d   QhRRRR/# )r7   r   r   r8   z$dict[str, tuple[str, RepodataState]]r9   )r:   s   "r;   r<   r     s     
 
- 
<` 
r>   c                	   \         P                  '       g   \         P                  ^8X  d   \        M\	        \
        \         P                  R7      pV! 4       ;_uu_ 4       pVP                  V P                  V4       UUUu/ uF  w  rEpV\        V4      V3bK  	  upppuuRRR4       # u upppi   + '       g   i     R# ; i)   )max_workersN)	r
   r   repodata_threadsr   r   r   map_fetch_one_repodata_jsonr3   )rE   r   ExecutorexecutorrV   pathr  s   &&     r;   r   )LibMambaIndexHelper._fetch_repodata_jsons  s     }}} 8 8A = 8gF^F^_ 	
 ZZ8 +3,,t7T7TVZ*[*[&S c$i''*[ Z ZZs    !B1B*B1*B11C	c                    V ^8  d   QhRRRR/# )r7   rV   r3   r8   z&tuple[str, os.PathLike, RepodataState]r9   )r:   s   "r;   r<   r     s     % %C %4Z %r>   c                	   \         P                  ! V4      pVP                  '       g   \        R 4      hR\        P
                  9   d   \        \        P                  P                  4       4       Fe  w  r4\        V\        4      '       g   K  VR,          WP                  38X  g   K8  VP                  \        R4      8X  g   KT  \        P                  V Kg  	  \        W P                  R7      p\        P                   '       g   \        P"                  '       d(   VP$                  pVP&                  P)                  4       pMVP*                  P-                  4       w  rgWV3# )z#Channel URLs must specify a subdir!PYTEST_CURRENT_TEST:Nr7   Ninf)r   )r   from_urlrr   r   r   environr   r   _cache_r   r   r   r   _mtimefloatr
   offlineuse_index_cachecache_path_json
repo_cache
load_state
repo_fetchfetch_latest_path)rE   rV   r1   keycachedsubdir_datar   r  s   &&      r;   r  ,LibMambaIndexHelper._fetch_one_repodata_json  s   ""3'~~~BCC BJJ.  $J$6$6$<$<$>?!#u--r7s$4$455&--5QV<:W"**3/	  @ !6F6FG???g555 $33I**557E  +55GGIIu$$r>   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# )
r7   r   r3   channel_urlr  zRepodataState | Noner   r   r8   zRepoInfo | Noner9   )r:   s   "r;   r<   r     s;     C CC+.C7KCW[C	Cr>   c                	   V'       d$   \         '       d   \        P                  R 4       Rp\        V4      pVP	                  R4      pV'       d#   \        W#P                  VP                  R7      pMRp\        V4      pV P                  V4      pV'       d`   V'       dX    \        P                  RWV4       V P                  P                  \        V4      VV\        \        P                  4      R7      #  \        P                  R	WV4       V P                  P#                  \        V4      TT\        \        P                  4      \        P$                  '       d   \&        P(                  M\&        P*                  R
7      p
T'       d3   T'       d+    T P                  P3                  T
\        T4      TR7       T
# T
#   \          d"   p	\        P                  RT	R7        Rp	?	LRp	?	ii ; i  \,         da   p	R\        T	4      9   dJ   \        P.                  '       d4   \        P1                  RT4       \        P                  RYR7        Rp	?	R# T	hRp	?	ii ; i  \,         d#   p	\        P                  RYR7        Rp	?	T
# Rp	?	ii ; i)zIOverriding truthy 'try_solv' as False on Windows for performance reasons.Fz.solv)rV   etagmodNz(Loading %s (%s) from SOLV repodata at %s)r  expectedrW   r   z&Failed to load from SOLV. Trying JSON.)exc_infoz(Loading %s (%s) from JSON repodata at %s)r  rV   rW   r   package_typeszdoes not existzCould not load repodata for %s.z0Ignored MambaNativeException in offline mode: %s)r2   r  metadataz!Ignored SOLV writing error for %s)r   r   r   r   with_suffixr   r6  r7  r   _channel_to_idr   "add_repo_from_native_serializationr3   r   r
   r   	Exceptionadd_repo_from_repodata_jsonuse_only_tar_bz2r   
TarBz2OnlyCondaOrElseTarBz2r   r(  warningnative_serialize_repo)rE   r   r4  r  r   	solv_pathrepodata_originr1   rW   excr2   s   &&&&&      r;   r   2LibMambaIndexHelper._load_repo_info_from_json_path  s     IIabHO	))'2	,::SXS\S\]O"O+&((1
R		>
Yb wwAAY,)1F<<2	 B  	II:JU^ 7766^%-B88.
 /// !++%77 7 D2 Y--C	N_ . 
 tM  R		BS	QQR& $ 	3s8+ =zJ		Lc	`I	" ( Y		=z	XXYsV   !AF? 8BG. 'I ?G+
G&&G+.I9%I-IIIJ	'JJ	c                   V ^8  d   QhRR/# )r7   r1   r   r9   )r:   s   "r;   r<   r   S  s      g r>   c                	`    VP                   pV\        P                  9   d   VP                  pV# ra   )rC   r
   r   rj   )rE   r1   rW   s   && r;   r=  "LibMambaIndexHelper._channel_to_idS  s,    ++
555
 !Jr>   c                    V ^8  d   QhRRRR/# )r7   recordsr   r8   r0   r9   )r:   s   "r;   r<   r   ]  s     

 

'> 

CS 

r>   c                	    V Uu. uF  q P                  V4      NK  	  ppV P                  P                  VR \        P                  R7      pV P                  P                  V4       \        RVR R R7      # u upi )r   packagesrj   r   Nr   )!_package_info_from_package_recordr   add_repo_from_packagesr   r[   set_installed_repor0   )rE   rN  rT   rQ  r2   s   &&   r;   r   #LibMambaIndexHelper._load_installed]  sy    QXYQXv::6BQXYww--)>)A)A . 

 	""4(t
 	
 Zs   A6c                    V ^8  d   QhRRRR/# )r7   r   r'   r8   zlist[RepoInfo]r9   )r:   s   "r;   r<   r   i  s      )  r>   c           
     	`   . pV F  p\        V4      pVP                  4        VP                  4        Uu. uF  pV P                  V4      NK  	  ppV P                  P                  WcR 7      p\        V4      P                  RR4      pVP                  \        RWxVR7      4       K  	  V# u upi ))rQ  rj   r^   r   Nr   )
r   loadvaluesrR  r   rS  r   r   r   r0   )	rE   r   r   r  package_cache_datarT   rQ  r2   path_as_urls	   &&       r;   r   $LibMambaIndexHelper._load_pkgs_cachei  s    D!1$!7##% 17799F 66v>9   771181OD%d+33C?KLL  tQ\  s   B+)module_namec                    V ^8  d   QhRRRR/# )r7   repodata_subsetzdict[str, ShardBase]r8   r   r9   )r:   s   "r;   r<   r   }  s     + +3+	+r>   c           
        . pVP                  4        F  w  r4\        V4      pV P                  V4      pVP                  p. pVP	                  4        F4  w  r\        V
V	V V	 2VV P                  R7      pVP                  V4       K6  	  V P                  P                  VV\        \        P                  4      R7      pVP                  \        VVVVR7      4       K  	  V# )zN
Load repository information from deserialized repodata.json-like
structures.
)rV   rW   r   rP  r   )r   r   r=  r   iter_recordsr   r   r   r   rS  r   r
   r   r0   )rE   r_  r   r4  	shardlikechannel_objectrW   r   rQ  rU   rT   packager2   s   &&           r;   r   6LibMambaIndexHelper._load_repo_info_from_repodata_dict|  s     &5&;&;&="K %[1N,,^<J ))HH$-$:$:$< 9#*XJ/)151S1S ( %= 7711! -B88. 2 D LL ** +	5 '>F r>   c                    V ^8  d   QhRRRR/# )r7   rT   r   r8   r!   r9   )r:   s   "r;   r<   r     s     #
 #
 #
+ #
r>   c                	   VP                  R R4      '       dJ   VP                  P                  R9   d/   \        VP                  P                  P	                  4       4      pM\        R4      p\
        '       d   RVP                  R4      ;'       g    R/pM/ p\        R/ RVP                  bRVP                  bRVP                  ;'       g    RbRVP                  ;'       g    ^ bR	\        VP                  4      bR
VP                  R4      ;'       g    RbRVP                  bRVP                  ;'       g3    VP                   RVP                   RVP                  ;'       g    R 2bRVP                  R4      ;'       g    RbRVP                  R4      ;'       g    RbRVP                  R4      ;'       g    RbRVP                  R4      ;'       g    RbR\        VP                  R4      ;'       g    . 4      bR\        VP                  R4      ;'       g    . 4      bR\        VP                  R4      ;'       g    . 4      bR\        VP                  R4      ;'       g    . 4      bR VbRVP                  R4      ;'       g    ^ bR\!        VP                  R4      ;'       g    ^ R,          4      bVB # )rY   Nr[   rR   r\   rj   rk   rm   ro   r1   rp   rV   rq   rU   -rs   rt   ru   rv   r]   ri   rw   rx   ry   rz   r{   r|   r9   )r~   rY   valuer    r   r   r!   rj   rk   rn   ro   r3   r1   rr   fnr   r   )rE   rT   rY   r   s   &&  r;   rR  5LibMambaIndexHelper._package_info_from_package_record  s   ::h%%&--*=*=AV*V 3 3 9 9 ;<F%F))+VZZ8S-T-Z-ZXZE E 

NN
  ++
  ,,11	

 '
 

5)//R
 ]]
 YYXXV[[M6>>2B!FLLDVDVTVCW"X
 JJy)//R
 

5!''R
 ::h'--2
 zz,/552
  

+; < B BC
 I.44"5
  FJJ|4::;!
"  

+; < B BC#
$ %
& F#((q'
( 6::k277a4?@+
 	
r>   c                   V ^8  d   QhRR/# )r7   r8   r   r9   )r:   s   "r;   r<   r     s     $Y $Yd $Yr>   c                	   \         P                  \        P                  \        P                  39   p\        V P                  4      pV'       dL   \        V P                   Uu0 uF  q3P                  kK  	  up4      pV P                  ^ ,          P                  pV P                   F  pVP                  f   K  V'       d*   VP                  X8w  d   X^,          pVP                  pXpM^ pV'       d   ^pMTpV^,          p\        P                  RVP                  VV4       V P                  P                  VP                  \        Wx4      4       K  	  R# u upi )r   NzChannel: %s, prio: %s : %s)r
   channel_priorityr	   STRICTFLEXIBLEr   r   rC   r2   r   r   r5   r   set_repo_priorityr   )	rE   has_prioritysubprio_indexr2   channel_priocurrent_channel_namer   prioritysubprioritys	   &        r;   r   (LibMambaIndexHelper._set_repo_priorities  s   //""$$4
 

 DJJ

K
 3 3
KLL#'::a=#?#? I~~%++/CC A%L+4+C+C('  +"II,%%	 GG%%innj6WX1 $  Ls   "Ec               $    V ^8  d   QhRRRRRR/# )r7   queriesz+Iterable[str | MatchSpec] | str | MatchSpecreturn_type!Literal['records', 'dict', 'raw']r8   2list[PackageRecord] | dict[str, Any] | QueryResultr9   )r:   s   "r;   r<   r     s(     	? 	?<	? 7	? 
<		?r>   c                	    \        V\        \        34      '       d   V.p\        \	        \        V4      4      p\
        P                  ! V P                  V4      pV P                  W24      # ra   )	r   r3   r   r   r  r   findr   _process_query_result)rE   rz  r{  results   &&& r;   searchLibMambaIndexHelper.search  sS    
 gY/00iGs3()DGGW-))&>>r>   c               (    V ^8  d   QhRRRRRRRR/# 	r7   queryzstr | MatchSpectreer   r{  r|  r8   r}  r9   )r:   s   "r;   r<   r     2     ? ?? ? 7	?
 
<?r>   c                	|    \        V4      p\        P                  ! V P                  W4      pV P	                  WC4      # ra   )r3   r   ri   r   r  rE   r  r  r{  r  s   &&&& r;   ri   LibMambaIndexHelper.depends  s2     E
tww4))&>>r>   c               (    V ^8  d   QhRRRRRRRR/# r  r9   )r:   s   "r;   r<   r     r  r>   c                	|    \        V4      p\        P                  ! V P                  W4      pV P	                  WC4      # ra   )r3   r   whoneedsr   r  r  s   &&&& r;   r  LibMambaIndexHelper.whoneeds  s2     E
5))&>>r>   c                    V ^8  d   QhRRRR/# )r7   specszIterable[MatchSpec]r8   ztuple[str, ...]r9   )r:   s   "r;   r<   r     s     	$ 	$#6 	$? 	$r>   c                    \        4       pV FF  pV P                  VP                  4       4      pV F  pVP                  VP                  4       K   	  KH  	  \        V4      # )zG
Returns all the package names that (might) depend on the passed specs
)r   ri   dist_strr
  rj   r   )rE   r  explicit_poolspecpkg_recordsrT   s   &&    r;   r  !LibMambaIndexHelper.explicit_pool  sR     #&%D,,t}}7K%!!&++. &  ]##r>   c               $    V ^8  d   QhRRRRRR/# )r7   r  r+   r{  r|  r8   r}  r9   )r:   s   "r;   r<   r   "  s(       7 
<	r>   c                	   VR 8X  d   V# VP                  4       pVP                  R/ 4      P                  R4      R8w  d   VP                  R/ 4      P                  RR4      pVP                  R/ 4      P                  RR4      pVP                  R/ 4      P                  RRVP                  4        24      p\        V R	V R
V 24      hVR8X  d8   . pVR,          R,           F  p\	        R/ VB pVP                  V4       K!  	  V# V# )rawr  statusOKr  typez	<Unknown>msgzFaulty response: z query 'z
' failed: rN  pkgsr9   )to_dictr~   jsonr   r   r   )	rE   r  r{  
query_typer  	error_msgr  r   rT   s	   &&&      r;   r  )LibMambaIndexHelper._process_query_result"  s   
 %M!::h#''1T9GR044V[IJJJw+//EE

8R044U>OPVP[P[P]<_`I
|8E7*YKPQQ)#Kh'//&--""6* 0 r>   )
r   r   r   r   r   r   r   r   r   r   r9   )NN)NT)T)rN  )FrN  )"rH   rI   rJ   rK   rL   r   r   classmethodr   r   r   r   r   r   r   staticmethodr   r   r   r  r   r=  r   r   r   r   rR  r   r  ri   r  r  r  rO   r9   r>   r;   r   r      s     "$&57!,0)4 =A)4 )4V ; ; $)VL,"$"8  B ' '
%4CJ

& x(+ )+Z#
J$YR	???	$ r>   r   )F)UrL   
__future__r   loggingr   dataclassesr   	functoolsr   pathlibr   typingr   conda.base.constantsr   r   r	   conda.base.contextr
   conda.common.compatr   conda.common.ior   r   r   conda.common.urlr   r   r   conda.core.package_cache_datar   conda.core.subdir_datar   conda.models.channelr   conda.models.match_specr   conda.models.recordsr   
libmambapyr   r   libmambapy.solver.libsolvr   r   r   r   r   libmambapy.specsr   r   r   r    r!   mamba_utilsr"   collections.abcr#   r$   r%   r&   conda.common.pathr'   conda.gateways.repodatar(   conda.gateways.shardsr)   conda.gateways.shards.typingr*   	ShardBaser+   r,   shards_typingr-   r  r.   	getLoggerrH   r   r0   rQ   hasattrr   r   r   r9   r>   r;   <module>r     s   DL #  	 !     L L & & Y Y K K : - ( - . 2   )2#+59@&20' &
+,   $ ")6Q!R HVJ	 J	r>   