
    8xd[t                        d 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ZddlmZmZ ddlmZmZmZmZmZ dd	lmZ ej        j         d
ej        j         ddderdndd e edd                    g ddgg dddZ edd          e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)Z ej        d*d+          d,         Zddd-d.d/d0Z  e	d1          d2             Z!d3 Z"d4 Z#d5 Z$d6 Z%	 dKd8Z&dLd9Z'd: Z(d; Z)dLd<Z*dMd=Z+dNd>Z,d? Z- e	d1          d@             Z.dA Z/e/Z0dB Z1dMdCZ2dD Z3dMdEZ4dOdGZ5 e	d1          dOdH            Z6dI Z7dJ Z8dS )PziThis file handles the parsing of feature specifications from files,
ending up with a configuration matrix    N)OrderedDictcopy)	lru_cache)product)cc_conda_buildsubdir)ensure_list
get_loggerisliston_wintrim_empty_keys)_parse.z1.22z5.26.253.43.5noconazx.x)min_pinmax_pin)pythonr   numpy)pin_run_as_buildignore_versionignore_build_only_depsextend_keyszhttps://cran.r-project.org)r   r   perlluar_basecpu_optimization_targetr   r   r   r   cran_mirrorr   zr-basevs2008vs2010vs2017)2.7z3.3r   r   91014gfortran)ccxxvcfortrangccgxx)r*   r+   r-   clangclangxx)winlinuxosx-   r   r   r   )PYNPYLUAPERLR)maxsizec                    t           |                                          }| dk    rgt          |          t          d          k    rd}n"t          |          t          d          k    rd}|d         |         |d<   |d         |         |d<   d |                                D             }| dk    rt           |          d         |         |d<   |S )	Nr2   r   z3.2r%   r*   r+   c                 ,    i | ]\  }}|d k    |dz   |S )r,   	_compiler ).0langpkg_names      4lib/python3.11/site-packages/conda_build/variants.py
<dictcomp>z*_get_default_compilers.<locals>.<dictcomp>h   s4       D(4<< 	{H<<    r,   )DEFAULT_COMPILERSr   parse_versionitems)platformpy_ver	compilerss      rE   _get_default_compilersrN   ^   s    !(+0022I5  M%$8$888FF6""mE&:&:::F"3/	#$U+F3	% 'oo//  I 5+H5d;FC	$rG   c                    t                                           }| j        |d<   t          | d          r| j                            d          s|d         n| j        d         }|                    t          | j        |                     |S )Ntarget_platformvariantr   )	DEFAULT_VARIANTSr   r	   hasattrrQ   getupdaterN   rK   )configbaser   s      rE   get_default_variantrX   s   s      ""D$mD	 	**	&28.2D2DX2N2N	&X^H% 
 	KK&v??@@@KrG   c                 &   ddl m}m} t          |           5 }|                                }d d d            n# 1 swxY w Y    || ||          d          }t          j        |t
          j        j                  pi }t          |           |S )Nr   )get_selectorsselect_linesF)variants_in_place)Loader)
conda_build.metadatarZ   r[   openreadyamlloadloader
BaseLoaderr   )pathrV   rZ   r[   fcontentscontents          rE   parse_config_fileri      s    @@@@@@@@	d q6688              |HmmF&;&;uUUUHi)?@@@FBGGNs   9= =c                 l   g }|                     d D                        	 t                    }|                     fd|D                        t                      |                     fd|D                        |                     fd|D                        n9# t          $ r,}|                    t          |                     Y d }~nd }~ww xY wt          t          d |                    }|r6t          d                    | d	                    |                              d S )Nc              3   *   K   | ]}d |v d| dV  dS )r5   z  z& key contains an invalid character '-'NrA   )rB   ks     rE   	<genexpr>z validate_spec.<locals>.<genexpr>   s;        ;<q6Q666 rG   c              3   <   K   | ]}|D ]}|vd | d| dV  dS )z  zip_key entry z
 in group z does not have any settingsNrA   )rB   zgrl   specs      rE   rm   z validate_spec.<locals>.<genexpr>   s_       
 

 
 }}	 LqKKBKKK }}}}
 
rG   c              3      K   | ]8}|D ]3}|v rd                      ||          n                    |          V  49dS )zO  zip_key entry {} in group {} is a duplicate, keys can only occur in one groupN)formatadd)rB   ro   rl   uniques      rE   rm   z validate_spec.<locals>.<genexpr>   sw       
 

 
 
  F{{!6!R=== &

1	
 
 
 
 
 
 
rG   c              3   j   K   | ]-}t          fd |D             dhz
            dk    %d| dV  .dS )c                 `    h | ]*}|v r"t          t          |                             nd +S N)lenr
   rB   rl   rp   s     rE   	<setcomp>z*validate_spec.<locals>.<genexpr>.<setcomp>   s:    NNNaa4ii[a))***TNNNrG   Nr6   z  zip fields in zip_key group z are not all the same length)rx   rB   ro   rp   s     rE   rm   z validate_spec.<locals>.<genexpr>   s       	
 	
 NNNN2NNNRVQWW   	 NRMMM   	
 	
rG   z&Variant configuration errors in {}:
{}
)
extend_get_zip_keysset
ValueErrorappendstrlistfilterrr   join)srcrp   errorszip_keysert   s    `   @rE   validate_specr      s   F MM  @D     
#
 &&
 	 
 
 
 

 
 
 	
 	
 	
  
 
 
 

 
 
 
 	
 	
 	
 	 	
 	
 	
 	
	
 	
 	
 		
 		
 		
 		
1    c!ffH &v&&''F 
5<<S$))FBSBSTT
 
 	

 
s   B& &
C0"CCc                 0   d fdt          |j                  D             }|s|j        st          j        d          r t          d                   }n) t
          j                            dd                    }t
          j                            |          r|	                    |            d          }t
          j                            |          r|	                    |           t          | d|           } t
          j                            |d                    }t
          j                            |          r|	                    |           |                    fdt          |j                  D                        |S )a  
    Find config files to load. Config files are stacked in the following order:
        1. exclusive config files (see config.exclusive_config_files)
        2. user config files
           (see context.conda_build["config_file"] or ~/conda_build_config.yaml)
        3. cwd config files (see ./conda_build_config.yaml)
        4. recipe config files (see ${RECIPE_DIR}/conda_build_config.yaml)
        5. additional config files (see config.variant_config_files)

    .. note::
        Order determines clobbering with later files clobbering earlier ones.

    :param metadata_or_path: the metadata or path within which to find recipe config files
    :type metadata_or_path:
    :param config: config object specifying config file settings
                   (see exclusive_config_files, ignore_system_variants, and variant_config_files)
    :type config: :class:`Config`
    :return: List of config files
    :rtype: `list` of paths (`str`)
    c                     t           j                            t           j                            t           j                            |                               S rw   )osre   abspath
expanduser
expandvars)ps    rE   <lambda>z#find_config_files.<locals>.<lambda>   s4    (:(:27;M;Ma;P;P(Q(QRR rG   c                 &    g | ]} |          S rA   rA   rB   rf   resolves     rE   
<listcomp>z%find_config_files.<locals>.<listcomp>   s!    LLLAWWQZZLLLrG   config_file~zconda_build_config.yamlre   c                 &    g | ]} |          S rA   rA   r   s     rE   r   z%find_config_files.<locals>.<listcomp>   s!    OOO''!**OOOrG   )r
   exclusive_config_filesignore_system_variantsr   rT   r   re   r   isfiler   getattrr}   variant_config_files)metadata_or_pathrV   filescfgre   r   s        @rE   find_config_filesr      s   * SRG MLLLV-J!K!KLLLE 6 m,, 	H'.788CC'"',,s,EFFGGC7>># 	LLg/007>># 	LL#V-=>>D
'"',,t%>??
@
@C	w~~c S	LLOOOOk&2M&N&NOOOPPPLrG   Tc                    i t          |          }t          |          }|                                 D ]\  }r|r,t          t                    }|                    d|                                            D ]\  }|r|v r|v rt          |d          rNv r2t                   d          r                             |           W|                                <   ot                              g                     <            	                    t          |                     t          t                                       <   dk    rd |D             }t          |d         t                    st          |d         t                    s|g}                    g           <            	                    |           t          d d          D             D                       <   t          |d          r|                                <   g}	|r|D ]
}
|
v r|
}	 nt          fd|	D                       r|	D ]}t          t          |                             t          t          |                    k    r`t!          d	                    ||t          t          |                    t          t          |                                                 t          |                   |<   v r|	D ]}|v rBt          t          |                             t          t          |                    k    r n^|v rBt          t          |                             t          t          |                    k    r n|                                <   fd
t          |          D             }fd|	D             }t          |          r-t!          d                    |||                             S )NzAdding in variants from keysr   c                     g | ]}||S rA   rA   )rB   subvals     rE   r   z._combine_spec_dictionaries.<locals>.<listcomp>  s    >>>v>V>>>rG   r   c              3   4   K   | ]}t          |          V  d S rw   )r   )rB   	set_groups     rE   rm   z-_combine_spec_dictionaries.<locals>.<genexpr>  s<       ) ) ) !OO) ) ) ) ) )rG   c                 ,    h | ]}t          |          S rA   )tuple)rB   groups     rE   rz   z-_combine_spec_dictionaries.<locals>.<setcomp>  s    -R-R-RueEll-R-R-RrG   c              3       K   | ]}|v V  	d S rw   rA   rB   
group_itemrp   s     rE   rm   z-_combine_spec_dictionaries.<locals>.<genexpr>'  s(      "V"V*:#5"V"V"V"V"V"VrG   znAll entries associated by a zip_key field must be the same length.  In {}, {} and {} are different ({} and {})c                 (    g | ]}|         v|S rA   rA   )rB   subvaluerl   valuess     rE   r   z._combine_spec_dictionaries.<locals>.<listcomp>D  s2     5" 5" 5"(0'/vay'@'@ %-'@'@'@rG   c                     g | ]}|v|	S rA   rA   r   s     rE   r   z._combine_spec_dictionaries.<locals>.<listcomp>I  s.     7" 7" 7"(2'1'='= %/'='='=rG   zvariant config in {} is ambiguous because it
does not fully implement all zipped keys (To be clear: missing {})
or specifies a subspace that is not fully implemented (To be clear:
.. we did not find {} from {} in {}:{}).)r
   rJ   r   __name__inforS   rU   r   rT   r}   r   r   
isinstancer   allrx   r   rr   )specsr   filter_keysr   
log_outputr   spec_sourcelogvkeys_in_groupr   r   missing_subvaluesmissing_group_itemsrl   rp   r   s                 @@@rE   _combine_spec_dictionariesr      s   
 F{##Dk**K"[[]] a& a&T `	& C **AKAABBB

 \& \&1 [&qDyyK''"1f-- 	= F{{wvay&/I/I{ &q	 0 0 3 3 3 3,-FFHHq		(3FJJq"4E4E(F(FF1I"1I,,[^^<<<(,S^^(<(<F1IIj>>!>>>)!A$55 $j1u>U>U $!"A$*JJq"$5$5q	q	((+++$( ) )-R-Rq	-R-R-R) ) ) % %q		
 #1f-- B&()F1II ./CM' .-5 !. !.E'(Ezz8=(- (2  #"V"V"V"V"V"V"VVV 4&2? !W !WJ'*;tJ7G+H+H'I'IS(3AN& N& (& (& /9-DDJF0;010:03KNN0C0C03KZ@P4Q4Q0R0RE. E.
/* 
/* 
)* :ET*EU9V9VF:$6$6!W  "#f2? 
!9 
!9J'1T'9'9c(3D4D(E(E?& ?&),[^^)<)<?= ?= ).'1V';';(3F:4F(G(GA& A&),[^^)<)<A= A= ).01F1I5" 5" 5" 5" 5"4?NN5" 5" 5" 1
7" 7" 7" 7"6C7" 7" 7" 3
 $''8#9#9 !&*4)S TZSY,7,?,=,0,-,21IT* T*	+& +& %& MrG   c                    t           d         dd         }|                    d |                                 D                        t          | |dg|                              dg           }t          | |||          }|S )a  With arbitrary sets of sources, combine into a single aggregate spec.

    Later specs in the input set have priority and overwrite duplicate entries.

    specs: list of dictionaries.  Keys are arbitrary, but correspond to variable
           names used in Jinja2 templated recipes.  Values can be either single
           values (strings or integers), or collections (lists, tuples, sets).
    r   Nc                 `    g | ]+}|t          |                    d                     D ]}|,S )r   )r
   rT   )rB   rp   keys      rE   r   z!combine_specs.<locals>.<listcomp>k  s]     	
 	
 	
	
 #488M#:#:;;		
 	
  	
 	
 	
 	
rG   r   )r   r   r   )r   r   r   )rR   r}   r   r   rT   )r   r   r   r   r   s        rE   combine_specsr   `  s     #=1!!!4K	
 	
	
 	
 	
   *;ZLZ  	c*b  (;j  F MrG   c                 2   d t                                           D             }i }|                                D ]\\  }}|| v rSt          | |                   }|dk    r0d                    |                    d          dd                   }||d|z   <   ]|S )zGiven args passed into conda command, set language env vars to be made available.

    Search terms: CONDA_PY, CONDA_R, CONDA_PERL, CONDA_LUA, CONDA_NPY
    c                     i | ]\  }}||	S rA   rA   rB   rl   r   s      rE   rF   z)set_language_env_vars.<locals>.<dictcomp>  s    777DAq1a777rG   r8    r   N   CONDA_)
SUFFIX_MAPrJ   r   r   split)rQ   inverse_mapenvvariant_nameenv_var_namevalues         rE   set_language_env_varsr     s    
 87J$4$4$6$6777K
C&1&7&7&9&9 1 1"l7""-..Et##C 0 0! 455+0C<'(JrG   c                     |                      d          }|st                      S t          |d           rt          |          hS t          |d           rd |D             S t	          d          )a+  
    Extracts 'zip_keys' from `spec` and standardizes value into a list of zip_groups
    (tuples of keys (string)).

    :param spec: Variants specification
    :type spec: dict
    :return: Standardized 'zip_keys' value
    :rtype: set
    :raise ValueError: 'zip_keys' cannot be standardized
    r   c                 ,    t          | t                    S rw   r   r   r   s    rE   r   z_get_zip_keys.<locals>.<lambda>  s    Jq#,>,> rG   uniformc                 &    t          | d           S )Nc                 ,    t          | t                    S rw   r   r   s    rE   r   z1_get_zip_keys.<locals>.<lambda>.<locals>.<lambda>  s    
1c@R@R rG   r   )r   r   s    rE   r   z_get_zip_keys.<locals>.<lambda>  s    F16R6R$S$S$S rG   c                 ,    h | ]}t          |          S rA   )	frozenset)rB   ro   s     rE   rz   z _get_zip_keys.<locals>.<setcomp>  s    111"	"111rG   z;'zip_keys' expect list of string or list of lists of string)rT   r   r   r   r   )rp   r   s     rE   r~   r~     s     xx
##H 2uu	">">	?	?	? 2(##$$	SS
 
 
 2 211111
R
S
SSrG   c                     ddh}|r |                     t          d                    |                    t          |                     d                              S )a  
    Extracts 'extend_keys' from `spec`.

    :param spec: Variants specification
    :type spec: dict
    :param include_defaults: Whether to include default 'extend_keys'
    :type include_defaults: bool, optional
    :return: Standardized 'extend_keys' value
    :rtype: set
    r   r   )rU   rR   unionr
   rT   )rp   include_defaultsr   s      rE   _get_extend_keysr     sX     }-K <+M:;;;[-)@)@AABBBrG   c                     |t          |           }|t          |           }h d} |                    |          j        |                     |           S )a  
    Keys in `spec` that are not exploded and are simply carried over from the `spec`
    into the variants without modification.

    :param spec: Variants specification
    :type spec: dict
    :param zip_keys: Keys defined as 'zip_keys' (see :func:`_get_zip_keys`)
    :type zip_keys: set, optional
    :param extend_keys: Keys defined as 'extend_keys' (see :func:`_get_extend_keys`)
    :type extend_keys: set, optional
    :return: Passthru (not exploded) keys defined in `spec`
    :rtype: set
    N>   r   r   replacements)r~   r   r   
differenceintersection)rp   r   r   passthru_keyss       rE   _get_passthru_keysr     sa      &&&t,,???M6={++6ANNtTTTrG   c                 l    |t          | ||          }t          |                               |          S )a  
    Keys in `spec` that are that are exploding into the variants.

    :param spec: Variants specification
    :type spec: dict
    :param passthru_keys: Passthru (not exploded) keys (see :func:`_get_passthru_keys`)
    :type passthru_keys: set, optional
    :param zip_keys: Keys defined as 'zip_keys' (see :func:`_get_zip_keys`) and is passed
                     to :func:`_get_passthru_keys` if `passthru_keys` is undefined
    :type zip_keys: set, optional
    :param extend_keys: Keys defined as 'extend_keys' (see :func:`_get_extend_keys`) and
                        is passed to :func:`_get_passthru_keys` if `passthru_keys` is
                        undefined
    :type extend_keys: set, optional
    :return: Exploded keys defined in `spec`
    :rtype: set
    )r   r   r   )rp   r   r   r   s       rE   _get_explode_keysr     s5    $ *4;GGt99...rG   c                 d   g }t          |d          r| }n| D ]}|                    |          -|                    |          |v r|                    |           Dt          t                    }|                    d                    ||||                    |                               |S )zvariants is the exploded out list of dicts, with one value per key in each dict.
    key and values come from subsequent variants before they are exploded out.r   NzrFiltering variant with key {key} not matching target value(s) ({tgt_vals}) from {source_name}, actual {actual_val})r   tgt_valssource_name
actual_val)rS   rT   r   r   r   debugrr   )variantsr   r   r   reduced_variantsrQ   r   s          rE   filter_by_key_valuer     s     vv #   	 	G{{3+C0@0@F0J0J ''0000 **		KKQ6!'$/#*;;s#3#3	 LR L L    rG   c                 ,    |                      |          S rw   )r   )stringchars     rE   
_split_strr     s    <<rG   c                     t                     }t           |          } fd|D             }t           |          } fd |j        | D             }|                     fd|D                        t          |           g }t          |                                 D ]b}d |                                D             }|                    d t          ||          D                        |
                    |           c|S )a  
    Helper function to explode spec into all of the variants.

    .. code-block:: pycon
        >>> spec = {
        ...     # normal expansions
        ...     "foo": [2.7, 3.7, 3.8],
        ...     # zip_keys are the values that need to be exploded as a set
        ...     "zip_keys": [["bar", "baz"], ["qux", "quux", "quuz"]],
        ...     "bar": [1, 2, 3],
        ...     "baz": [2, 4, 6],
        ...     "qux": [4, 5],
        ...     "quux": [8, 10],
        ...     "quuz": [12, 15],
        ...     # extend_keys are those values which we do not explode
        ...     "extend_keys": ["corge"],
        ...     "corge": 42,
        ... }

        >>> explode_variants(spec)
        [{
            "foo": 2.7,
            "bar": 1, "baz": 2,
            "qux": 4, "quux": 8, "quuz": 12,
            "corge": 42,
            "zip_keys": ..., "extend_keys": ...,
        },
        {
            "foo": 2.7,
            "bar": 1, "baz": 2,
            "qux": 5, "quux": 10, "quuz": 15,
            "corge": 42,
            ...,
        }, ...]

    :param spec: Specification to explode
    :type spec: `dict`
    :return: Exploded specification
    :rtype: `list` of `dict`
    c                 J    i | ]}|         s|         d k    ||          S )r   rA   ry   s     rE   rF   z$explode_variants.<locals>.<dictcomp>1  s1    NNNqT!WNQ247rG   c                 R    i | ]#}|fd  t          |                   D             $S )c                 0    g | ]}t          |d           S )F)include_dictr
   )rB   r   s     rE   r   z/explode_variants.<locals>.<dictcomp>.<listcomp>6  s%    PPPa{15111PPPrG   r   ry   s     rE   rF   z$explode_variants.<locals>.<dictcomp>5  sH        
PP;tAw;O;OPPP  rG   c           	      V    i | ]%}|t          t          fd |D                        &S )c              3   B   K   | ]}t          |                   V  d S rw   r   ry   s     rE   rm   z.explode_variants.<locals>.<dictcomp>.<genexpr>:  s/      99DG,,999999rG   )r   zipr{   s     rE   rF   z$explode_variants.<locals>.<dictcomp>:  s=    OOOT#9999b999:;;OOOrG   c                 4    i | ]\  }}|t          |          S rA   r   r   s      rE   rF   z$explode_variants.<locals>.<dictcomp>C  s$    ;;;$!Q1d1gg;;;rG   c                 F    i | ]\  }}t          ||          D ]\  }}||	S rA   )r   )rB   ro   zvrl   r   s        rE   rF   z$explode_variants.<locals>.<dictcomp>E  s7    MMMfb"RMMAQMMMMrG   )r~   r   r   r   rU   r   r   r   rJ   r   r   )	rp   r   r   passthruexplode_keysexploder   r   rQ   s	   `        rE   explode_variantsr    sN   R T""H 'tX66MNNNNMNNNH %T=99L   (((3  G NNOOOOhOOO   G
 H7>>++, ! !;;(..*:*:;;;MMGV 4 4MMM	
 	
 	
 	    OrG   c                    | sdS t                      t                      }d}d| d         v r| d         d         r| d         d         ng }|rt          | d         d         d         t                    s't          | d         d         d         t                    r| d         d         }n| d         d         g}|D ]}|D ]}|                    |           | D ]*}|                                D ]\  }}|dk    rt          |d          r=                    |t                                }	|		                    |           |	|<   Zt          |t                    rCt                              |t                                          t          |          z  |<   t                              |g                     t          |          z   |<   ||vr%t          t          |                             |<   ,|r[|D ]X}t          t          t          t          fd|D                                   }
t          |          D ]\  }}|
|         |<   Y|d<   S )zOpposite of dict_of_lists_to_list_of_dicts function.

    Take broken out collection of variants, and squish it into a dict, where each value is a list.
    Only squishes string/int values; does "update" for dict keys
    Nr   r   r   c              3   (   K   | ]}|         V  d S rw   rA   )rB   r   squisheds     rE   rm   z1list_of_dicts_to_dict_of_lists.<locals>.<genexpr>z  s'      (H(H3#(H(H(H(H(H(HrG   )r   r   r   r   r   rs   rJ   rS   rT   rU   r
   r   	enumerate)list_of_dictsall_zip_keysgroupszip_key_groupsr   itemrQ   rl   r   existing_valuer   idxr   r  s                @rE   list_of_dicts_to_dict_of_listsr  O  s     }}H55LF q)))mA.>z.J) 	a$$ 
  	'mA&z215t<< 	4
!Z(+UA
 A
 	4 #1%j1FF#A&z23F 	' 	'E ' '  &&&&'  9 9MMOO 	9 	9DAqJq&!! 	9!)a!?!?%%a(((,At$$ 9!(,,q#%%"8"899CFFB"8<<2#6#677+a..HL(("&s8A;'7'7"8"8HQK	9  , 	, 	,E#s3(H(H(H(H%(H(H(H#IJJKLLF%e,, , ,S &s,)HZOrG   c                    t          | d          r| j        }|sddlm}  |            }t	          | |          }t          t          |                    }|D ]}t          ||          ||<   t          |d          r|j        r
|j        |d<   |r||d<   |	                                D ]\  }}t          ||           t          ||j                  }||fS )	NrV   r   )Config)internal_defaultsrQ   zconfig.variantargument_variants)r   )rS   rV   conda_build.configr  r   r   rX   ri   rQ   rJ   r   r   verbose)	recipedir_or_metadatarV   r   r  r   r   rf   rp   combined_specs	            rE   get_package_combined_specr    s    $h// .&- ------3V<<E*=f*E*EFFFE 0 0$Q//a vy!! 1fn 1"(. .%-!";;==  4a "%FNCCCM%rG   c                 $   t          |           }|                                }|d= t          |           } t          |                                          D ]8\  }}|                                D ]\  }}||vrt          | |||          p| } 9| S )Nr  )r   )r   r   r  reversedrJ   r   )r  r   r   sourcesource_specsrl   vss          rE   !filter_combined_spec_to_used_keysr    s    "=11K JJLLE!" %]33M ( 7 7 	 	!'')) 	 	EAr##
 (q"&QQQ %$ 	 rG   c                 N    t          | ||          \  }}t          ||          S )N)rV   r   )r   )r  r  )r  rV   r   r  r   s        rE   get_package_variantsr!    s7    4fx  M5 -]%HHHHrG   Fc           	           h d                     t          t           d                             d                                          fd d         D             }|S )z|For purposes of naming/identifying, provide a way of identifying which variables contribute
    to the matrix dimensionality>   r   r   r   r   r   c                 j    g | ].vr$t          fd dd         D                       ,/S )c              3   H   K   | ]}|         d                   k    V  dS )r   NrA   )rB   rQ   rl   r   s     rE   rm   z&get_vars.<locals>.<listcomp>.<genexpr>  s4      LLG71:!Q/LLLLLLrG   r6   N)any)rB   rl   	loop_onlyspecial_keysr   s    @rE   r   zget_vars.<locals>.<listcomp>  si       L   ! LLLLLx|LLLLL ! 	
   rG   )rU   r   r
   rT   )r   r&  	loop_varsr'  s   `` @rE   get_varsr)    s     FEELK(F(FGGHHIII     !  I rG   c           	      T   t                      }|                                }| D ]~g t          j        d          }|rS|sQ|                    d          dt          j                  z  }                    |           fd|D             }nfd|D             }|st          j                  }d                    t          t          j        	                    d                              }	d|z  }
d	|z  }d
|z   dz   }d|	z  }|r
                    d|           n                    |
||g           d                              t          fd|D                       r2|                               dv rd| v r|                    d           |S )Nz(.*?)_compiler(_version)?$r6   z&\{\s*compiler\([\'\"]%s[\"\'][^\{]*?\}c                 $    g | ]}|v s|v 
|S rA   rA   )rB   linecompiler_langr   s     rE   r   z/find_used_variables_in_text.<locals>.<listcomp>  s2       dmt>S>S>S>S>SrG   c                 D    g | ]}|                     d d          v |S )r5   _)replace)rB   r,  r   s     rE   r   z/find_used_variables_in_text.<locals>.<listcomp>  s8       dll36L6L1L1L1L1L1LrG   z[-_]r/  z-\{\s*(?:pin_[a-z]+\(\s*?['\"])?%s[^'\"]*?\}\}z/^[^#\[]*?\#?\s\[[^\]]*?(?<![_\w\d])%s[=\s<>!\]]z(?:^|[^\{])\{%\s*(?:el)?if\s*.*z\s*(?:[^%]*?)?%\}z^\s+\-\s+%s\s*(?:\s[\[#]|$)r   |c              3   B   K   | ]}t          j        |          V  d S rw   )research)rB   r,  all_ress     rE   rm   z.find_used_variables_in_text.<locals>.<genexpr>  s/      BBDry$''BBBBBBrG   )
c_compilercxx_compilerCONDA_BUILD_SYSROOT)r   
splitlinesr3  matchr   escaper   r   mapr   insertr}   r%  rs   )rQ   recipe_textselectors_onlyused_variablesrecipe_linescompiler_matchcompiler_regexvariant_linesv_regexv_req_regexvariant_regexselector_regexconditional_regexrequirement_regexr5  r-  r   s                 @@@rE   find_used_variables_in_textrK    s   UUN))++L %> %>"?CC 	. 	*0033MFJ J N NN>***    !-  MM   !-  M  	)A,,kk#bi">">??H7RKgU.8;OO 	 ;[H 	RNN1n----NNM+<>OPQQQ))G$$BBBBMBBBBB 	>q!!!222(G33"&&'<===rG   c                 2   t          |          5 }|                                }d d d            n# 1 swxY w Y   t                      }| D ]J}d|z  }t          j        ||t          j        t          j        z            r|                    |           K|S )Nz(^[^$]*?\$\{?\s*%s\s*[\s|\}])flagsr_   r`   r   r3  r4  	MULTILINEDOTALLrs   rQ   	file_pathrf   textr@  r   rG  s          rE   #find_used_variables_in_shell_scriptrU    s    	i Avvxx              UUN " "81<9]Dry0HIII 	"q!!!   155c                 8   t          |          5 }|                                }d d d            n# 1 swxY w Y   t                      }| D ]M}d|z   dz   }t          j        ||t          j        t          j        z            r|                    |           N|S )Nz\%rM  rO  rR  s          rE   #find_used_variables_in_batch_scriptrX    s    	i Avvxx              UUN " "	E)9]Dry0HIII 	"q!!!rV  )NNNT)T)NN)NNN)F)9__doc__os.pathr   r3  syscollectionsr   r   	functoolsr   	itertoolsr   ra   conda_build.conda_interfacer   r	   conda_build.utilsr
   r   r   r   r   conda_build.versionr   rI   version_infomajorminorrR   rH   rsplit	arch_namer   rN   rX   ri   r   r   r   r   r   r~   r   r   r   r   r   r  dict_of_lists_to_list_of_dictsr  r  r  r!  r)  rK  rU  rX  rA   rG   rE   <module>rh     sN  ) )  				 



 # # # # # #                    > > > > > > > > V V V V V V V V V V V V V V 7 7 7 7 7 7 !'BB#*:*@BB (ee5'#;;ue+T+T+TUUU'1   0%  , 2=52 2 2 # $X . 	
 
 	
 
 	
 
 ' ,    7    D FM#q!!"%	 	 
 4  (	 	 	  3
 3
 3
l. . .d JNl l l l^   >  "T T T0C C C C"U U U U,/ / / /.  2 4  D D DP "2 / / /d       @  ,I I I I   " 4) ) ) )X      rG   