
    @(i{                    `   S r SSKJr  SSKrSSK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  SS	KJr  SS
KJr  SSKJrJrJr  SSKJr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&  SSK'J(r(J)r)  SSK*J+r+J,r,J-r-J.r.J/r/  SSK0J"r1  SSK0J2r2J3r3J4r4J5r5  SSK6J7r7  SSK8J9r9  \(       a:  SSK:J;r;J<r<  SSKJ=r=J>r>  SSK?J@r@  SSKAJBrB  SSK'JCrC  SSK*JDrD  SSKEJFrF  SSKGJHrH  SS KIJJrJ  \R                  " S!\L 35      rM\ " S" S#5      5       rNS$ rO\P" \5S%5      rQ          S)S& jrR " S' S(5      rSg)*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)build_repodata_subset   )logger_callback)CallableIterable)AnyLiteral)	PathsType)RepodataState)QueryResult)RepoInfo)	ShardBase)PackageRecordDict)SolverInputStatezconda.c                  V    \ rS rSr% SrS\S'   S\S'   S\S'   S\S	'   \SS
 j5       rSrg)_ChannelRepoInfo   z;A dataclass mapping conda Channels, libmamba Repos and URLszChannel | Nonechannelr-   repostr
url_w_credurl_no_credc                    U R                   (       a  U R                   R                  $ U R                  R                  S5      nUS   [        ;   a  US   $ US   $ )N/)r4   canonical_namer8   splitr   )self	url_partss     S/data/cameron/miniconda/lib/python3.13/site-packages/conda_libmamba_solver/index.pyr=   _ChannelRepoInfo.canonical_name   sO    <<<<...$$**3/	R=M)R= }     N)returnr6   )	__name__
__module____qualname____firstlineno____doc____annotations__propertyr=   __static_attributes__rD   rC   rA   r2   r2      s-    A
NO rC   r2   c                 :    [         R                  R                  SL $ )z;
Flag to see whether we should check for sharded repodata.
T)r   pluginsuse_sharded_repodatarD   rC   rA   _is_sharded_repodata_enabledrQ      s     ??//477rC   python_site_packages_pathc           
        U R                  S5      =nS;   a  [        UR                  5       5      nO[        S5      n[        (       a  SU R                  S5      =(       d    S0nO0 n[	        S0 SU S   _SU S   _SU R                  S	S5      _S
U R                  S
S5      _SU_SU_SU R                  S5      =(       d    S_SU_SU R                  S5      =(       d    S_SU R                  S5      =(       d    S_SU R                  S5      =(       d    S_SU R                  S5      =(       d    S_S[        U R                  S5      =(       d    / 5      _S[        U R                  S5      =(       d    / 5      _S[        U R                  S5      =(       d    / 5      _S[        U R                  S5      =(       d    / 5      _SU_SU R                  S5      =(       d    S_S[        U R                  S5      =(       d    SS-  5      _UD6$ )z]
Build libmamba PackageInfo from an unprocessed repodata "packages", "packages.conda" entry.
noarchpythongenericNorR    nameversionbuild_stringbuildbuild_numberr   r4   package_urlplatformsubdirfilenamelicensemd5sha256
signaturestrack_featuresdepends
constrainsdefaulted_keyssize	timestamp  rD   )getr!   title_SUPPORTS_PYTHON_SITE_PACKAGESr"   listint)recordrb   url
channel_idrT   extras         rA   _package_info_from_package_dictrw      s    **X&&+@@FLLN+D!%%'4O)P)VTV
   F^y! ZZ, ZZ2	
   H%+  

9%+ JJu# zz(#)r ::l+1r FJJ'78>B? VZZ	*0b1  

<06B7!" FJJ'78>B?#$ %& ZZ$1'( ZZ$)T1
 / rC   c                     \ rS rSrSrS\SSS4           SS jjr\SS j5       r  S      S!S jjr	S"S jr
S#S	 jr  S$     S%S
 jjr    S&S jr      S'S jrS(S jrS)S jrS*S jr S+         S,S jjrS-S jrS.S jrS/S jr\" \ S9    S0S j5       rS1S jrS2S jr S3     S4S jjr  S5       S6S jjr  S5       S6S jjrS7S jr S3     S8S jjrSrg)9LibMambaIndexHelper   a  
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.
rD   Nc                   / nU H  nUR                   (       ae  [        R                  SUR                   U5        [        S0 UR	                  5       R                  5        V	V
s0 s H  u  pU	S:w  d  M  X_M     sn
n	D6nUR                  U5        M     Xpl        U=(       d    [        R                  U l	        X0l
        X`l        U R                  5       U l        U R                  5       U l        U(       a*  U R                  R!                  U R#                  U5      5        U(       a*  U R                  R                  U R%                  U5      5        U R'                  5         XPl        X@l        g s  sn
n	f )NzrPlatform-aware channels are not supported. Ignoring platform %s from channel %s. Use subdirs keyword if necessary.r`   rD   )r`   loginfor   dumpitemsappendchannelsr   subdirsrepodata_fnin_state_init_dbdb_load_channelsreposextend_load_pkgs_cache_load_installed_set_repo_priorities
_pkgs_dirs_installed_records)r?   r   r   r   installed_records	pkgs_dirsr   platform_less_channelsr4   kvs              rA   __init__LibMambaIndexHelper.__init__   s'    "$G8 $$ "aglln6J6J6L$`6LdaPQU_P_TQT6L$`a"))'2   /1'//& --/-1-@-@-B
JJd33I>?JJd223DEF!!# $"3# %as   "E,2E,c           
         UR                   (       d  [        SU S35      eUR                   n[        S0 UR                  5       R	                  5        VVs0 s H  u  p4US:w  d  M  X4_M     snnD6nU " U4U4S9$ s  snnf )NzChannel z" must define 'platform' attribute.r`   )r   r   rD   )r`   
ValueErrorr   r~   r   )clsr4   ra   r   r   s        rA   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                P   U=(       d&    U R                    Vs/ s H  o3R                  PM     snnSnU Hi  nU(       a8  U R                  R                  U5       H  nU" U5      (       d  M  US-  nM     MB  U[	        U R                  R                  U5      5      -  nMk     U$ s  snf )Nr   r$   )r   r5   r   packages_in_repolen)r?   r   filter_	repo_infocountr5   pkgs          rA   
n_packagesLibMambaIndexHelper.n_packages  s    
 E$**E*Y..*ED7733D9Cs||
 : TWW55d;<<   Fs   B#c                   0 nUR                  SU R                  S9 H{  nU R                   Hh  nUR                  U:X  d  M  [        R                  SUR                  5        XUR                  '   U R                  R                  UR                  5        Mj     M}     U R                  USS9 HC  nU R                   H0  nUR                  UR                  :X  d  M  UR                  Ul	        M2     ME     U R                  5         g )NFwith_credentialsr   zReloading repo %stry_solv)urlsr   r   r8   r|   debugr7   r   remove_repor5   r   r   )r?   r4   r   rt   r   new_repo_infos         rA   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 	!!#rC   c                   0 U R                    Vs0 s H9  oR                  [        R                  R                  :w  d  M,  UR                  U_M;     snE[        R
                  EnUR                  5        VVs0 s He  u  p4UR                  (       d  M  U[        [        R                  " UR                  R                  SS5      5      U[        U R                  5      S9_Mg     nnn[        R                  R                  5        VVVs0 s H  u  pVUU Vs/ s H  nUR                  (       d  M  UR                  UR                  [        [        R                  " UR                  R                  SS5      5      UR                  [        U R                  5      S95      PM     sn_M     nnnn[!        [        U R                  5      [        R                  " [#        [        R                  5      5      [         R$                  " U5      [         R&                  " U5      [#        [(        R*                  " 5       5      [,        R.                  " 5       S9n[1        U5      n	U	R3                  [4        5        U	$ s  snf s  snnf s  snf s  snnnf )N %20)rt   display_name	platforms)r   channel_aliascustom_channelscustom_multichannelshome_dircurrent_working_dir)r   locationr   r   rZ   r   r   base_urlLibmambaChannelr    parsereplacesetr   r   rn   r   r6   
ChannelMapMultiChannelMapr   homeosgetcwdr   
set_loggerr%   )
r?   cr   rZ   r4   channel_namer   r   paramsr   s
             rA   r   LibMambaIndexHelper._init_db2  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   +I2I27I7AI7JI=.A4I="J=Jc                >   Uc  U R                  5       n0 nUR                  5        H1  u  pEUR                  S5      (       a  UR                  SS5      nXSU'   M3     UnU R                  (       a   [        5       (       a  U R                  U5      $ U R                  X5      $ )Nzfile://r   r   )_channel_urlsr   
startswithr   r   rQ   _load_channel_repo_info_shards_load_channel_repo_info_json)r?   urls_to_channelr   encoded_urls_to_channelrt   r4   s         rA   r   "LibMambaIndexHelper._load_channels]  s    
 ""002O #%+113LC~~i((kk#u-+2C( 4 2 ==9;;66GG 00KKrC   c                    / U R                   R                  R                  5       QU R                   R                  Q7n[	        X!5      nU R                  U5      nU$ )z:
Load repository information from sharded repodata cache.
)r   	installedkeys	requestedr#   "_load_repo_info_from_repodata_dict)r?   r   root_packageschannel_datachannel_repo_infoss        rA   r   2LibMambaIndexHelper._load_channel_repo_info_shardsu  sR     T$--11668S4==;R;RS,]L!DD\R!!rC   c           
     P   U R                  [        UR                  5       5      5      n/ nUR                  5        Hg  u  nu  pg[	        U5      u  p[        U5      n
U R                  UU
UU=(       a    U R                  (       + S9nUR                  [        X   UUU
S95        Mi     U$ )z7
Load repository information from repodata.json files.
r   r4   r5   r7   r8   )
_fetch_repodata_jsonstupler   r   r   r   _load_repo_info_from_json_pathr   r   r2   )r?   r   r   urls_to_json_path_and_stater   r7   	json_pathstateurl_no_token_r8   r5   s               rA   r   0LibMambaIndexHelper._load_channel_repo_info_json  s     '+&@&@G[G[G]A^&_#.I.O.O.Q*J*2:>OL%l3K66"84=='8	 7 D %% +7) +	 /R" "!rC   c           	     (   0 n[        5       n/ nU R                   H>  nUR                  SU R                  S9 H  nUR	                  [        U5      5        M     M@     U GH  nUR                  SS9 Vs/ s H0  nUR                  [        U R                  5      5      (       d  M.  UPM2     nnUR                  U5      (       a  Mf  UR                  SS9 Vs/ s H@  nUR                  [        U R                  5      5      (       d  M.  UR                  SS5      PMB     nnXg:w  a5  UR                  U Vs0 s H  oUU_M     sn5        UR                  U5        M  U H  nXR;  d  M
  XAU'   UR                  U5        M!     GM"     U$ s  snf s  snf s  snf )z*Maps authenticated URLs to channel objectsTr   F)r   r   r   )r   r   r   r   r   r   endswithr   
issupersetr   updateadd)r?   r   seen_noauthchannels_with_subdirsr4   rt   noauth_urls	auth_urlss           rA   r   !LibMambaIndexHelper._channel_urls  su   e "}}G||T4<<|P%,,WS\: Q % -G #<<<??C<<dll 34 ?  
 %%k22 #<<<>>C<<dll 34 (C'>  
 'Y?Yc'\Y?@"";/ #) 'IOOC( #) -0 / @s   4-F%F-F
F
3F
c           
     j   [         R                  (       d  [         R                  S:X  a  [        O[	        [
        [         R                  S9nU" 5        nUR                  U R                  U5       VVVs0 s H  u  pEnU[        U5      U4_M     snnnsS S S 5        $ s  snnnf ! , (       d  f       g = f)Nr$   )max_workers)	r   r   repodata_threadsr   r   r   map_fetch_one_repodata_jsonr6   )r?   r   Executorexecutorrt   pathr   s          rA   r   )LibMambaIndexHelper._fetch_repodata_jsons  s     }} 8 8A = 8gF^F^_ 	
 Z8 +3,,t7T7TVZ*[*[&S c$i''*[ Z Zs   !B$4B
B$B$$
B2c                   [         R                  " U5      nUR                  (       d  [        S5      eS[        R
                  ;   a  [        [        R                  R                  5       5       H^  u  p4[        U[        5      (       d  M  US S XR                  4:X  d  M2  UR                  [        S5      :X  d  MM  [        R                  U	 M`     [        X R                  S9n[        R                   (       d  [        R"                  (       a'  UR$                  nUR&                  R)                  5       nOUR*                  R-                  5       u  pgXU4$ )Nz#Channel URLs must specify a subdir!PYTEST_CURRENT_TEST   inf)r   )r   from_urlra   r   r   environrq   r   _cache_r   
isinstancer   r   _mtimefloatr   offlineuse_index_cachecache_path_json
repo_cache
load_state
repo_fetchfetch_latest_path)r?   rt   r4   keycachedsubdir_datar   r   s           rA   r   ,LibMambaIndexHelper._fetch_one_repodata_json  s    ""3'~~BCC BJJ.  $J$6$6$<$<$>?!#u--r7s$4$455&--5QV<:W"**3/	  @ !6F6FG??g55 $33I**557E  +55GGIIu$$rC   c                   U(       a"  [         (       a  [        R                  S5        Sn[        U5      nUR	                  S5      nU(       a  [        X#R                  UR                  S9nOS n[        U5      nU R                  U5      nU(       a[  U(       aT   [        R                  SXU5        U R                  R                  [        U5      UU[        [        R                  5      S9$  [        R                  S	XU5        U R                  R#                  [        U5      UU[        [        R                  5      [        R$                  (       a  [&        R(                  O[&        R*                  S
9n
U(       a.  U(       a'   U R                  R3                  U
[        U5      US9  U
$ U
$ ! [          a  n	[        R                  SU	S9   S n	A	NS n	A	ff = f! [,         aZ  n	S[        U	5      ;   aD  [        R.                  (       a/  [        R1                  SU5        [        R                  SXS9   S n	A	g U	eS n	A	ff = f! [,         a  n	[        R                  SXS9   S n	A	U
$ S n	A	ff = f)NzIOverriding truthy 'try_solv' as False on Windows for performance reasons.Fz.solv)rt   etagmodz(Loading %s (%s) from SOLV repodata at %s)r   expectedru   add_pip_as_python_dependencyz&Failed to load from SOLV. Trying JSON.)exc_infoz(Loading %s (%s) from JSON repodata at %s)r   rt   ru   r  package_typeszdoes not existzCould not load repodata for %s.z0Ignored MambaNativeException in offline mode: %s)r5   r   metadataz!Ignored SOLV writing error for %s)r   r|   r   r   with_suffixr   r  r  r   _channel_to_idr   "add_repo_from_native_serializationr6   r   r   r  	Exceptionadd_repo_from_repodata_jsonuse_only_tar_bz2r   
TarBz2OnlyCondaOrElseTarBz2r   r  warningnative_serialize_repo)r?   r   channel_urlr   r   	solv_pathrepodata_originr4   ru   excr5   s              rA   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R& $ 	3s8+ =zJ		Lc	`I	" ( Y		=z	XYsQ   AF+ -BG $H= +
G5GG
H: AH53H55H:=
I&I!!I&c                ^    UR                   nU[        R                  ;   a  UR                  nU$ N)r=   r   r   rZ   )r?   r4   ru   s      rA   r  "LibMambaIndexHelper._channel_to_id+  s,    ++
555
 !JrC   c                    U Vs/ s H  o R                  U5      PM     nnU R                  R                  US[        R                  S9nU R                  R                  U5        [        S USSS9$ s  snf )Nr   )packagesrZ   r  r   )!_package_info_from_package_recordr   add_repo_from_packagesr   rX   set_installed_repor2   )r?   recordsrs   r(  r5   s        rA   r   #LibMambaIndexHelper._load_installed5  sy    QXYQXv::6BQXYww--)>)A)A . 

 	""4(t
 	
 Zs   A1c           
     V   / nU H  n[        U5      nUR                  5         UR                  5        Vs/ s H  nU R                  U5      PM     nnU R                  R                  XcS9n[        U5      R                  SS5      nUR                  [        S XxUS95        M     U$ s  snf )Nr(  rZ   r   r   r   )
r   loadvaluesr)  r   r*  r   r   r   r2   )	r?   r   r   r   package_cache_datars   r(  r5   path_as_urls	            rA   r   $LibMambaIndexHelper._load_pkgs_cacheA  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           
        / nUR                  5        H  u  p4UR                  5       n[        U5      nU R                  U5      nUR                  n/ n	S HM  n
UR                  U
0 5      R                  5        H&  u  p[        UUU U 3US9nU	R                  U5        M(     MO     U R                  R                  XS9nUR                  [        UUUUS95        M     U$ )zN
Load repository information from deserialized repodata.json-like
structures.
)r(  zpackages.conda)rt   ru   r/  r   )r   build_repodatar   r  r   rn   rw   r   r   r*  r2   )r?   repodata_subsetr   r  	shardlikerepodatachannel_objectru   r   r(  package_grouprb   rs   packager5   s                  rA   r   6LibMambaIndexHelper._load_repo_info_from_repodata_dictT  s     &5&;&;&="K //1H %[1N,,^<J ))HH!?(0]B(G(M(M(O$H= 'j
3#-	G OOG, )P "@ 771181VDLL ** +	- '>> rC   c                T   UR                  SS 5      (       aH  UR                  R                  S;   a.  [        UR                  R                  R	                  5       5      nO[        S5      n[
        (       a  SUR                  S5      =(       d    S0nO0 n[        S0 SUR                  _SUR                  _SUR                  =(       d    S_S	UR                  =(       d    S
_S[        UR                  5      _SUR                  S5      =(       d    S_SUR                  _SUR                  =(       d1    UR                   SUR                   SUR                  =(       d    S 3_SUR                  S5      =(       d    S_SUR                  S5      =(       d    S_SUR                  S5      =(       d    S_SUR                  S5      =(       d    S_S[        UR                  S5      =(       d    / 5      _S[        UR                  S5      =(       d    / 5      _S[        UR                  S5      =(       d    / 5      _S[        UR                  S5      =(       d    / 5      _SU_SUR                  S5      =(       d    S
_S[!        UR                  S5      =(       d    S
S-  5      _UD6$ )NrT   rU   rX   rR   rY   rZ   r[   r\   r^   r   r4   r_   rt   r`   rb   -rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rD   )rn   rT   valuer!   ro   rp   r"   rZ   r[   r]   r^   r6   r4   ra   fnrq   rr   )r?   rs   rT   rv   s       rA   r)  5LibMambaIndexHelper._package_info_from_package_record~  sY   ::h%%&--*=*=AV*V 3 3 9 9 ;<F%F))+VZZ8S-T-ZXZE E 

NN
  +
  ,,1	

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

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

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

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

+; < BC#
$ %
& F#(q'
( 6::k27a4?@+
 	
rC   c                   [         R                  [        R                  [        R                  4;   n[        U R                  5      nU(       aH  [        U R                   Vs1 s H  o3R                  iM     sn5      nU R                  S   R                  nU R                   H  nUR                  c  M  U(       a$  UR                  W:w  a  WS-  nUR                  nWnOSnU(       a  SnOUnUS-  n[        R                  SUR                  UU5        U R                  R                  UR                  [        Xx5      5        M     g s  snf )Nr   r$   zChannel: %s, prio: %s : %s)r   channel_priorityr
   STRICTFLEXIBLEr   r   r=   r5   r|   r   r8   r   set_repo_priorityr   )	r?   has_prioritysubprio_indexr5   channel_priocurrent_channel_namer   prioritysubprioritys	            rA   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                    [        U[        [        45      (       a  U/n[        [	        [        U5      5      n[
        R                  " U R                  U5      nU R                  X25      $ r%  )	r   r6   r   rq   r   r   findr   _process_query_result)r?   queriesreturn_typeresults       rA   searchLibMambaIndexHelper.search  sS    
 gY/00iGs3()DGGW-))&>>rC   c                |    [        U5      n[        R                  " U R                  X5      nU R	                  XC5      $ r%  )r6   r   rh   r   rR  r?   querytreerT  rU  s        rA   rh   LibMambaIndexHelper.depends  s2     E
tww4))&>>rC   c                |    [        U5      n[        R                  " U R                  X5      nU R	                  XC5      $ r%  )r6   r   whoneedsr   rR  rY  s        rA   r^  LibMambaIndexHelper.whoneeds  s2     E
5))&>>rC   c                    [        5       nU HF  nU R                  UR                  5       5      nU H  nUR                  UR                  5        M      MH     [        U5      $ )zG
Returns all the package names that (might) depend on the passed specs
)r   rh   dist_strr   rZ   r   )r?   specsexplicit_poolspecpkg_recordsrs   s         rA   rc  !LibMambaIndexHelper.explicit_pool  sR     #&%D,,t}}7K%!!&++. &  ]##rC   c                   US:X  a  U$ UR                  5       nUR                  S0 5      R                  S5      S:w  a  UR                  S0 5      R                  SS5      nUR                  S0 5      R                  SS5      nUR                  S0 5      R                  SS	UR                  5        35      n[        U S
U SU 35      eUS:X  a/  / nUS   S    H  n[	        S0 UD6nUR                  U5        M!     U$ U$ )NrawrU  statusOKrZ  typez	<Unknown>msgzFaulty response: z query 'z
' failed: r,  pkgsrD   )to_dictrn   jsonr   r   r   )	r?   rU  rT  
query_typerZ  	error_msgre  r   rs   s	            rA   rR  )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 rC   )r   r   r   r   r   r   r   r   )r   zIterable[Channel]r   Iterable[str]r   r6   r   Iterable[PackageRecord]r   r*   r   zSolverInputState | None)r4   r   rE   ry   )NN)r   zIterable[RepoInfo] | Noner   zCallable | NonerE   rr   )r4   r   rE   None)rE   r   )NT)r   zdict[str, Channel] | Noner   boolrE   list[_ChannelRepoInfo])r   dict[str, Channel]rE   rw  )r   rx  r   rv  rE   rw  )rE   rx  )r   rs  rE   z$dict[str, tuple[str, RepodataState]])rt   r6   rE   z&tuple[str, os.PathLike, RepodataState])T)
r   r6   r  r6   r   zRepodataState | Noner   rv  rE   zRepoInfo | None)r4   r   )r,  rt  rE   r2   )r   r*   rE   zlist[RepoInfo])r8  zdict[str, ShardBase]rE   rw  )rs   r   rE   r"   )rE   ru  )r,  )rS  z+Iterable[str | MatchSpec] | str | MatchSpecrT  !Literal['records', 'dict', 'raw']rE   2list[PackageRecord] | dict[str, Any] | QueryResult)Fr,  )rZ  zstr | MatchSpecr[  rv  rT  ry  rE   rz  )rb  zIterable[MatchSpec]rE   ztuple[str, ...])rU  r,   rT  ry  rE   rz  ) rF   rG   rH   rI   rJ   r	   r   classmethodr   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   r)  r   rV  rh   r^  rc  rR  rM   rD   rC   rA   ry   ry      sN    "$&57!,0%4#%4 %4 	%4
 3%4 %4 *%4N ; ; ,0#'( ! 
	 $)Z 6:L2L L 
 	L0"1"	""1"=A"	"8 D
%6 _cCC+.C7KCW[C	CJ

& x('3'	' )'R#
J$YX :C	?<	? 7	? 
<		? 9B	?? ? 7	?
 
<? 9B	?? ? 7	?
 
<?	$ :C 7 
<	 rC   ry   )
rs   r/   rb   r6   rt   r6   ru   r6   rE   r"   )TrJ   
__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"   #conda_libmamba_solver.shards_subsetr#   mamba_utilsr%   collections.abcr&   r'   r(   r)   conda.common.pathr*   conda.gateways.repodatar+   r,   r-   conda_libmamba_solver.shardsr.   shards_typingr/   r   r0   	getLoggerrF   r|   r2   rQ   hasattrrp   rw   ry   rD   rC   rA   <module>r     s  DL #  	 !     L L & & Y Y K K : - ( - . 2   F (2#+5&260' &
+,   $8 ")6Q!R 55),5365DG55pp prC   