
    8xd3                       d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
mZ d dlmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZmZmZmZmZmZmZmZ d d	lmZ d d
l m!Z! d dl"Z#d dl$Z$d dl%Z%d dl&m'Z' d dl(m)Z) d dl*m+Z+ d dl,m-Z. d dl"m/Z/ d dl0m1Z1m2Z2 d dl3m3Z3 d dl4m5Z5 d dl6m7Z7 d dl8m9Z9 d dl:m;Z; d dl<m=Z=m>Z> ddl=m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZH ddlImJZJ ddl>mKZKmLZLmMZMmNZNmOZOmPZPmQZQ  ePeR          ZS G d de          ZT	 d dlUmVZVmWZW nc# eX$ r[ i ddddd dd!dd"dd#d#d$d$d%d$d&d&d'd'd(d(d)d*d+d+d,d,d-d-d.d/d0d1ZW eYeW          ZV eY eWjZ                              Z[Y nw xY wd a\da]d2a^d2a_g a`i aa ebed3          r" ejc                    dk    r ejc                    ndZdeje        d4k    r efd5ed          Zdd6Zgd7Zh	 	 	 	 	 	 	 	 d^d:Zid; Zj	 	 	 	 	 	 	 	 	 	 d_d<Zk eJd=d>d?@          d8ddedd8d8ddd9dd8dfdA            Z-dB ZldC ZmdZndZodDZpdEZqdFZrdG ZsdH ZtdI Zud`dJZvdK ZwdL ZxdM ZydN ZzdO Z{dP Z|dQ Z}dR Z~dS ZdT ZdU ZdadVZi fdWZdX ZdY ZdbdZZd[ Z G d\ d]          ZdS )c    N)OrderedDict)ExecutorProcessPoolExecutor)datetime)partial)groupby)Number)abspathbasenamedirnamegetmtimegetsizeisfilejoinsplitext)Path)uuid4)ensure_binary)
SubdirData)Channel)update_index)InvalidArchiveError)EnvironmentPackageLoader)tqdm)ConstructorError)ParserError)ReaderError)ScannerError)conda_interfaceutils   )

CondaErrorCondaHTTPError	MatchSpecResolveTemporaryDirectoryVersionOrdercontext	get_indexhuman_bytesurl_path)
deprecated)CONDA_PACKAGE_EXTENSION_V1CONDA_PACKAGE_EXTENSION_V2CONDA_PACKAGE_EXTENSIONSFileNotFoundErrorJSONDecodeError
get_loggerglobc                       e Zd Zd ZdS )DummyExecutorc              '   8   K   |D ]}|D ]} ||          V  d S N )selffunc	iterablesiterablethings        1lib/python3.11/site-packages/conda_build/index.pymapzDummyExecutor.mapQ   sJ      ! 	" 	"H! " "d5kk!!!!"	" 	"    N)__name__
__module____qualname__r@   r9   rA   r?   r6   r6   P   s#        " " " " "rA   r6   )NAMESPACE_PACKAGE_NAMESNAMESPACES_MAPpythonrzr-basezmro-basezmro-base_implerlangjavaopenjdkjulialatexluanodejsjsperlphprubyzm2-basem2zmsys2-conda-epochm2w64 	cpu_countwin320   i0*  z.lockFTc
           	      
   d}
t          t          j        |                    }|st          |          }t          j                            || d          }t          j                            |          rt          j                            |          }
|sLt          j                            |          r-t          | k    s"t          |k    s|
t          k    st          |k    r{t          |          }t          j        j        t          gz   }|r't!          t          j        t"          j        |          }nR|r't!          t          j        t"          j        |          }n)t!          t          j        t"          j        dz   |          } |            5  t          j                            |          r7t-          |          fd|D             }|vr|                    d           t1          ||            t3          ||           | dk    rt4          j        } 	 t9          || dt:          j        | 	          anG# t@          $ r: d
|v r|!                    d
           t9          ||dt:          j        | 	          aY nw xY wd t>          "                                D             }i }|D ]l}|j#        dk    r|j$        }t          j%        r|&                    d          }nt          j        '                    |j$                  st          j        (                    t          j                            t          j        j)        |j$                            r4t          j                            t          j        j)        |j$                  }t          j                            ||j*        d          }d}d}t          j                            |          r||k     r	 tW          |d          5 }tY          j-        |          t\          |j*        <   ddd           n# 1 swxY w Y   n6# t^          t`          f$ r tc          j2        d           |dz  }Y nw xY w||k     nHt:          j        s<	 t          j3        |j4        dz             t\          |j*        <   n# t@          $ r Y w xY w|j4        t:          j5        v r_t\          6                    |j*                  r@|6                    di           }|7                    t\          |j*                            ||d<   n|t\          d
<   ddd           n# 1 swxY w Y   t          j                            |          a| a	|a
|at>          t          t\          fS )z
    Used during package builds to create/get a channel including any local or
    newly built packages. This function both updates and gets index data.
    r   repodata.jsonloggersr"   c                 $    g | ]}|d k    r|nS )localr9   ).0url
local_paths     r?   
<listcomp>z#get_build_index.<locals>.<listcomp>   s%    NNN#sg~~:NNNrA   )verbosenoarchF)channel_urlsprepend	use_local	use_cacheplatformdefaultsc                     h | ]	}|j         
S r9   )channel)r`   recs     r?   	<setcomp>z"get_build_index.<locals>.<setcomp>   s     N N N N N NrA   file/channeldata.jsonzr+Ng?z/channeldata.jsonpackages)8listr!   ensure_listr   ospathr   r   r   local_subdirlocal_output_folderlocal_index_timestampcached_channelsLoggingContextdefault_loggersrB   r   loggingDEBUGWARNCRITICALisdirr,   insert_ensure_valid_channel_delegated_update_indexr    subdirr*   r)   offlinecached_indexr$   removevaluesschemelocationon_winlstripisabsexistssepnameopenjsonloadchannel_dataOSErrorr2   timesleepdownload_channeldatabase_urldefault_channelsgetupdate)r   bldpkgs_diroutput_folderclear_cacheomit_defaultsrf   debugrd   lockingtimeoutmtime
index_fileurlsr]   log_contextexpanded_channelssuperchannelrm   r   channeldata_fileretrymax_retriesfrs   rb   s                           @r?   get_build_indexr      s   , E),7788L -,, mV_EEJ	w~~j!! -  ,, 	m'w~~j))m' 6!!-//(((l**
 L!!&6(C 	!%"6wWWWKK 	!%"6gVVVKK!$g&6&:G  K []] S	4 S	4 w}}]++ /%m44
NNNNNNNT))KK:...!-888#M5AAAA
 !!(/  )!% --#%o#      " 	 	 	%%KK
+++(!%)#%o#     	 !O N8K8K8M8M N N NL, &8 &8>V++&/H| O#+??3#7#7W]]7+;<< ORW['2BCCB B O $&7<<W=M#N#N')w|| ',0B( ($ E"#Kw~~&677 +#k11+%)*:D%A%A !NQAE1L$>!N !N !N !N !N !N !N !N !N !N !N !N !N !N !N %$+_#= + + + $
3 %
+ $k11 #? %%9>9S ' 03F F: :L66  . % % %$H% #w'???LDTDTLE E?  ,//
B??HOOL$>???/7L,'3L$gS	4 S	4 S	4 S	4 S	4 S	4 S	4 S	4 S	4 S	4 S	4 S	4 S	4 S	4 S	4h !# 0 0 < <+&.<<s   B
T.H<;T.<AJ =T.?J  ET.P%+"PP%PP% P!P%$T.%*QT.QT.))RT.
R!T. R!!BT..T25T2c                     |dhD ]U}t           j                            | |          }t           j                            |          st          j        |           Vd S )Nre   )rv   rw   r   r   makedirs)local_folderr   folderrw   s       r?   r   r     s\    8$  w||L&11w}}T"" 	K rA   c                     t           j                            |           \  }}|t          j        v r|} |g}t          | |||||||||	|
          S )z
    update_index as called by conda-build, delegating to standalone conda-index.
    Needed to allow update_index calls on single subdir.
    )
	check_md5channel_namepatch_generatorthreadsrd   progresssubdirswarncurrent_index_versionsr   )rv   rw   splitr!   DEFAULT_SUBDIRS_update_index)dir_pathr   r   r   r   rd   r   r   r   r   r   parent_pathr   s                r?   r   r   #  sn    & 7==22K%''')!'5   rA   z3.25.0z4.0.0zUse standalone conda-index.)addendumc           
      $   t           j                            |           \  }}|t          j        v r3|	rt
                              d           t          ||||||||
          S t          | |||||          	                    |||||
|          S )a  
    If dir_path contains a directory named 'noarch', the path tree therein is treated
    as though it's a full channel, with a level of subdirs, each subdir having an update
    to repodata.json.  The full channel will also have a channeldata.json file.

    If dir_path does not contain a directory named 'noarch', but instead contains at least
    one '*.tar.bz2' file, the directory is assumed to be a standard subdir, and only repodata.json
    information will be updated.

    zThe update_index function has changed to index all subdirs at once.  You're pointing it at a single subdir.  Please update your code to point it at the channel root, rather than a subdir.)r   r   r   rd   r   hotfix_source_repor   )r   r   deep_integrity_checkr   )r   rd   r   r   r   r   )
rv   rw   r   r!   r   logr   r   ChannelIndexindex)r   r   r   r   r   rd   r   r   r   r   r   r   r   	base_pathr   s                  r?   r   r   M  s    4 x00Iw%''' 	HHa   %1#9	
 	
 	
 		
 &   e'-5   rA   c                 v   |                      d          r	| d         }nt                      }|                      dg           D ]:}	 |                    t          |          j                   +# t
          $ r Y 7w xY w|t          z  }t          |          dk    r t          |	                                         }nd}|| d<   |                      d          s?d| d         v r5| d         
                    dd          \  }}||k    r| d         | d<   || d<   ||                      d| d                   | d         fS )	N	namespacedependsr"   globalnamespace_in_name-r   name_in_channel)r   setaddr%   r   r#   rE   lenrF   popr   )infor   depends_namesspecspacesnamespace_prefixreduced_names          r?   _determine_namespacer     sU   xx &%		HHY++ 	 	D!!)D//"67777   !88v;;!&vzz||4II I%[88'(( (SDL-@-@)-f););C)C)C&,y((&*6lD"#'DLdhh0$v,??fMMs   'A..
A;:A;c                 :    t          |           } | dk    r| dz  } | S )N   A   )int)	timestamps    r?   _make_secondsr     s-    II<	
	 rA   r[   zrepodata_from_packages.json)descriptiondev_urldoc_urldoc_source_urlhomelicensereference_package
source_urlsource_git_urlsource_git_tagsource_git_revsummaryversionr   icon_url	icon_hashrun_exportsbinary_prefixtext_prefix
activate.ddeactivate.dpre_link	post_link
pre_unlinktagsidentifierskeywordsrecipe_origincommitsc                    || v r|	 | |                                                              dd          | |<   d S # t          $ r; | |         d                                                              dd          | |<   Y d S w xY wd S )N
 r   )stripreplaceAttributeError)record
field_names     r?   _clear_newline_charsr    s    V	R!'
!3!9!9!;!;!C!CD#!N!NF: 	R 	R 	R!'
!3A!6!<!<!>!>!F!FtS!Q!QF:	R s   19 AA>=A>c                    |                     dg            t          j        |                    di           |                    di           dd           d |                    di                                           D             }t          j        |                    di           |dd           t          j        |                    di           |                    di           dd           |                    dd          D ]}d	D ]}|                    t                    r&|dk    r |                    t          t                    }|||         v r8d
||         |         d<   ||         |         d         	                    d           |                    dd          D ]}d	D ]{}|                    t                    r&|dk    r |                    t          t                    }||         
                    |d           }|r|d         	                    |           ||d                                          |S )Nremovedrs   F)mergeadd_missing_keysc                 V    i | ]&\  }}|                     t          t                    |'S r9   )r  r.   r/   r`   kvs      r?   
<dictcomp>z'_apply_instructions.<locals>.<dictcomp>  s>       Aq 	
		,.HII1  rA   packages.condarevoker9   )rs   r  Trevokedr   package_has_been_revokedr   )
setdefaultr!   merge_or_update_dictr   itemsendswithr.   r  r/   appendr   sort)r   repodatainstructionsnew_pkg_fixesfnkeypoppeds          r?   _apply_instructionsr!    s   	2&&&	Z$$R((	     $$Z44::<<  M
 
%r**	    
%r**)2..	    x,, P P1 	P 	PC{{566 X3BR;R;RZZ :<VWWXc]""/3b!),b!),334NOOO	P x,, / /1 	/ 	/C{{566 X3BR;R;RZZ :<VWWc]&&r400F /#**2...	/ YOrA   c                      d } d }t          t          dd                    }t          |j        d<   | |j        d<   ||j        d<   d	|_        d	|_        |S )
Nc                     t          | t                    rE| dk    r| dz  } t          j        |                               t          j        d                    } |                     |          S )Nr   r   UTCtzinfo)
isinstancer	   r   utcfromtimestampr  pytztimezonestrftime)dt	dt_formats     r?   _filter_strftimez1_get_jinja2_environment.<locals>._filter_strftime  sf    b&!! 	TL  t*2..66dmE>R>R6SSB{{9%%%rA   c                     |rjd| dg}|                     d|  d           |d |                                D             z  }d                    d                    |          |           S | S )Nzhref=""zalt="c                 $    g | ]\  }}| d | dS )z="r0  r9   r  s      r?   rc   zE_get_jinja2_environment.<locals>._filter_add_href.<locals>.<listcomp>  s(    DDDTQqLLALLLDDDrA   z<a {}>{}</a>r  )r  r  formatr   )textlinkkwargskwargs_lists       r?   _filter_add_hrefz1_get_jinja2_environment.<locals>._filter_add_href  s     	+D+++,Kt///DDV\\^^DDDDK!((+)>)>EEEKrA   conda_build	templates)loaderr+   r+  add_hrefT)r   r   r+   filterstrim_blockslstrip_blocks)r.  r7  environments      r?   _get_jinja2_environmentr@    s    & & &   ]K88  K *5K&&6K
#&6K
#"K $KrA   c                    |  dt                       }|st          |          }t          |d          5 }|                    |           |r|                    d           d d d            n# 1 swxY w Y   t	          |           r@t          j        |          t          j        |           k    rt          j        |           dS t          j	        ||            dS )N.wb   
FT)
r   r   r   writer   r!   md5_filerv   unlinkmove_with_fallback)rw   contentwrite_newline_endcontent_is_binary	temp_pathfhs         r?   _maybe_writerN  *  s    ##%''##I )((	i		 "
 	HHUOOO               d|| >)$$t(<(<<<Ii   5	Y---4s   -A..A25A2c                     t          |          }|                     |          r-| d t          |                    } |                     d          } | }|S )N_)strr  r   rstrip)buildbuild_numberbuild_number_as_stringbuild_strings       r?   _make_build_stringrW  ?  s]     ..~~,-- "4344445S!!LrA   c                    | rddg}t          |           D ]}|                    d|z             t          | |                   D ]k}|                    d|z             |                    d          \  }}|d                             |d          }|r|d                             |           l|                    d	           |                    d
           t                              d                    |                     dS dS )aI  
    The following dependencies do not exist in the channel and are not declared
    as external dependencies:

    dependency1:
        - subdir/fn1.tar.bz2
        - subdir/fn2.tar.bz2
    dependency2:
        - subdir/fn3.tar.bz2
        - subdir/fn4.tar.bz2

    The associated packages are being removed from the index.
    z?WARNING: The following dependencies do not exist in the channelz2    and are not declared as external dependencies:z  %sz    - %srq   rs   Nr	  z9The associated packages are being removed from the index.rV   r   )sortedr  r   r   r   r   r   )missing_dependenciespatched_repodatabuilderdep_name	subdir_fnr   r  r   s           r?   _warn_on_missing_dependenciesr_  H  s)     %M@
 344 	; 	;HNN6H,---#$8$BCC ; ;	zI5666&__S11
)*599"dCC ;$Y/66r:::; 	RSSSr7##$$$$$!% %rA   c                 >   dddddddd}t           j                            |           r4t          |           5 }t	          j        |                              dg           }d d d            n# 1 swxY w Y   |D ]}|                    d          r=|                    d          dk    rd|d<   n|                    d          d	k    rd|d
<   dD ]:}|                    |          s#|d                             d|z            rd||<   ;dD ]N}|                    |          s7t          j        |d         d|z            rd||	                    dd          <   Ot          |d          5 }t	          j
        ||           d d d            d S # 1 swxY w Y   d S )NFr   r   r   r   r   r   r   pathsprefix_placeholder	file_modebinaryTr   r3  r   )r   r   _pathzetc/conda/%s)zpre-linkz	post-linkz
pre-unlinkz	*/.*-%s.*r   rP  w)rv   rw   lexistsr   r   r   r   
startswithfnmatchr  dump)paths_cache_pathpost_install_cache_pathpost_install_details_jsonr   rb  r  patrM  s           r?   _cache_post_install_detailsrp  j  sw   ! ! 
w'(( L"## 	2qIaLL$$Wb11E	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2  	L 	LAuu)** D55%%11AE-o>>UU;''611?C-m<3 8 8044Q77 8AgJ<Q<Q"Q&= = 8 48-a0> L L044S99 LgogJc 1? ? L HL-ckk#s.C.CD	L 
%s	+	+ 1r	+R0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s#   )A//A36A3/FFFc                    d}|D ]E}t           j                            | |          }t           j                            |          r nd }Fi }|r`t	          |          5 }	 t          j        |          }n## t          t          t          t          f$ r Y nw xY wd d d            n# 1 swxY w Y   	 t          j        |          }nM# t          $ r@ |                    di                               d           t          j        |          }Y nw xY wt	          |d          5 }|                    |           d d d            n# 1 swxY w Y   |S )N)zinfo/recipe/meta.yaml.renderedzinfo/recipe/meta.yamlzinfo/meta.yamlrequirementsrS  rg  )rv   rw   r   rh  r   yaml	safe_loadr   r   r   r   r   dumps	TypeErrorr   r   rE  )	tmpdirrecipe_cache_pathrecipe_path_search_orderrw   recipe_pathrecipe_jsonr   recipe_json_strrM  s	            r?   _cache_reciper}    s    
 )  gll64007??;'' 	EK + 	!"nQ//$k<M   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
2*[11 2 2 2++//888*[112 
	%	% "
!!!" " " " " " " " " " " " " " "s[   B$ A54B$5BB$BB$$B(+B(0C ADD"EEEc                    i }	 t          t          j                            | dd                    5 }t	          j        |          }d d d            n# 1 swxY w Y   n# t          t          f$ r 	 t          t          j                            | dd                    5 }t          j	        |          }d d d            n# 1 swxY w Y   n4# t          t          f$ r  t                              d| z             Y nw xY wY nw xY wt          |d          5 }t	          j        ||           d d d            d S # 1 swxY w Y   d S )Nr   zrun_exports.jsonzrun_exports.yamlz'%s has no run_exports file (this is OK)rg  )r   rv   rw   r   r   r   r   r1   rs  rt  r   r   rk  )rw  run_exports_cache_pathr   r   rM  s        r?   _cache_run_exportsr    s   KJ"',,vv/ABBCC 	'q)A,,K	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'&' J J J	Jbgll663EFFGG 01"nQ//0 0 0 0 0 0 0 0 0 0 0 0 0 0 0*+ 	J 	J 	JII?&HIIIII	J	J 
$c	*	* #b	+r"""# # # # # # # # # # # # # # # # # #s   .A AA AA AA D1.CC 4C C	CC	CD.C=:D<C==DDD99D= D=c                    |                     di                                d          }|rt          j                            | dd|          }t          j                            |          s!t          j                            | dd          }t          j                            |          r1|t          |          d         z  }t          j        ||           d S d S d S )Nappiconr   recipezicon.png)r   rv   rw   r   rh  r   r!   rH  )rw  r{  icon_cache_pathapp_icon_path	icon_paths        r?   _cache_iconr    s      OOE2..226::M AGLL=II	wy)) 	AVVZ@@I7??9%% 	Ax66r::O$Y@@@@@A A	A 	ArA   c           	         t                      }|                    d          }|                    d                    | pd|          |t	          j                                        t          j        d                    |          }|S )Nzsubdir-index.html.j2z{}/{}rV   r$  r%  )titlers   current_timeextra_paths)	r@  get_templaterenderr2  r   utcnowr  r)  r*  )r   r   repodata_packagesr  r?  templaterendered_htmls          r?   _make_subdir_index_htmlr    s    )++K''(>??HOOnn\/R88"_&&..dmE6J6J.KK	 $  M rA   c           
         t                      }|                    d          }|                    | |d         |d         t          j                                        t          j        d                              }|S )Nzchanneldata-index.html.j2rs   r   r$  r%  )r  rs   r   r  )r@  r  r  r   r  r  r)  r*  )r   channeldatar?  r  r  s        r?   _make_channeldata_index_htmlr    sz    )++K''(CDDHOOZ(I&_&&..dmE6J6J.KK	 $  M rA   c                    t          j        g d|           }|                                                    d          dk    rt          j        g d|           }g }|                    d                                                                          D ]C}|                    d          \  }}}}|                    |t          |          ||d           D|S )N)gitz	rev-parsez--is-inside-work-tree)cwdutf-8true)r  r   z--pretty=format:'%h|%ad|%an|%s'z--date=unix|)hashr   authorr   )
subprocesscheck_outputr  decode
splitlinesr   r  r   )	rw   is_repooutputr   line_hash_time_author_descs	            r?   _get_source_repo_git_infor    s    %5554  G }}g&&&00(LLLRV
 
 
 MM'**0022==?? 		 		D+/::c??(E5'5NN!!$U%#(	     NrA   c                     t           j                            | d|          }t           j                            |          rt	          j        ||           d S d S )Nr   )rv   rw   r   rh  r!   rH  )rw  info_fn
cache_path	info_paths       r?   _cache_info_filer    sR    VVW55I	wy!! 8 J777778 8rA   c                     | }t           D ]}|                    |d          }t          t                     |                     |d          hz
  }|t          t	          |                    z   S )NrV   )r0   r  r   nextiter)r  cache_fnext	other_exts       r?   _alternate_file_extensionr     sj    H' - -##C,,,--Hb1I1I0JJId4	??++++rA   c                    i }i }|rt          |          5 }t          j        |          }t          j        |          }|                                D ]D\  }}	|                    t
                    r|	||<   %|                    t                    r|	||<   E	 d d d            n# 1 swxY w Y   |s| t          j        t          j	        d||d}t          d| z            }
t          |
          }|                    t          j        |                     d|_        |t          j        |
                    d          <   d |p|j        D             }t%          ||
f          }|S )N)r   archrj   )r   rs   r  z+https://conda.anaconda.org/dummy-channel/%sT)with_credentialsc                     i | ]}||S r9   r9   )r`   precs     r?   r  z'_get_resolve_object.<locals>.<dictcomp>%  s    AAADT4AAArA   )channels)r   r   r   r  r  r.   r/   r)   	arch_namerj   r   r   _process_raw_repodata_strru  _loaded_cache_ra   _package_recordsr&   )r   	file_pathprecsr  rs   conda_packagesfirecsr  r  rm   sdr   rH   s                 r?   _get_resolve_objectr    s   HN *)__ 	*y}}H9R==D

 * *1::899 *"#HQKKZZ :;; *()N1%	*	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*  	
 !)#, 
 !,
 
 CfLMMG	G		B  H!5!5666BJ=?Jw{{D{99:AAE$@R-@AAAE
+++AHs   BB%%B),B)c                    i }| j                                         D ]\  }}||v rzg }||         D ]n}|                     t          | d|                     d         j        }|                    |                     t          | d|                                on?| j         |         d         j        }|                     t          | d|                     }|||<   d |                                D             S )N=r   c                     g | ]	}|D ]}|
S r9   r9   r`   grouppkgs      r?   rc   z(_get_newest_versions.<locals>.<listcomp>6  s%    >>>E>>C>>>>rA   )groupsr  find_matchesr%   r   extendr   )rH   pinsr  g_nameg_recsmatchespinr   s           r?   _get_newest_versionsr  *  s   F(..** 	! 	!T>>GF| Q Q..f3D3Ds3D3D)E)EFFqIQq~~i68M8MG8M8M.N.NOOPPPPQ hv&q)1GnnY&/D/D7/D/D%E%EFFG v>>V]]__>>>>rA   c                    t          j        | j                  }t                      }| j                                        D ]\  }}|D ]}|j        D ]}||v rt          |          }|                     |          s|                    |          }	|	rw|	d         j        }
t          |	                    |j
        g                     t          |                    t          |j
         d|
                               z  ||j
        <   |                    |           όٌd |                                D             S )zZFor each package in new_r, if any deps are not satisfiable, backfill them from original_r.r   r  c                     g | ]	}|D ]}|
S r9   r9   r  s      r?   rc   z%_add_missing_deps.<locals>.<listcomp>N  %    GGGEGG#CGGGGrA   )copydeepcopyr  r   r  r   r%   r  r   r   r   r   r   )new_r
original_rexpanded_groups
seen_specsr  r  g_recdep_specmsr  r   s              r?   _add_missing_depsr  9  sa    mEL11OJ,,,.. ) ) 	) 	)E!M ) )z))x(())"-- (55b99G ")!*"436+//<<4 4&33I>T>T7>T>T4U4UVV 40
 x(((()	) HG_3355GGGGrA   c                    t          j        | j                  }| j        D ]}t          d | j        |         D                       s(t	          t          | j        |         d         j                            }||j        v rd }t          t          |j        |                             D ]L}|j        |         |         }t	          t          |j                            |k    r|j	        s|j
        s|} nM|*|ht          |                    |g                     z  ||<   d |                                D             S )Nc              3   2   K   | ]}|j         p|j        V  d S r8   )track_featuresfeatures)r`   ms     r?   	<genexpr>z-_add_prev_ver_for_features.<locals>.<genexpr>T  s,      PPa1#1qzPPPPPPrA   r   c                     g | ]	}|D ]}|
S r9   r9   r  s      r?   rc   z._add_prev_ver_for_features.<locals>.<listcomp>j  r  rA   )r  r  r  anyr(   rQ  r   ranger   r  r  r   r   r   )r  orig_rr  r  latest_versionkeep_mi_ms           r?   _add_prev_ver_for_featuresr  Q  sW   mEL11O,  PP5<;OPPPPP 	 &c%,v*>q*A*I&J&JKKV]"" F3v}V45566  ]6*1-BJ00NBB% C)+ C  FE!+1(S#''336 6 +' HG_3355GGGGrA   c                    i }|pi }|j                                         D ]\  }}|j         |         d         j        }t          |                    t          | d|                               }||v rw||         D ]n}|                    t          | d|                     d         j        }|                    |                    t          | d|                                o|||<   t          | d |                                D                       }	t          | t          |	|                    }	t          t          |	|                    S )aH  Captures only the newest versions of software in the resolve object.

    For things where more than one version is supported simultaneously (like Python),
    pass pins as a dictionary, with the key being the package name, and the value being
    a list of supported versions.  For example:

    {'python': ["2.7", "3.6"]}
    r   r  c                     g | ]	}|D ]}|
S r9   r9   r  s      r?   rc   z*_shard_newest_packages.<locals>.<listcomp>  s%    IIIu5IICsIIIIrA   )r  )r  r  r   r   r  r%   r   r  r   r  r  )
r   rH   r  r  r  r  r   r  	pin_valuer  s
             r?   _shard_newest_packagesr  m  so    F:2D(..** ! !(6"1%-annY&/D/D7/D/D%E%EFFGGT>>!&\ Q Q	..f3J3Jy3J3J)K)KLLQOWq~~i68M8MG8M8M.N.NOOPPPP v  IIIII  E  .?q.I.IJJJE )%33444rA   c                    t          |           }t          | ||          }fdt                                                    ddhz
  D             }i }i }|D ]}|j                            t                    r~d         |j                 ||j        <   |j                            t          t                    }	d         	                    |	i           	                    d          ||j                 d<   |j                            t                    rd         |j                 ||j        <   ||d<   ||d<   |S )N)r  c                 "    i | ]}||         S r9   r9   )r`   r  r  s     r?   r  z+_build_current_repodata.<locals>.<dictcomp>  s,       8A;  rA   rs   r  md5legacy_bz2_md5)
r  r  r   keysr  r  r/   r  r.   r   )
r   r  r  rH   	keep_pkgsnew_repodatars   r  keep_pkgcounterparts
    `        r?   _build_current_repodatar    se   FX666A&vq$77I    #HMMOO 4 4
DT7U U  L HN F F; :;; 	F*23C*DX[*QN8;' #+--*,F K $((b99==eDD 8;'(899 [!!"<== 	F$,Z$8$EHX[!'L%3L!"rA   c                       e Zd ZdeddfdZ	 	 	 	 	 ddZddZdefdZ	 	 dd	Z	e
dd
            Ze
d             Ze
d             Zd Zd Zd Zd Zd Zd ZddZd Zd ZddZdS )r   NFc                    t          |          | _        |p!t          |                    d                    | _        || _        |st          j        j        dk    s|dk    rt                      nt          |          | _        || _        d S )Nrq      r"   )r
   channel_rootr   rR  r   _subdirssysversion_infomajorr6   r   thread_executorr   )r:   r  r   r   r   r   r   s          r?   __init__zChannelIndex.__init__  s     $L11(NH\5H5H5M5M,N,N .(.!33w!|| OOO$W-- 	
 %9!!!rA   c                 	   |rt           j        }nt           j        }t          j        |t
          g          5  | j        s[d t          j        | j	                  D             }t                              d|z             t          |dhz            x| _        }	n,t          t          | j                  dhz            x| _        }	t          j        t          j        | j	                  gd          5  i }
t          j                            | j	        d          }t          j                            |          r;t)          |          5 }t+          j        |          }
d d d            n# 1 swxY w Y   t/          t1          |	          |p| d	          5 }|	D ]{}|                    d
|z             |                                 t/          d|p| d	          5 }|                    d           |                                 t7          | j	        |           |                     ||||          }|                    d           |                                 |                     ||t<                     |                    d           |                                 |                     |||          \  }}|                    d           |                                 |                     ||t@                     |                    d           |                                 tC          |||          }|                    d           |                                 |                     ||d           |                    d           |                                 | "                    ||           |                    d           |                                 | #                    |
||           d d d            n# 1 swxY w Y   }	 d d d            n# 1 swxY w Y   | $                    |
           | %                    |
           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr\   c                 j    h | ]0}|j         t          j        v |                                )|j         1S r9   )r   r!   r   is_dir)r`   r   s     r?   ro   z%ChannelIndex.index.<locals>.<setcomp>  sA     $ $ ${e&;;;; K;;;rA   zfound subdirs %sre   i  )r   rr   F)totaldisableleavez
Subdir: %s   zGathering repodata)rd   r   r   zWriting pre-patch repodatazApplying patch instructionszWriting patched repodataz Building current_repodata subset)r  zWriting current_repodata subsetzcurrent_repodata.json)json_filenamezWriting subdir index HTMLzUpdating channeldata)&r~   r   ERRORr!   r|   rB   r  rv   scandirr  r   r   rY  r   r   try_acquire_locksget_lockrw   r   r   r   r   r   r   r   set_descriptionr   r   index_subdir_write_repodataREPODATA_FROM_PKGS_JSON_FN_patch_repodataREPODATA_JSON_FNr  _write_subdir_index_html_update_channeldata_write_channeldata_index_html_write_channeldata)r:   r   r   rd   r   r   r   leveldetected_subdirsr   r   r   r   tr   t2repodata_from_packagesr[  patch_instructionscurrent_repodatas                       r?   r   zChannelIndex.index  s#     	"MEEME!%(<<< Z	6 Z	6= 	Q$ $"$*T->"?"?$ $ $ 
 		,/??@@@)/0@H:0M)N)NNww)/DM0B0BhZ0O)P)PPw ( 1223S   M6 M6  "#%7<<0ACU#V#V 7>>"233 4.// 41'+y||4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 g,,1HLQV   @") = =)),*?@@@


!"#g.EXe   :../CDDDIIKKK1$2CVLLL595F5F &(/)1+5	 6G 6 62 ../KLLLIIKKK 00 & 6 :   ../LMMMIIKKKCGCWCW &(>D D@,.@ ../IJJJIIKKK 00 &(8:J   ../QRRRIIKKK/F &(8?U0 0 0, ../PQQQIIKKK 00 & 0.E 1    ../JKKKIIKKK 99&BRSSS../EFFFIIKKK 44 ,.>  q: : : : : : : : : : : : : : :=@ @ @ @ @ @ @ @ @ @ @ @ @ @ @F 22<@@@''555[M6 M6 M6 M6 M6 M6 M6 M6 M6 M6 M6 M6 M6 M6 M6Z	6 Z	6 Z	6 Z	6 Z	6 Z	6 Z	6 Z	6 Z	6 Z	6 Z	6 Z	6 Z	6 Z	6 Z	6 Z	6 Z	6 Z	6s   B=Q?5AQ'E, Q',E00Q'3E04%Q'AP& H P P&PP&PP&Q'&P**Q'-P*.-Q'Q?'Q+	+Q?.Q+	/Q??RRc           	      
  #$ t          | j        |          }|                     |           t          |t                    }|rt                              d|z             d t          j        |          D             }	 t          |          5 }t          j
        |          pi }	d d d            n# 1 swxY w Y   n# t          t          f$ r i }	Y nw xY w|	                    di           }
|	                    di           }t          |
          t          |          z  }t          |dd          }	 t          |          5 }t          j
        |          pi }d d d            n# 1 swxY w Y   n	#  i }Y nxY w|                                }||z
  }t          |	                    dg                     }	 |rt          |          5 }t                      }|D ]r}|                                                    d          \  }}||k    r3|                    d	          s|                    d
          r|                    |           s	 d d d            n# 1 swxY w Y   n||z
  }||z  }|                     ||||||          }t          ||z
  |z
  |z
            $t+          $t                    sJ ||z
  }|D ]	}||v r||= 
$fd|	                    di                                           D             }$fd|	                    di                                           D             }t/          $          D ]p}||v sj||v sft0                              | j        |||          \  }}||k    r|                    |           K|                    t4                    r|||<   k|||<   qg ||R }t7          j        t0          j        | j        |          }t=          t>          d|p| d          D ]Ċ#t=          | j         !                    |#fd|D                       d|z  |p| d          D ]\  }}} }!|rz|rxtE          |          | d||<   |!r&|                    tF                    r|!||<   B|!||<   Ht          $                    dt          j%                             ||          z             ||d|itL          t/          tO          |                    d}"||k    r=t          |d          5 }t          j(        ||           d d d            n# 1 swxY w Y   nI# ||k    r>t          |d          5 }t          j(        ||           d d d            w # 1 swxY w Y   w w xY w|"S )NzBuilding repodata for %sc                 f    h | ].}|                     d           s|                     d          ,|/S ).conda.tar.bz2r  )r`   r  s     r?   ro   z,ChannelIndex.index_subdir.<locals>.<setcomp>0  sP     
 
 
{{8$$
 )+J(?(?

 
 
rA   rs   r  .cachez	stat.jsonr	  rq   r,  r-  )rd   r   c                 $    i | ]\  }}|v 	||S r9   r9   r`   r  r  unchanged_sets      r?   r  z-ChannelIndex.index_subdir.<locals>.<dictcomp>}  s4     % % %Aq%% 1%%%rA   c                 $    i | ]\  }}|v 	||S r9   r9   r1  s      r?   r  z-ChannelIndex.index_subdir.<locals>.<dictcomp>  s4     + + +Aq%% 1%%%rA   zFile formatFdescr  r  c              3   F   K   | ]}|                               |V  d S r8   r.  )r`   r  conda_formats     r?   r  z,ChannelIndex.index_subdir.<locals>.<genexpr>  s4      TT"++l:S:STTTTTTTrA   zhash & extract packages for %s)r   sizezPackage at %s did not contain valid index.json data.  Please check the file and remove/redownload if necessary to obtain a valid package.r   )rs   r  r   repodata_versionr	  rg  ))r   r  _ensure_dirsr  r   r   rv   listdirr   r   r   r   r2   r   r   r  r  r   r  r   _calculate_update_setr'  r  rY  r   _load_index_from_cacher.   	functoolsr   _extract_to_cacher   r0   r  r@   r   r/   errorrw   REPODATA_VERSIONrt   rk  )%r:   r   r   rd   r   subdir_pathrepodata_json_pathfns_in_subdirrM  old_repodataold_repodata_packagesold_repodata_conda_packagesold_repodata_fnsstat_cache_path
stat_cachestat_cache_original
remove_set
ignore_setfinadd_setr  	fn_subdirr  
update_setremoved_setnew_repodata_packagesnew_repodata_conda_packagesr  rn   hash_extract_setextract_funcr   r8  
index_jsonr  r7  r2  s%                                      @@r?   r  zChannelIndex.index_subdir&  s   4,f55&!!!!+/IJJ 	?HH/+=>>>
 
j--
 
 
	()) 3R#y}}23 3 3 3 3 3 3 3 3 3 3 3 3 3 3) 	 	 	LLL	 !- 0 0R @ @&2&6&67G&L&L#455<W8X8XX {HkBB	o&& 1"!Yr]]0b
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1	JJJ(oo//%5
)))R8899
z	.  
;*%% ,!eeG # , ,(,

(:(:3(?(?	2$..$;;x00 ,BKK
4K4K ,#KKOOO,, , , , , , , , , , , , , , , (*::z!G 33 ! 4  J   0: =
 JZ WXXMmS11111 +]:K! ' '##"2% % % %(,,Z<<BBDD% % %!
+ + + +(,,-=rBBHHJJ+ + +' M** B B222a;V6V6V*AA)62z GB
 Syy"r****;;'ABB B8;1"55>A7;  76:66$,.0A6 L
 !%(" 0L	! ! !   48(,,$TTTT&6TTT  :FB$4H4 4 4  /BtZ  e 36u::t)L)L
2% 
!{{+EFF GBL ;B ? ?<F 5b 9 9II!357W\\+r5R5R!S  %2 2"=f %5!$z"2"233 L 000/3// .2Ij"---. . . . . . . . . . . . . . . 000/3// .2Ij"---. . . . . . . . . . . . . . . . 1 s    B> B2&B> 2B66B> 9B6:B> >CC4E2 E&E2 &E**E2 -E*.E2 2E88T, 	BIT, IT, !I"JT, >T  T$'T$,U2U%U2%U))U2,U)-U2r   c                 B   t          | j        |d          }|                    dd           |dz                      d           |dz                      d           |dz                      d           |dz                      d           |d	z                      d           |d
z                      d           |dz                      d           |dz                      d           t          | j        d                              d           dS )ztCreate cache directories within a subdir.

        Args:
            subdir (str): name of the subdirectory
        r/  T)parentsexist_okr   )rZ  aboutrb  r  r   post_installr  
recipe_logiconsN)r   r  mkdir)r:   r   r  s      r?   r:  zChannelIndex._ensure_dirs  s;    $+VX>>
555	g	$$d$333	g	$$d$333	g	$$d$333	h	%%t%444	m	#**D*999	n	$++T+:::	f	##T#222	l	"))4)888T((...=====rA   Tc                    ||z  }t          | j        |          }t                      }	t          t	          |          d|p| d          D ]}
|
|vr|	                    |
           t          j        t          ||
                    }t          |j	                  t          ||
         d                   k    s|j
        ||
         d         k    r|	                    |
           |	S )NzFinding updated filesFr4  r   r8  )r   r  r   r   r  r   rv   statr   st_mtimest_size)r:   r   rD  rH  rJ  rd   r   candidate_fnsrB  rQ  r  stat_results               r?   r<  z"ChannelIndex._calculate_update_set  s     &(884,f55UU
(,H	
 
 
 	' 	'B ##r"""" gd;&;&;<<,--Z^G5L1M1MMM"*jnV.DDDNN2&&&rA   c                 
   t          | |          }t                    }t          j                             |          }t          j        |          }|j        }|j        }	|	|d f}
t          |dd|dz             }t          |dd|dz             }t          |dd|dz             }t          |dd|dz             }t          |dd|dz             }t          |dd|dz             }t          |dd	|          }t                              d
z             d}t          j        	                    |          s5t          j        	                    |
                                        rd}	                     t                    s\t          j                            |          r=t          |          5 }t          j        |          }d d d            n# 1 swxY w Y   n|s|s t          j        	                    |          sct#                      5 }t$          j                            ||d           t          j                             |dd          }t          j        	                    |          s|
cd d d            S t          |          5 }t          j        |          }d d d            n# 1 swxY w Y   t+          |d|           t+          |d|           t+          |d|           t-          ||           t/          ||           t1          ||          }t3          |||           d d d            n# 1 swxY w Y   h d}|t5          |          z  D ]}||= n|r|||||||g}fd|D             }t7          ||          D ]s\  }}t          j        	                    |          rO	 t          j        t          j                            |                     n#  Y nxY wt=          j        ||           tt          |          5 }t          j        |          }d d d            n# 1 swxY w Y   n;t          |          5 }t          j        |          }d d d            n# 1 swxY w Y   |                     t$          j        !                    |                     t          |d          5 }t          j"        ||           d d d            n# 1 swxY w Y   |	||f}
nE# tF          tH          tJ          tL          f$ r% |s tN          (                    | |d          cY S Y nw xY w|
S )Nr/  r   .jsonr[  rb  r  r   r\  r  z#hashing, extracting, and caching %sFTr   )dest_dir
componentsz
index.jsonz
about.jsonz
paths.jsonzrecipe_log.json>
   target-tripletucsr  r   binstarmachinerj   
has_prefixoperatingsystemrequires_featuresc                 <    g | ]}|                               S r9   )r  )r`   rP  alternate_cache_fnr  s     r?   rc   z2ChannelIndex._extract_to_cache.<locals>.<listcomp>h  s(     R R Rq2/A!B!B R R RrA   rg  )
second_try))r   r  rv   rw   ra  rc  rb  r   r   r   r  r  r/   r   r   r   r   r'   conda_package_handlingapiextractr  r  rp  r}  r  r   zipr   r   r!   	copy_intor   get_pkg_detailsrk  r   KeyErrorEOFErrorr2   r   r?  ) r  r   r  rs  rB  r  abs_fnre  r8  r   retvalindex_cache_pathabout_cache_pathrl  rx  r  rm  r  alternate_cacher   rW  rw  r   r{  filter_fieldsr  rb  bizarro_pathssrcdestrM  rr  s      `                            @r?   r?  zChannelIndex._extract_to_cache  s@   
 <00
 7r::k2..gfoo"$UD$&Xw7@RSSXw7@RSSXw7@RSS h(WBTUU!%=(W2D"
 "
 #'>8g3E#
 #
 {HfhGG		7"<===w~~.// 	#BGNN$$R);<<5
 5
 	# #OX	
 ;;9:: D.rw~~ @ @ D. *++ .q!%1J. . . . . . . . . . . . . . .$ ?.?."$'..1A"B"B?. ()) FV*.66F 7    "$ffl!K!KJ7>>*55 &%F F F F F F F F j)) 2Q%)Yq\\
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 %V\;KLLL$V\;KLLL$V->@PQQQ&v/EFFF/(*A   #08I"J"JK_EEE%F F F F F F F F F F F F F F F*! ! ! #0#j//"A / /J":../  . %$$%*+# !S R R R RE R R R!$]E!:!: 3 3ICw~~c** 3!K(=(=>>>>! DT222*++ .q!%1J. . . . . . . . . . . . . . . *++ .q!%1J. . . . . . . . . . . . . . . 48HHPPQQQ&,, *	*b)))* * * * * * * * * * * * * * *j0FF#XxI 	 	 	 #55 &" 6      	
 s  0AS9 8GS9 GS9  G!8S9 A$M=S9 
MJ:.M:J>	>MJ>	A7M9S9 M		S9 M	A/S9 =1O/.S9 /O31*S9 P<0S9 <Q  S9 Q S9 Q8,S9 8Q<<S9 ?Q< AS9 S'S9 'S++S9 .S+/	S9 9=T;:T;c                     t          | |dd|dz             }	 t          |          5 }t          j        |          }d d d            n# 1 swxY w Y   n# t          t
          f$ r |}Y nw xY w||fS )Nr/  r   rg  )r   r   r   r   r   r2   )r  r   r  rJ  r~  rM  rW  s          r?   r=  z#ChannelIndex._load_index_from_cache  s    fhgVV	&'' +2!Yr]]
+ + + + + + + + + + + + + + +) 	 	 	JJJ	 :~s3   A AA AA AA A*)A*c                 0   t          | |          }	 t          t          ||                    }n# t          $ r i cY S w xY wt          |dd|dz             }t          |dd|dz             }t          |dd|dz             }t          |dd|dz             }t          |dd|dz             }	t          |dd|d	z             }
t          |dd
|dz             }i }||||	|fD ]}	 t          j                            |          dk    rNt          |          5 }|                    t          j	        |                     d d d            n# 1 swxY w Y   u# t          t          f$ r Y w xY w	 t          |
          }|rt          |          d         }|                    dd          d         }d                    |d         |          }d|z   }t          | d|          }t!          j        |          }d| dt          |           }|                    ||           t!          j        ||           n#  Y nxY w||d<   |                    di           }	 |                    d |                                D                        n# t*          $ r Y nw xY wt-          |d           t-          |d           	 t          |          5 }t          j	        |          |d<   d d d            n# 1 swxY w Y   n# t          t          f$ r i |d<   Y nw xY w|S )Nr/  r   rg  r[  r  r   r\  r  z.*r]  r   r  rB  r"   z{}.{}r   zicons/r^  zmd5::)r   r   r   sourcec                      i | ]\  }}d |z   |S )source_r9   r  s      r?   r  z5ChannelIndex._load_all_from_cache.<locals>.<dictcomp>  s"    EEEdaQEEErA   r   r   )r   r   r1   rv   rw   r   r   r   r   r   r   r{  r4   rY  rsplitr2  r!   rF  rH  r   r  r  r  )r  r   r  rB  r   r~  r  rx  r  rm  icon_cache_path_globrecipe_log_pathdatarw   rM  icon_cache_pathsr  icon_extchannel_icon_fnr   icon_channel_pathicon_md5r   r  s                           r?   _load_all_from_cachez!ChannelIndex._load_all_from_cache  s   <00	T+r2233EE  	 	 	III	  XwWMMXwWMM h"w,OO!%="w,"
 "
 #'>2<#
 #
  $K629MM{HlBLQQ#
 	 	D7??4((A--d 3rDIbMM2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3X&   	#$899 
M"()9":":2">*11#q99"=")..fx"H"H#o5$(w$P$P! >/::H8HHgo.F.FHH	i(CCC(:KLLL	D W(B''	KKEEfllnnEEEFFFF 	 	 	D	 	T=111T9---	%,-- 4&*imm]#4 4 4 4 4 4 4 4 4 4 4 4 4 4 4" 	% 	% 	%"$D	%s   0 ??!2E(E;EE	EE	EE'&E'+C	H5 5H91J
 

JJ;K: 
K."K: .K22K: 5K26K: :LLc                 ,   t          | j        ||          }t          j        |dd                              dd                              d          }t          ||d          }|r+|dz   }t          j        |          }t          ||d	           |S )
Nr  Tindent	sort_keys':'': 'r  )rJ  .bz2)rK  )	r   r  r   ru  r  encoderN  bz2compress)	r:   r   r  r  rC  new_repodata_binarywrite_resultrepodata_bz2_pathbz2_contents	            r?   r  zChannelIndex._write_repodata  s    !$"3V]KKJ  
 WUF##VG__ 	 $ 3t
 
 
  	Q 2V ;,':;;K*K4PPPPrA   c                 
    |d         }t           j        |          } fd}t                      } ||t          |t                                ||t          |t          dz                         ||t          |t                                ||t          |t          dz                         ||t          |d                     t           j        |||          }t          |d          }t          ||          S )Nrs   c                    t          t          j        |                    rdt          |          t	          t          |                    t          j        |          t          j        |          d| t          |          <   d S d S )N)r8  r   sha256r  )
r   r   r  r   r   r   r!   sha256_checksumrF  r   )r  rw   r:   s     r?   _add_extra_pathz>ChannelIndex._write_subdir_index_html.<locals>._add_extra_path  s|    d4,d3344 #DMM!$Xd^^!4!4#3D99 >$//	/ /HTNN+++ rA   r  patch_instructions.json
index.html)r   r  r   r  r  r  r   rN  )	r:   r   r  r  rB  r  r  r  
index_paths	   `        r?   r  z%ChannelIndex._write_subdir_index_html  s%   $Z04,f55	 	 	 	 	 "mmT+7G%H%HIIIT+7G&7P%Q%QRRRT+7Q%R%RSSSk+E+NOO	
 	
 	
 	T+7P%Q%QRRR/v'8+
 
 +|44
J666rA   c                 z    t          | j        |          }t          | j        d          }t	          ||           d S )Nr  )r  r   r   r  rN  )r:   r  r  r  s       r?   r!  z*ChannelIndex._write_channeldata_index_html  s<    4T5FTT$+\::
Z/////rA   c                    |d         |d         }t                                                    d |                                D             z
  }|                                }|                    fd|D                        |                    di           fd}g }t          |                                d           D ]T\  }	}
|	vs|	                             d          r$t          |
d           D ]\  }} |||           H |||
           Ud	 }g g }}|rt          | \  }}t          j	        t          j        | j                  }t          || j                            ||                    D ]\  }}|r|                    |           |d
         }	                    |	i           }|                    dd          }|                    dd          }t          |          t          |          k    }                    |	i           |	<   dD ]} ||	         ||||           dD ]B}t!          |                    |          |                    |          f          |	         |<   Ct#          t%          t          |                    dg           gz                                 |	         d<   |                    di           }|                    d          }|r|                    d          ||<   ||	         d<   t'          t)          |                    dd          |                    |	i                               dd                              |	         d<   |                    t*          t#          t%          t          |                    dg           gz                                 d           d S )Nrs   r  c                 2    h | ]}|d d         t           z   S )Ni)r.   )r`   r  s     r?   ro   z3ChannelIndex._update_channeldata.<locals>.<setcomp>  s3     ?
 ?
 ?
45AcrcF//?
 ?
 ?
rA   c                 "    i | ]}||         S r9   r9   )r`   r  legacy_packagess     r?   r  z4ChannelIndex._update_channeldata.<locals>.<dictcomp>  s     RRRqQ 2RRRrA   c                    t          |d           d         }|d         }|d         }                    |i                               di           }|vs                    |i                               dg           vs[                    |i                               dd	          t          |                    dd	                    k     s|r!|d
         |vr|                     |           d S d S d S )Nc                 :    | d                              dd          S )Nr"   r   r   r   xs    r?   <lambda>zIChannelIndex._update_channeldata.<locals>._append_group.<locals>.<lambda>  s    1+q9Q9Q rA   )r  r  r"   r   r   r   r   r   r   )rY  r   r   r  )r  
candidates	candidatepkg_dictpkg_namer   package_datar   s         r?   _append_groupz7ChannelIndex._update_channeldata.<locals>._append_group  s   z/Q/QRRRSUVI |H'H&**8R88<<]BOOK,,!1!1(B!?!?!C!CIr!R!RRR##Hb1155k1EE[! < <==> >> Y'{::i(((((> > ;:rA   c                     | d         d         S )Nr"   r   r9   r  s    r?   r  z2ChannelIndex._update_channeldata.<locals>.<lambda>)  s    1Q4< rA   r   c                     | d         d         S )Nr"   r   r9   r  s    r?   r  z2ChannelIndex._update_channeldata.<locals>.<lambda>.  s    !A$y/ rA   c                     |                     |          r$|s|                     |          s||         | |<   d S |                     |          | |<   d S r8   r  )pdr  erec
data_newerr  s        r?   _replace_if_newer_and_presentzGChannelIndex._update_channeldata.<locals>._replace_if_newer_and_present4  sT    xx{{ $
 $$((1++ $Q11rA   r   r   0)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ra  r   r   r   )channeldata_versionr   rs   )r   r  r  r   r   r   r  rw  r>  r   r   r  r  r  r@   r(   r  rY  rt   r   maxCHANNELDATA_VERSION)r:   r   r  r   r  use_these_legacy_keysall_packagesr  r  r   r  rP  vgroupr  fnsfn_dicts	load_funcfn_dictr  r  data_verec_vr  r  r   exports_from_this_versionr  r  s      `                      @@r?   r   z ChannelIndex._update_channeldata  ss   ":.!"23 #O$8$8$:$: ; ; ?
 ?
9G9L9L9N9N?
 ?
 ?
 !
 &**,,RRRR<QRRRSSS#''
B77	) 	) 	) 	) 	) 	)  "<#5#5#7#79O9OPP 		- 		-KD%<''<+=+A+A-+P+P' ")0I0I!J!J 2 2IAv!M&&11112 fe,,,,	$ 	$ 	$ BX 	)LMC%-
 
	
 !4+?+C+CIs+S+STT <	 <	MGT ;G$$$F|#''b11)S11)S11)&11L4H4HH
%1%5%5dB%?%?T"  A$ 21$T*D$
A   
 	L 	LA -0!dhhqkk0J,K,KL&q))06TXXi44x?@@AA1 1T"9- #hh}b99,0HH],C,C), B*.((=*A*AK'4?T"=12?a00$((r2266{AFF 3 3T";/ 	':!\--i<<xGHHII  ) 	
 	
 	
 	
 	
rA   c                    |                     di                                           D ]\  }}d|v r|d= t          | j        d          }t	          j        |dd                              dd          }t          ||d           d S )	Nrs   r   rr   r  Tr  r  r  )r   r  r   r  r   ru  r  rN  )r:   r  _pkgr  channeldata_pathrI  s         r?   r"  zChannelIndex._write_channeldata  s    )ooj"==CCEE 	( 	(ND(H$$Y' 13EFF*[dCCCKK6
 
 	%w55555rA   c                    i }t                      5 }t          j                            ||           t          j                            ||d          }t          j                            |          r;t          |          5 }t          j
        |          }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |S )N)rh  r  )r'   rt  ru  rv  rv   rw   r   r   r   r   r   )r:   r   r   r  rw  instructions_filer   s          r?    _load_patch_instructions_tarballz-ChannelIndex._load_patch_instructions_tarball  s'   !! 	0V"&...PPP "VV=V W Ww~~/00 0+,, 0#'9Q<<L0 0 0 0 0 0 0 0 0 0 0 0 0 0 0		0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 s6   A1B:B#B:#B'	'B:*B'	+B::B>B>c                 &   |pt          | j        d          }t          |          rt                              d| d|            	 ddlm}m}  |d|          } ||          }|j        	                    |           n*# t          $ r dd l}	|	                    d|          }Y nw xY w|                    ||          }
|
                    dd          dk    rt          d	          |
S |r"t!          d
                    |                    i S )Nzgen_patch.pyzusing patch generator z for r   )module_from_specspec_from_file_locationa_bpatch_instructions_versionr"   'Incompatible patch instructions versionzSpecified metadata patch file '{}' does not exist.  Please try an absolute path, or examine your relative path carefully with respect to your cwd.)r   r  r   r   r   importlib.utilr  r  r:  exec_moduleImportErrorimpload_sourcer  r   RuntimeError
ValueErrorr2  )r:   r   r  r   gen_patch_pathr  r  r   modr  r  s              r?   _create_patch_instructionsz'ChannelIndex._create_patch_instructions  sc   (SD1BN,S,S.!! 	IIL~LLFLLMMM=TTTTTTTT..unEE&&t,,'',,,, = = =


ooe^<<=
 ..x@@L <a@@1DD"#LMMM  ^^d^d'_ _   Is   9B $B)(B)c                     t          j        |dd                              dd          }t          | j        |d          }t          ||d           d S )Nr  Tr  r  r  r  )r   ru  r  r   r  rN  )r:   r   r  	new_patchpatch_instructions_paths        r?   _write_patch_instructionsz&ChannelIndex._write_patch_instructions  se    J|AFFFNN6
 
	 #'v'@#
 #
 	,i>>>>>rA   c                 V   t          | j        |d          }t          |          rt                              d|z             t          |          5 }t          j        |          }|                    dd          dk    rt          d          |cd d d            S # 1 swxY w Y   i S )Nr  zusing patch instructions %sr  r   r"   r  )
r   r  r   r   r   r   r   r   r   r  )r:   r   r  rM  r  s        r?   _load_instructionszChannelIndex._load_instructions  s    "&v'@#
 #
 )** 	$II36MMNNN-.. $"#y}}##$@!DDqHH&'PQQQ#	$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
 	s   ?BB"%B"c                 x   r7t          fdt          D                       r|                     |          }n|                     ||          }|r|                     ||           n|                     |          }|                    dd          dk    rt          d          t          |||          |fS )Nc              3   B   K   | ]}                     |          V  d S r8   r.  )r`   r  r   s     r?   r  z/ChannelIndex._patch_repodata.<locals>.<genexpr>  sB       #
 #
.1O$$S))#
 #
 #
 #
 #
 #
rA   r  r   r"   r  )	r  r0   r  r  r  r  r   r  r!  )r:   r   r  r   r  s      ` r?   r  zChannelIndex._patch_repodata  s     		s #
 #
 #
 #
5M#
 #
 #
  
  
 		  @@ LL  ::/ L  	;**6<@@@@226::L8!<<q@@HIII"68\BBLPPrA   )NFFNN)NFF)FT)Fr8   )rB   rC   rD   MAX_THREADS_DEFAULTr  r   r  rQ  r:  r<  staticmethodr?  r=  r  r  r  r!  r   r"  r  r  r  r  r  r9   rA   r?   r   r     s       
 #"9 9 9 9,  #h6 h6 h6 h6Ti i i iV>3 > > > >2    @ @ @ @ \@D   \ C C \CJ  (7 7 780 0 0
}
 }
 }
~	6 	6 	6  ! ! ! !F? ? ?  Q Q Q Q Q QrA   r   )NFFNFTNN)
FNNr"   FFNTNF)FF)NNNr8   )r  r  rj  r>  r   r~   rv   r  r  r   collectionsr   concurrent.futuresr   r   r   r   	itertoolsr   numbersr	   os.pathr
   r   r   r   r   r   r   r   pathlibr   uuidr   conda_package_handling.apirt  r)  rs  conda.common.compatr   conda.core.subdir_datar   conda.models.channelr   conda_index.indexr   r   r   jinja2r   r   r   yaml.constructorr   yaml.parserr   yaml.readerr   yaml.scannerr   r8  r    r!   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   deprecationsr-   r.   r/   r0   r1   r2   r3   r4   rB   r   r6   conda.base.constantsrE   rF   r  	frozensetr   
NAMESPACESrz   r   rx   ry   r{   r   hasattrrW   r  rj   minLOCK_TIMEOUT_SECSLOCKFILE_NAMEr   r   r   r   r   rA  r  r  r  CHANNELDATA_FIELDSr  r!  r@  rN  rW  r_  rp  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r9   rA   r?   <module>r     s   


         				     



  # # # # # # < < < < < < < <                        	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	             ! ! ! !   . - - - - - . - - - - - ( ( ( ( ( ( ; ; ; ; ; ; : : : : : : - - - - - - - -       - - - - - - # # # # # # # # # # # # % % % % % % . . . . . . . .                        % $ $ $ $ $                  j" " " " "H " " "4LLLLLLLLL 4 4 4(S 	# 	C	
 	 	( 	 	6 	 	 	u 	$ 	 	u 	  	4!" 	W#N& (i770>02233JJJ+4.    wr;//NLBLNNQ4F4FLBLNNNQ  LG#b"566  
P= P= P= P=f   	
$ $ $ $T Hg(EFFF 	
8 8 8 GF8vN N N4     " :  BR R R- - -`  :   *  % % %D#1 #1 #1L  :# # #A A A 	 	 		 	 	  ,8 8 8, , ,   D "$ ? ? ? ?H H H0H H H85 5 5 5@  6DQ DQ DQ DQ DQ DQ DQ DQ DQ DQs   D AE:9E: