
@K7]c           @` s  d  Z  d d l m Z m Z m Z d d l m Z m Z d d l Z d d l	 Z	 d d l
 Z
 d d l Z d d l m Z m Z m Z m Z m 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 Z y d d l m  Z  Wn* e! k
 rXd d l m" Z" e" f Z  n Xd d l# Z$ d	 d
 l% m& Z& 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- d	 d l% m. Z. d	 d l% m/ Z/ m0 Z0 d	 d l% m1 Z1 d	 d l% m2 Z2 d	 d l% m3 Z3 d	 d l% m4 Z4 d	 d l% m5 Z5 d	 d l% m6 Z6 d	 d l% m7 Z7 d	 d l% m8 Z8 d	 d l% m9 Z9 d	 d l% m: Z: d	 d l% m; Z; d	 d l% m< Z< d	 d l= m> Z> m? Z? m@ Z@ d d lA mB ZB d d  lA mC ZC mD ZD mE ZE m= Z= d d! lF mG ZG mH ZH d d" lI mJ ZJ mK ZK mL ZL mM ZM mN ZN mO ZO mP ZP mQ ZQ mR ZR d d lS jT jU ZU d d# lV mW ZW mX ZX mY ZY d d$ lZ m[ Z[ m\ Z\ m] Z] m^ Z^ d d% l_ m` Z` ma Za mb Zb d d& lc md Zd me Ze mf Zf d d' lg mh Zh d d li jj Zj d d lk mB Zl d d lA mB Zm e jn d( k rCd d lo jp Zp n  d) e jn k r[d* Zq n e= jr rmd+ Zq n d, Zq d-   Zs d.   Zt d/   Zu d0   Zv d1   Zw d2   Zx ey d3  Zz d4   Z{ d5   Z| d6   Z} d7   Z~ d8   Z d9   Z d:   Z d;   Z d<   Z d=   Z d>   Z d?   Z d@   Z dA   Z dB   Z dC   Z dD   Z dE   Z dF   Z dG   Z dH   Z dI   Z dJ   Z dK   Z dL   Z dM   Z dN   Z dO   Z dP   Z i e dQ 6e dR 6Z dS   Z dT   Z dU   Z ey e e ey e e dV  Z dW   Z dX   Z dY   Z dZ   Z d[   Z d\   Z d]   Z d^   Z d_ d`  Z e e da  Z db   Z dc   Z e e e e e ey dd  Z de   Z df   Z dg   Z ey dh  Z e di  Z d S(j   sM   
Module that does most of the heavy lifting for the ``conda build`` command.
i    (   t   absolute_importt   divisiont   print_function(   t   dequet   OrderedDictN(   t   isdirt   isfilet   islinkt   joint   dirname(   t   UnicodeDammit(   t   CONDA_TARBALL_EXTENSIONS(   t   CONDA_TARBALL_EXTENSIONi   (   t   env_path_backup_var_existst   conda_45t   conda_46(   t   PY3(   t   prefix_placeholder(   t   TemporaryDirectory(   t   VersionOrder(   t	   text_type(   t   CrossPlatformStLink(   t   PathTypet   FileMode(   t   EntityEncoder(   t   get_rc_urls(   t   url_path(   t   root_dir(   t   conda_private(   t	   MatchSpec(   t   reset_context(   t   context(   t   UnsatisfiableError(   t   NoPackagesFoundError(   t
   CondaError(   t	   pkgs_dirs(   t   env_vart   globt	   tmp_chdir(   t   __version__(   t   environt   sourcet   tarcheckt   utils(   t   get_build_indext   update_index(	   t   output_yamlt   bldpkg_patht   render_recipet   reparset   distribute_variantst   expand_outputst   try_downloadt   execute_download_actionst   add_upstream_pins(   t   FIELDSt   MetaDatat   default_structs(   t   post_processt
   post_buildt   fix_permissionst   get_build_metadata(   t   indentt   DependencyNeedsBuildingErrort   CondaBuildException(   t   set_language_env_varst   dict_of_lists_to_list_of_dictst   get_package_variants(   t   create_all_test_filest   win32t   bsds   /bin/sht   bashs	   /bin/bashc         C` s   |  j    } d j g  | D]0 } | d k r | d t |  j j |  ^ q  } |  j j j d  } | r | |  j j k r d | k r | d | 7} n  |  j   |  j   g } | r | j	 |  n  d j |  } | | } | S(   Nt   -t   target_platformt   _s   -target_(
   t   get_used_loop_varsR   t   strt   configt   variantt   gett   subdirt   namet   versiont   append(   t   metadatat   desct   used_loop_varst   kt
   build_varst   tpt   key(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt	   stats_key\   s    3$
c         C` sC   t  |  d  \ } } t  t |  d  \ } } d j | | |  S(   Ni<   s   {:d}:{:02d}:{:04.1f}(   t   divmodt   intt   format(   t   secst   mt   st   h(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   seconds_to_textn   s    c         C` s  t  d j |   t  d j |  j d d    |  j d  r~ t  d j t |  j d d   t |  j d d     n
 t  d	  |  j d
  r t  d j t j |  j d
 d     n
 t  d  t  d j t j |  d    t  d j t |  d    d  S(   Ns#   
Resource usage statistics from {}:s      Process count: {}t	   processesi   t   cpu_syss      CPU time: Sys={}, User={}i    t   cpu_users      CPU time: unavailablet   rsss      Memory: {}s      Memory: unavailables      Disk usage: {}t   disks      Time elapsed: {}
t   elapsed(   t   printR^   RO   Rc   R+   t   bytes2human(   t
   stats_dictt
   descriptor(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt	   log_statst   s    
+
 c   	      C` sn  t  j r d n d } xRd D]J} d |  j   k } | } | r |  j j d i   j | d  ru |  j d | } q |  j   d	 | } n  | | 7} d
 |  j   d	 | | } t |  j |  } t |  r t |  j	 j
 |  j	 j j d  r d n d  } t |  st j | d  n  t | |  } t  j | | |  j	 j d |  j	 j t j | d  q q Wd S(   s0   
    Create scripts to run after build step
    s   .bats   .shs   pre-links	   post-links
   pre-unlinks   package:t   buildt    RH   t   .s   win-t   Scriptst   bini  t   lockingN(   s   pre-links	   post-links
   pre-unlink(   R+   t   on_wint   get_recipe_textt   metaRO   RQ   R   t   pathR   RM   t   host_prefixt   host_subdirt
   startswithR   t   ost   makedirst	   copy_intot   timeoutRt   t   chmod(	   R`   t   extRY   t	   is_outputt
   scriptnamet   dst_namet   srct   dst_dirt   dst(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   create_post_scripts   s&    !
$%c      	   c` s  | j  t j  } t j  t j  } i | | 6} t j r | j d d  } | j  t j  } | | | <| j d d  } | j  t j  } | | | <n  | | t <t g  | j   D] \ }	 }
 t |	  ^ q  } g  } t |  d } t	 j
 d  } | rx | j   D] \ } }
 yY | d d d d	 d
 | | g } t j |  } | j | j d  j d d  j    Wqt j k
 rqqXqWg  | D] } | | ^ q} n
 t d  x\|  D]T} t j j |  r| | } n  | r| | k rqn  | j d  rqn  t | |  } t |  s3qn  t j d k rTt |  rTqn  t j |  j | k  rrqn  y t | d  } Wn4 t k
 rt j t   } | j! d |  qn Xy+ t j" | j#   d d d d t j% } Wn t& k
 r| j'   } n X| j( d  d k r"d n d } | d k rt j r| j( |  d k r| } | j)   | j)   t* | | | |  t | d  } t j" | j#   d d d d t j% } qn  x@ | j   D]2 \ } } | j( |  d k r| | | f VqqW| j)   | j)   qWd S(   s	  
    Yields files that contain the current prefix in them, and modifies them
    to replace the prefix with a placeholder.

    :param files: Filenames to check for instances of prefix
    :type files: list of tuples containing strings (prefix, mode, filename)
    s   \t   /s   \\i   t   rgs   --no-headings   --with-filenames   --files-with-matchess   --fixed-stringss   --texts   utf-8s   
s   
sr   WARNING: Detecting which files contain PREFIX is slow, installing ripgrep makes it faster. 'conda install ripgrep's   .pycs   .pyot   darwins   rb+s5   failed to open %s for detecting prefix.  Skipping it.i    t   tagnamet   flagss    it   binaryt   textN(   s   .pycs   .pyo(+   t   encodeR+   t   codecR   Ru   t   replacet   mint   itemst   lent   externalt   find_executablet
   subprocesst   check_outputt   extendt   decodet
   splitlinest   CalledProcessErrorRj   R|   Rx   t   isabst   endswithR   R   t   syst   platformR   t   statt   st_sizet   opent   IOErrort
   get_loggert   __name__t   warnt	   mmap_mmapt   filenot   Nonet   mmap_MAP_PRIVATEt   OSErrort   readt   findt   closet   rewrite_file_with_new_prefix(   t   filest   prefixt   prefix_bytest   prefix_placeholder_bytest   searchest   forward_slash_prefixt   forward_slash_prefix_bytest   double_backslash_prefixt   double_backslash_prefix_bytesRW   RJ   t
   min_prefixt
   rg_matchest
   prefix_lenR   t
   rep_prefixt   argst   matchest   rg_matcht   fRx   t   fit   logt   mmt   modet   datat   rep_prefix_bytes(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   have_prefix_files   s    		

1	, 
+!

-
c         C` sm   t  j |   } | j | |  } t |  d   } | j |  Wd  QXt  j |  t j | j  t j B | S(   Nt   wb(	   R|   R   R   R   t   writeR   t   S_IMODEt   st_modet   S_IWUSR(   Rx   R   t
   old_prefixt
   new_prefixt   stt   fo(    (    s0   lib/python2.7/site-packages/conda_build/build.pyR     s    #c      
   C` s   t  j |  d  } t g  | D] } | j |  t j d  ^ q  } | r\ t | |  } n1 g  | D]$ } | d k p~ | d k sc | ^ qc } t  j | |   } xH | D]@ } t  j t |  |  t | |  d | j	 d | j
 d t q Wd  S(   Nt   *Rp   s	   meta.yamls   conda_build_config.yamlR   Rt   t   clobber(   R+   t   rec_globt   sortedR   R|   t   sepR   t   filter_filesR~   R   Rt   t   True(   Rx   RM   t   dest_dirt   destination_subdirR   R   t
   file_paths(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   _copy_top_level_recipe  s    2!	c   	   
   C` s   t  |  j |  j | d  |  j |  j    p1 i  } | j d  } g  } | g | } g  | D] } | r] | ^ q] } t j | |  j  } xQ | D]I } t j t	 |  j |  t	 | |  d |  j j
 d |  j j d t q Wd  S(   Nt   parentt   scriptR   Rt   R   (   R   Rx   RM   t   get_rendered_outputRQ   RO   R+   R   R~   R   R   Rt   R   (	   R`   R   t   this_outputt   install_scriptt   build_inputst   inputsR   R   R   (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   _copy_output_recipe'  s    $c         C` s  |  j  j r|  j   rt |  j  j d  } y t j |  Wn n Xd } |  j rg t |  |  n t |  j	 |  j  |  |  j
 } |  j   } | j j d i   } | j   | d <| | j d <d | j k r | j d =n  d | j j d i   k r| j d d =n  t j | j d  t |  } | rat | d
   } t | j    j } Wd  QXn  | su| | k rFt t | d  d  n } | j d j t   | r| j d  | j d t j |  j	  d  n  | j d  | j |  Wd  QX| rFt j | t j	 j | d  d |  j  j d |  j  j d t qFn  t t j	 j | d  d   } t j  |  j  j! |  Wd  QXn  d  S(   Nt   recipeRp   Ro   t   stringt   outputst   parent_recipet   extras   build/scripts   test/commandst   rbs	   meta.yamlt   ws&   # This file created by conda-build {}
s&   # meta.yaml template originally from:
s   # s   
s4   # ------------------------------------------------

s   meta.yaml.templateR   Rt   R   s   conda_build_config.yaml(   s   build/scripts   test/commands("   RM   t   include_recipeR   t   info_dirR|   R}   R   R   R   Rx   t	   meta_patht   copyRw   RO   t   build_idR+   t   sort_list_in_nested_structureR.   R   R
   R   t   unicode_markupR   R^   R'   R)   t   get_repository_infoR~   R   Rt   R   t   yamlt   dumpRN   (   R`   t
   recipe_dirt   original_recipet   output_metadataRo   t   renderedR   t   original_recipe_text(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   copy_recipe7  sL    		$%!c         C` s   |  j  d  } | r t |  j j |  } t |  sJ t j d |  n  t |  j j |  } t j	 | | |  j j
 d |  j j t j j |  d d d d h k r t d d	 t j q n  d  S(
   Ns   about/readmes   Error: no readme file: %sRt   i   s	   README.mds
   README.rstt   READMEsN   WARNING: anaconda.org only recognizes about/readme as README.md and README.rstt   file(   t	   get_valueR   RM   t   work_dirR   R   t   exitR   R+   R~   R   Rt   R|   Rx   t   splitRj   t   stderr(   R`   t   readmeR   R   (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   copy_readmeo  s    %%	c         C` s3  t  j |  j d g    } | s% d  Sd } x | D] } | d k rJ q2 n  t |  j j |  } t j j |  s t j j |  j |  } n  t j j |  rt j j	 |  r d j
 |  } | d 7} n | } t  j | t |  j j d |  |  j j d |  j j q2 t d j
 |    q2 Wt d	  d  S(
   Ns   about/license_filei    Rp   s   LICENSE{}.txti   t   licensesRt   sv   License file given in about/license_file ({}) does not exist in source root dir or in recipe root dir (with meta.yaml)s   Packaged license file/s.(   R+   t   ensure_listR   R   RM   R   R|   Rx   R   R   R^   R~   R   R   Rt   t
   ValueErrorRj   (   R`   t   license_filest   countt   license_filet   src_filet   filename(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   copy_license|  s*    	!	c         C` s   |  j  d  p d } t j j |  j |  } t j j |  sW t |  j j |  } n  t j j |  r t j | t |  j j	 d  |  j j
 d |  j j n  d  S(   Ns   about/recipe_log_files   recipe_log.jsonRt   (   R   R|   Rx   R   R   RM   R   R+   R~   R   R   Rt   (   R`   t   log_fileR  (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   copy_recipe_log  s    	c         C` s  d } t  j |  j j  r* |  j j } n? t |  j d  ri |  j j ri t  j j |  j j d d  } n  | g } t  j j t  j j | d   r | j	 t  j j | d   n  x}| D]u} | r t  j j |  r | | k r xHt
 j |  j d g    D](} t
 j r)d | k r)t d   n  t t | |   } | sbd	 } t | j |    n  x | D] } y5 t
 j | | j | |  |  j j d
 t d t Wqit k
 r} t
 j t  }	 |	 j d j | t |    qiXqiWx8 d D]0 }
 x' t
 j | |
  D] } t  j |  qWqWq Wq q W|  j d  } | r|  j } x | D] } t t | |   } x | D] } | } t  j j |  st  j j | d  } n  | j | |  } | | k ryt
 j | | j | |  d |  j j d
 |  j j d t qyqyWqWWn  d  S(   NRp   R   t   infot   testR   s   test/source_filess   \sC   test/source_files paths must use / as the path delimiter on Windowss7   Did not find any source_files for test with pattern {0}Rt   R   s3   Failed to copy {0} into test files.  Error was: {1}s   .pycs   .pyos
   test/filesR   (   s   .pycs   .pyo(   R|   t   listdirRM   R   t   hasattrR   Rx   R   R   RS   R+   R  R   Ru   t   RuntimeErrorR%   R^   R~   R   R   t   FalseR   R   R   R   R   RL   t   get_ext_filest   removeR   Rt   (   R`   t   destinationt   src_dirt   src_dirst   patternR   t   msgR   t   eR   R   t   recipe_test_filest   orig_recipe_dirt   basedirt   dest(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   copy_test_source_files  sT    !	!$"$ 	c      	   C` sS   |  j    } t t j j |  j j d  d   } t j | | d d Wd  QXd  S(   Ns   hash_input.jsonR   R>   i   (	   t   get_hash_contentsR   R|   Rx   R   RM   R   t   jsonR   (   R`   t   recipe_inputR   (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   write_hash_input  s    'c         ` s   t  t | |   } |  j     t    t   d  sp   t k rg  j t j j	 t j
 j	 f  n  g    n  |  j d t  s  j t j
 j	 f  n    j    f d   | D  g  | D] } | d   k r | ^ q } | S(   Nt   __iter__s%   build/detect_binary_files_with_prefixc         3` s9   |  ]/ } | d   k r | d   k r | d Vq d S(   i   i   N(    (   t   .0R   (   t   ignore_filest   ignore_types(    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>  s    i   (   R   R   t   ignore_prefix_filest   setR  R   t   updateR   R   RQ   R   R   R   (   R`   R   R   t   files_with_prefixR   (    (   R*  R+  s0   lib/python2.7/site-packages/conda_build/build.pyt   get_files_with_prefix  s    	"	)c      
   C` s  |  j    } |  j   } | r<|  j r<t j r: d } n d } t t |  j j d  d   } x | D] \ } } } | | k r | d k r t	 d | | f  d } n  | j
 |  nE | | k r| d k r t	 d | | f  d } n  | j
 |  n  t	 d	 | | f  | j | | | | f  qh WWd  QXn  d
 }	 x | D] }
 |	 d |
 7}	 qIWx | D] }
 |	 d |
 7}	 qhW|	 rt |	   n  d  S(   Ns   "%s" %s "%s"
s	   %s %s %s
t
   has_prefixR   R   s0   Forcing %s to be treated as binary instead of %sR   s.   Forcing %s to be treated as text instead of %ss&   Detected hard-coded path in %s file %sRp   s;   Did not detect hard-coded path in %s from has_prefix_files
sB   Did not detect hard-coded path in %s from binary_has_prefix_files
(   t   binary_has_prefix_filest   has_prefix_filest   noarchR+   Ru   R   R   RM   R   Rj   R  R   R  (   R`   R/  R2  t   text_has_prefix_filest   fmt_strR   t   pfixR   t   fnt   errstrR   (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   record_prefix_files  s6    		!		'c         C` s   t  j d d |   S(   Ns   \/t\/[a-zA-Z0-9\-]*\/s   /t/<TOKEN>/(   t   ret   sub(   t   channel(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   sanitize_channel  s    c      	   C` s{  |  j  d  } t |  } t r5 i d d 6d d 6n
 i d d 6} t t |  j j d  |  } |  j d k rIx t |  D] } | j	 d	  d
 k r | j
 | | j	 d	  d  q | j d  r | | k r | j
 | j d d  d  q | j d  r1| | k r1| j
 | j d d  d  q | j
 | d  q Wn( x% t |  D] } | j
 | d  qVWWd  QXd  S(   Ns   build/entry_pointsR   R   s   utf-8t   encodingR   R   t   pythons   site-packagesi    s   
Rs   s   python-scriptsRr   (   R   t   get_entry_point_script_namesR   R   R   RM   R   R4  R   R   R   R{   R   (   R`   R   t   entry_point_scriptst   entry_point_script_namest	   mode_dictR   R   (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   write_info_files_file  s    '!!  c   	      C` sB  t    } |  j d  } | r} t  d t |   } t |  j   d k rp |  j d  } | rp | | d <qp n  | | d <n  |  j d  } | r t  d t |   } |  j d	  } | r | | d
 <n  | | d <n  | r>d | d <t t j j |  j j	 d  d  / } | j
 t j | d t d d d d  Wd  QXn  d  S(   Ns   build/noarcht   typeR@  s   build/entry_pointst   entry_pointsR4  s   build/preferred_envRQ   s$   build/preferred_env_executable_pathst   executable_pathst   preferred_envi   t   package_metadata_versions	   link.jsonR   t	   sort_keysR>   i   t
   separatorst   ,s   : (   RM  s   : (   R   R   R   t   lowerR   R|   Rx   R   RM   R   R   R%  t   dumpsR   (	   R`   t   package_metadatat   noarch_typet   noarch_dictRG  RI  t   preferred_env_dictRH  t   fh(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   write_link_json4  s(    	
'c   	      C` s  t  t |  j j d  d  e} i  } xg t d D][ } |  j d |  } | r^ | | | <n  t j d |  t k r2 t	 j
 |  | | <q2 q2 Wt | d <t | d <g  } x4 t   t |  j j  D] } | j t |   q W| | d <d g } d	   | D | d
 <y t | d <Wn t t f k
 r0n Xt j t  } | j   | d <|  j d  | d <t j | | d d d t Wd  QXd  S(   Ns
   about.jsonR   t   abouts   about/%st   conda_versiont   conda_build_versiont   channelst   CIO_TESTc         S` s%   i  |  ] } t  j | d   |  q S(   s	   <not set>(   R|   t   getenv(   R)  t   ev(    (    s0   lib/python2.7/site-packages/conda_build/build.pys
   <dictcomp>d  s   	 t   env_varsR   t	   root_pkgsR   R>   i   RK  (   R   R   RM   R   R7   R   R9   RO   t   listR+   R  RW  RX  R   t   channel_urlsRS   R>  R   t   KeyErrort   AttributeErrorR(   t   EnvironmentR   t   package_specst   get_sectionR%  R   R   (	   R`   R   t   dRZ   t   valuet   stripped_channelsR=  t   evarst   env(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   write_about_jsonO  s0    !

 
	c         C` sx  |  j    } |  j r
|  j d k rR |  j j d i   j d g   } | | d <n t j |  d  } t t |  j j	 d  d   } | j
 d |  j   |  j j f  xV t | d j |  j   j d	 d
   g  D]& } | j
 d d j | j     q WWd  QXn  t r$i d d 6d d 6n
 i d d 6} t t |  j j	 d  |  # } t j | | d d
 d t Wd  QXd  S(   Nt   strictt   requirementst   runt   dependst   requiresR   s   # This file as created when building:
#
#     %s.tar.bz2  (on '%s')
#
# It can be used to create the runtime environment of this package using:
# $ conda create --name <env> --file <this file>
t    RH   i   s   %s
t   =R   s   utf-8R?  R   s
   index.jsonR>   RK  (   t
   info_indext   pin_dependsRw   RO   R(   t   get_pinned_depsR   R   RM   R   R   t   distt   build_subdirR   t   rsplitR  R   R%  R   R   (   R`   Rs  t   runtime_depsR   Rv  RD  (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   write_info_jsonq  s    	!!5-'!c         ` s   |  j  d  } | r t | t  s0 | g } n  t t |  j j d  d  H } x> | D]6   t   f d   | D  rX | j   d  qX qX WWd  QXn  d  S(   Ns   build/no_linkt   no_linkR   c         3` s!   |  ] } t  j    |  Vq d  S(   N(   t   fnmatch(   R)  t   p(   R   (    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>  s    s   
(	   R   t
   isinstanceR_  R   R   RM   R   t   anyR   (   R`   R   R{  R   (    (   R   s0   lib/python2.7/site-packages/conda_build/build.pyt   write_no_link  s    !c         C` ss   g  } xf |  D]^ } | | j  d   j   } t j rZ | j d |  | j d |  q | j d |  q W| S(   NRr  s   Scripts\%s-script.pys   Scripts\%s.exes   bin/%s(   R   t   stripR+   Ru   RS   (   RB  t   scriptst   entry_pointt   cmd(    (    s0   lib/python2.7/site-packages/conda_build/build.pyRA    s    	c         C` s   |  j  j d i   j d i   } | r t t j j |  j j d  d  m } t | d  sm i | d 6} n  x4 d D], } | | k rt t	 j
 | |  | | <qt qt Wt j | |  Wd  QXn  d  S(	   NRo   t   run_exportss   run_exports.jsonR   t   keyst   weakt   strong(   R  R  (   Rw   RO   R   R|   Rx   R   RM   R   R  R+   R  R%  R   (   R`   R  R   RW   (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   write_run_exports  s    !'c   	      C` sW  t  j r1 g  | D] } | j d d  ^ q } n  |  j j rJ t |   n  t |   t |   t |   t	 |   t
 |   t |   t |   t |   t |  d t |  j j d  |  j j r t |  t |  j j d   n  t |  |  t |  | |  } t |  |  j j | | |  } t |  |  t |  |  |  j d  } t | d  re| g } n  t j t |  j j d  d d	 d
 j } x` | D]X } | j d  rt j t j j |  j j  | j d d   d |  j j! d | qqWWd QX|  j" d  rSt  j# t |  j |  j" d   t |  j j d  |  j j$ d |  j j% n  | S(   s   
    Creates the metadata files that will be stored in the built package.

    :param m: Package metadata
    :type m: Metadata
    :param files: Paths to files to include in package
    :type files: list of str
    s   \R   t   test_dirR  R)   R  t   gitR   R?  s   utf-8t   git_urlt   folderRp   t   verboseR   Ns   app/icons   icon.pngRt   (&   R+   Ru   R   RM   t   filename_hashingR'  Rz  Rk  RU  R  R   R  R  R  RD   R   R   R#  RE  R0  t   create_info_files_json_v1R:  R  Re  R  t   ioR   RO   R)   t   git_infoR|   Rx   R   R  R   R~   R   Rt   (	   R`   R   R   t   _fR/  t	   checksumst   sourcesR   R   (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   create_info_files  sB    		(







*- c         C` s   t  |  j d   } |  j d k r | j d  d k rJ | | j d  S| j d  ru | | k ru | j d d  S| j d  r | | k r | j d d  S| Sn |  j d d   r d  S| Sd  S(	   Ns   build/entry_pointsR@  s   site-packagesi    Rs   s   python-scriptsRr   s   build/noarch_python(   RA  R   R4  R   R{   R   R   (   R`   t   target_fileRC  (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   get_short_path  s    c         C` s4   x- | D]% \ } } } |  | k r | | f Sq Wd S(   N(   NN(   R   (   t
   short_pathR/  R   R   R  (    (    s0   lib/python2.7/site-packages/conda_build/build.pyR1    s    c         ` s3   t  j |   }  t   f d   |  D  r/ t Sd  S(   Nc         3` s!   |  ] } t  j    |  Vq d  S(   N(   R|  (   R)  R}  (   R  (    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>  s    (   R+   R  R  R   (   R{  R  (    (   R  s0   lib/python2.7/site-packages/conda_build/build.pyt
   is_no_link  s    c         C` sl   t  j |   t j t | |   j } g  |  D]- } t j t | |   j | k r/ | ^ q/ } t |  S(   N(   R+   R  R|   t   lstatR   t   st_inoR   (   R   t   target_short_pathR   t   target_short_path_inodet   spt   hardlinked_files(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   get_inode_paths  s
    -c         C` s   t  |   r t j St j S(   N(   R   R   t   softlinkt   hardlink(   Rx   (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt	   path_type  s    c         C` st  |  j  d  } g  } xXt |  D]J} t | |  \ } } t j j | |  }	 t |  |  }
 |
 r |
 j d d  j d d  }
 n  i |
 d 6t j	 |	  d 6t j j
 |	  d 6t |	  d 6} t | |  } | r | | d	 <n  | r
| r
| | d
 <| | d <n  | j d  t j k r_t j t | |   d k r_t | | |  } | | d <n  | j |  q" W| S(   Ns   build/no_links   \R   s   \\t   _patht   sha256t   size_in_bytesR  R{  R   t	   file_modei   t   inode_paths(   R   R   R1  R|   Rx   R   R  R   R+   t   sha256_checksumt   getsizeR  R  RO   R   R  R   t   st_nlinkR  RS   (   R`   R   R   R/  t   no_link_filest
   files_jsonR   R   R  Rx   R  t	   file_infoR{  R  (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   build_info_files_json_v1  s2    !
c   
      C` s   t  |  | | |  } i d d 6| d 6} |  j s~ t t | d  d  / } t j | | d t d d d	 d d t Wd  QXn  t   } x  | D] }	 |	 d | |	 d <q W| S(   Ni   t   paths_versiont   pathss
   paths.jsonR   RK  R>   i   RL  RM  s   : t   clsR  R  (   RM  s   : (	   R  t   noarch_pythonR   R   R%  R   R   R   t   dict(
   R`   R   R   R   R/  t   files_json_filest   files_json_infoR  R  R   (    (    s0   lib/python2.7/site-packages/conda_build/build.pyR  ,  s    
	!	c   	      ` s  t    t    j d k rE t j  j d  d  j n  t j d  j j  } t	 j
 j  j j  r  j j n	  j j } t  j d   j d  t | |  d  j j d  j d t  j d   d	  j d
  d  j d  t j d  j j  } t | |  } t j | d  j j }  j j    j j  t    f d   | D  rt  f d   | D  f } t j t d |   n  t  | d | t  j d   }  j d k rg  | D] } | | k r| ^ q} n | }  j d  rDt j  |  j j  n.  j d k rrt j  |  j j |  n  t j d  j j  } | | } t |  j j  | S(   NR@  s   build/entry_pointsRM   R   s   package/names   package/versiont   preserve_egg_dirs   build/preserve_egg_dirR4  s   build/noarcht   skip_compile_pycs   build/skip_compile_pycc         3` s$   |  ] }  t    |  k Vq d  S(   N(   R   (   R)  R   (   Ry   t   meta_dir(    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>]  s    c         3` s6   |  ], }   j  j t   j  j |  k r | Vq d  S(   N(   RM   R  R   Ry   (   R)  R   (   R`   (    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>^  s    s   Error: Untracked file(s) %s found in conda-meta directory.
This error usually comes from using conda in the build script.  Avoid doing this, as it
can lead to packages that include their dependencies.t   build_pythons   build/noarch_python(   R=   R   R4  R+   t   create_entry_pointsR   RM   t   prefix_filesRy   R|   Rx   R   R  t   host_pythonR:   R   t   boolR   R  R  t   tupleR   R  R>   R;   RA  R  t	   transformt   populate_filesR<   (	   R`   t   initial_prefix_filest   current_prefix_filesR@  t	   new_filest
   meta_filesRC  R   t	   pkg_files(    (   Ry   R`   R  s0   lib/python2.7/site-packages/conda_build/build.pyt   post_process_filesC  sH    

"$		(
c   0      ` sB
  t  j t  } | j d | j    |  j d g   } y t j | j j	  Wn t
 k
 ra n Xt  j | j d d    } d | j   k } | j   j d i   p i  }	 | j }
 | r|  j d  r| s |	 j d  r| j j }
 d j |  } t  j rd n d	 } |  j d  p-d
 j |  } t t j j | j j |  d  . } | j d  | j |  | j d  Wd  QX| |  d <n  |  j d  rt j d |  } |  j d  } | s(t |  d  } t j | d | j j  | d <| d s7| j d j |  d | d   q7n | j  d  } t  j! | j j	  } | j"   } | d | d <| d | d <| j#   | d <| j d  | d <d | d <d | d <xX t  j | j d   D]> } | t j k rt$ d j |    n  t j | | | <qWt j j | j j |  d  } t  j% t j j | j |  d  |  |
 rat& | |  n  i  } t  j' | | g d | j j d | d | t( | d j | j)     | d  k	 r| | t* | d  j | j)     <qn| rOt+ d!   t  j, | | j j	  D   t+ t  j! | j j	   } t+  f d"   |  D  } nQ| j-   s| j. d# j |  j d$    | j d%  } | j d&  } g  | D] } | j    d ^ q} g  | D] } | j    d ^ q} i d' d( 6d) d* 6} x | j/   D] \   } t0   f d+   | | f D  rHt1 d, j   |    q  | k r| j2 rd- } t1 d. j   |    qqWn  t+ t  j! | j j	   } x | j-   D]q } t3 } xI t+ |  D]; } t4 j4 | |  rt5 d/ |  | j6 |  t7 } qqW| s| j. d0 |  qqWt8 | |  } |  j d$  r||  j d$  d1 k r|d2 | k rmd3 | k s|t9 d4   n  t  j: | d5 | j j	 } t  j; t j j | j j< d6   t= | j j	  $ t> | | d5 | j j	 |  d7 <Wd  QXt+ t  j! | j j	   }  t  j: |  | d5 | j j	 } d8 j |  d$ | j#   | j?   g  }! g  }" g  }# |  j d9  d: k s| j j@ d; k rd< n d= }$ tA   f}% tB jC jD | j j	 | |! |$ d> |% t j j |% |! |$  g }" x|" D]}& |& jE d=  rtF jG |& | j  n  t j jH |&  }' y d d? lI mJ }( Wn$ tK k
 r^d  }( | j. d@  n XtL | j dA t3  r|( r|(   }) t  j | j jM  | jM   }* y& |) jN dB |& dC |* dD | j jO  WqtP k
 r}+ | j. dE j |+   qXn  y | j jQ }, Wn tR k
 r&	| j jS }, n X| jT s9	| jU r?	dF n |, }- | j jV ro	t j j | j jV |-  }. n' t j j t j jW | j jX  |-  }. t j j |. |'  }/ t j jY |/  r	t  j; |/  n  t  j% |& |/ | j jZ dG t3 |# j[ |/  qWWd  QXt\ t j jW |.  dH | j j] dI dJ t  j; | j j	  |# S(K   Ns   Packaging %sR   s   build/scripts   package:Ro   R   s   
t   batt   shs   output_script.{}R   R`   t   script_interpreteri    s4   Did not find an interpreter to run {}, looked for {}Rq  t   PKG_NAMEt   TOP_PKG_NAMEt   PKG_VERSIONt   TOP_PKG_VERSIONs   package/namet   inheritt   MSYS2_PATH_TYPEt   1t   CHERE_INVOKINGs   build/script_envs5   env var '{}' specified in script_env, but is not set.t   cwdRj  t   statss   bundling {}s	   bundle_{}c         s` s!   |  ] } t  j j |  Vq d  S(   N(   R|   Rx   t   normpath(   R)  t   pth(    (    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>  s   c         3` s1   |  ]'   t    f d     D  s   Vq d S(   c         3` s(   |  ] } | j    t j j  Vq d  S(   N(   R{   R|   Rx   R   (   R)  t	   keep_file(   t   item(    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>  s   N(   R  (   R)  (   t
   keep_files(   R  s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>  s    s&   No files or script found for output {}RQ   s   requirements/builds   requirements/hostt   PYTHONR@  t   Rs   r-basec         3` s   |  ] }   | k Vq d  S(   N(    (   R)  t	   pkgs_list(   t   dep(    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>  s    s   Empty package; {0} present in build and host deps.  You probably picked up the build environment's {0}  executable.  You need to alter your recipe to  use the {1} env var in your recipe to run that executable.sO   https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#hosts   Empty package; {0} dep present in build but not host requirements.  You need to move your {0} dep to the host requirements section.  See {1} for more info.s"   Including in package existing files:   Glob %s from always_include_files does not match any filest   condas	   bin/condas   Scripts/conda.exesm   Bug in conda-build has included conda binary in package. Please report this on the conda-build issue tracker.R   R  R  RH   RF  t   conda_v2t   2s   .condas   .tar.bz2t
   out_folder(   t   Verifys   Importing conda-verify failed.  Please be sure to test your packages.  conda install conda-verify to make this message go away.t   verifyt   path_to_packaget   checks_to_ignoret   exit_on_errors   Package doesn't have necessary files.  It might be too old to inspect.Legacy noarch packages are known to fail.  Full message was {}R4  Rt   R  t   threadsi   (^   R+   R   R   R  Rv  RO   R|   R}   RM   Ry   R   R  R   R   Rv   t$   get_top_level_recipe_without_outputst   activate_build_scriptt   activateR   Ru   R^   R   Rx   R   R   R(   t   get_dictt   guess_interpreterR   R   t   build_prefixt   errorR  R  R   RR   R  R~   t   _write_activation_textt   check_call_envRn   RQ   R[   R-  t   expand_globst   always_include_filesR   R   t   allR@   t"   uses_new_style_compiler_activationR  R|  Rj   R  R   R  t   AssertionErrorR   t   rm_rfR   R&   R  R   t   conda_pkg_formatR   t   conda_package_handlingt   apit   createR   R*   t	   check_allt   basenamet   conda_verify.verifyR  t   ImportErrort   getattrt   ignore_verify_codest   verify_packaget   exit_on_verify_errorRa  t   target_subdirRb  Rz   R4  R  t   output_folderR	   t   bldpkgs_dirR   R   RS   R-   t   debug(0   t   outputRT   Rj  R  t   kwR   R   R   R   t	   top_buildt   activate_scriptt   suffixt	   script_fnR   t   interpretert   interpreter_and_argst   initial_filest
   env_outputt   vart	   dest_filet   bundle_statst	   pfx_filest
   build_depst	   host_depst   pkgt
   build_pkgst	   host_pkgst   dangerous_double_depst   env_var_namet   linkt   patt   has_matchesR  R  t   tmp_archivest   final_outputsR   t   tmpt   tmp_patht   output_filenameR  t   verifierR  R  t   crossed_subdirRP   R  t   final_output(    (   R  R  s0   lib/python2.7/site-packages/conda_build/build.pyt   bundle_conday  s   	,'


	&(	###"		$'"%(	'(c         C` sY  t  j r d n d } t   } t  j | j j  t j j | j j d |  } t	 | d  7 } | j
 d  | j
 d j |   | j
 d  Wd  QX| j j r t | |  n  t j d |  j   } | d | d	 <| d
 | d <| j   | d
 <| j d  | d <t |  } i  }	 t  j | | g d | j j d | d |	 t |	 d j | j     | d  k	 r|	 | t | d j | j     <n  t t j j | d   }
 |
 st d   n  |
 d } | j j rt j j | j j | j j  } n | j j } t  j | | d | j j Wd  QXWd  QXt j j | t j j  |   S(   Ns   .bats   .sht   wheel_outputR   s   
s$   pip wheel --wheel-dir {} --no-deps .R`   R  R  R  R  s   package/nameR  Rj  R  s   bundling wheel {}s   bundle_wheel_{}s   *.whls9   Wheel creation failed.  Please see output above to debug.i    Rt   (!   R+   Ru   R   R&   RM   R   R|   Rx   R   R   R   R^   R  R  R(   R  R   RR   R   R  R  Rn   RQ   R   R[   R%   R  R  RP   R  R~   Rt   R  (   R  RT   Rj  R  R   t   tmpdirR  R   R  R  t   wheel_filest
   wheel_fileR  (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   bundle_wheel;  s>     %
$(c      	   C` se   t    } xU t t j j |  d   D]8 } t |  $ } t j |  } | | | d <Wd QXq% W| S(   s   
    Scan all json files in 'path' and return a dictionary with their contents.
    Files are assumed to be in 'index.json' format.
    s   *.jsonRQ   N(   R  R%   R|   Rx   R   R   R%  t   load(   Rx   t	   installedR  R   R   (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   scan_metadataa  s    	"R  t   wheelc   	      C` sO  t  j r d n d } t  j r$ d n d } d j | t j j t  j d  j d d  | f  } t r |  j d j	 d t
 j   n  | j rot | j j d	 d
  } t |  s t t |   s t j t |   n  t | d  j   n  d j | | j j j d d  | f  } t r9|  j d j	 |   qo|  j d j	 | |   |  j d  |  j d  n  d j | | j j j d d  | f  } t r| j rd n d } |  j d j	 | |   n |  j d j	 | |   t | j j d	 d
  } t |  sKt t |   s5t j t |   n  t | d  j   n  d  S(   Ns   $(cygpath -u Rp   s    )R  s   \s   \\s2   eval "$('{sys_python}' -m conda shell.bash hook)"
t
   sys_pythons
   conda-metat   historyt   as   conda activate "{0}"
s   source "{0}" "{1}"
s   unset CONDA_PATH_BACKUP
s   export CONDA_MAX_SHLVL=2
s   --stacks   conda activate {0} "{1}"
(   R+   Ru   R   R|   Rx   t   root_script_dirR   R   R   R^   R   t
   executablet   is_crossRM   Ry   R   R   R	   R}   R   R   R  (	   t   file_handleR`   t   cygpath_prefixt   cygpath_suffixt   activate_patht   history_filet   host_prefix_patht   build_prefix_patht   stack(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   _write_sh_activation_textt  sD    	!			c         C` s   t  |  d   } | j   } | j d  t j j |   d j   d k r | j j j	 d  ru d d l
 m } n  | | |  nW t j j |   d j   d k r t | |  n% t j t  } | j d j |    | j |  Wd  QXd  S(	   Ns   r+i    i   s   .batt   win(   t   write_bat_activation_texts   .shsJ   not adding activation to {} - I don't know how to do so for this file type(   R   R   t   seekR|   Rx   t   splitextRN  RM   Rw  R{   t   conda_build.utilsRB  R@  R+   R   R   R   R^   R   (   t   script_pathR`   RT  R   RB  R   (    (    s0   lib/python2.7/site-packages/conda_build/build.pyR    s    ""
c         ` s  |  j  d  } g  | D] } t j |  ^ q } |  j  d  } g  | D] } t j |  ^ qG } |  j |  j _ |  j r|  j rt t  t d  k  r t	 d   n  t
 j |  j j t |  d d |  j j d |  j j d |  j j d |  j j d	 t |  j j  d
 |  j j d |  j j d |  j j d |  j j d t |  j j  
} t
 j |  j j | d d d |  j d |  j j d |  j d |  j   d k n  |  j r| j |  n  t
 j |  j j t |  d d |  j j d |  j j d |  j j d |  j j d	 t |  j j  d
 |  j j d |  j j d |  j j d |  j j d t |  j j  
} y| sht j |  j j d i   |  j j  d  t j! |  j" d g    t j! |  j" d g    } t
 j |  j j# t |  d d |  j j d |  j j d |  j j d |  j j d	 t |  j j  d
 |  j j d |  j j d |  j j d |  j j d t |  j j  
n  Wn t$ k
 r	} d d l% m&   t' |  d  r|  j( j)   n |  j* d t+  }	 t,   f d   | j- D  t, d   |	 D  }
 |
 r
|
 | _- |  q
n X|  j j. sFt/ j0 j1 |  j j  sFt/ j2 |  j j  rt
 j |  j j | d d d |  j d |  j j d |  j d |  j   d k n  d  S(   NRo   t   hosts   4.3.2s0   Non-native subdir support only in conda >= 4.3.2RP   R  R  Rt   t   bldpkgs_dirsR   t   disable_pipt   max_env_retryR  R`  Rj  RM   R7  t   is_condaR  Rm  Rn  s   test/requiress   requirements/runR  i   (   R   t   other_outputst   permit_undefined_jinjac         3` s   |  ] }   |  j  Vq d  S(   N(   RQ   (   R)  R  (   R   (    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>  s    c         s` s!   |  ] \ } } | j    Vq d  S(   N(   RQ   (   R)  RJ   t   out(    (    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>  s    (3   t
   ms_dependsR+   t   ensure_valid_spect   build_is_hostRM   t   _merge_build_hostR7  R   RW  R  R(   t   get_install_actionsRy   R  Rz   R  R  Rt   RH  R   RI  RJ  R  R`  t
   create_envRQ   R   R  Rw  t   insert_variant_versionsRw   RO   RN   R  R   t   test_prefixR?   t   conda_interfaceR   R  RL  t   valuest   get_output_metadata_setR   R-  t   packagest   dirtyR|   Rx   R   R  (   R`   t   notestt   build_ms_depst   spect   host_ms_depst   host_actionst   build_actionst   test_run_ms_depsR  RL  t   missing_deps(    (   R   s0   lib/python2.7/site-packages/conda_build/build.pyt   create_build_envs  s    ""$	3	<c   A   $   ` s{  i  } | s i  } n  |  j    r8 t t j |    | St j t  }	 g  }
 g  } g  } t j |  j j   t	 j
 d |     Wd QXd   d <t r t j	 d   d <n  |  j r t |  d t n  | t d g k rt |  | | f g  } g  } g  } |  } t } x | D] \ } } | j    sC|  j j rYt | d  rY| j t |   n | j t |   | j   |  j   k r| } t } qqW| st d |  j p|  j   d	 j |  j     | S| sWg  } xi | D]a  t j j   d
 r6t  f d   t D  r6| j t j j    q| j   qWt d |  n  t	 j |  j j  g g  | D]   | k rp ^ qp|  j  g  |  j! d  D] } | j" ^ q} t d   |  j# j$ d g   D  r| j% d d g  n  |  j& } | r| | k r| d k r"d n | } t j j' t( j) | |  j j  pLd  } | s| d k s{t d   | D  r| j |  |	 j* d |  qt+ d   qn  | rt j, | j# j$ d i   | j j- d  t j, | j# j$ d i   | j j- d  d } t. | j j- j$ d g    } xB | j j- j$ d i   j/   D]" } | | k rF| j0 |  qFqFW| rt1 j2 d j3 d   | D   } n  t4 |  t |  n  t5 | |  t6 |   t j |  j j   t |  d t d t Wd QX| r|  j7 r|  j8 d t  n | r+t9 |   }  n  t: |  t j j3 |  j j; d   |  j j; } t< |  r|  j j= rt d  |  qn& |  j j= rt d!  n  t j> |  t j? |  j j@  t jA d" |  j jB  } tC t3 |  j jD d#  d$  6 } | jE d% j3 tF tG |     | jE d%  Wd QXt jH |  jI d& d   } | r^d% j3 |  } n  t< |  ri  }  t jJ rt3 |  j d'  }! | rt3 | d'  }! d( d lK }" |" jL d)  tC |! d*    }# |# jE |  Wd QXn  tM jN |  |! d+ |  d, | n~t3 |  j d-  }! t' |!  r5| r5tO d.   n  t' |!  sG| rtP |  | |!  \ }$ } | stQ g |  j jR rd/ g n g  d0 |$ g }% |  j jR s|  j jS rd }& n d1 d2 g }' |  jT s|' jU d
 d3  n    f d4   |' D }& xH |& jV   D]: \ }( }) t d5 j |! jW d6  r'd7 n d8 |( |)   qW  d9 =t jX |% d:   d; |& d< | d+ |  t jY |  j jB  qn  |  r| rtZ |  d= j |  j     | d k	 r|  | t[ |  d  <qqqn  t3 |  j jD d#  }* t.   }+ t j j' |*  r4	tC |*   } t. | j\   j]    }+ Wd QXn  t jA d" |  j jB  |+ }, | }- | r[| t d g k r[| p	|  j^ d> t  }. |  }/ t3 |  j jD d#  }* t j j' |*  r	tC |*   } t. | j\   j]    }+ Wd QXn	 t.   }+ |  j j_ d? k r
|  j j_ n	 |  j j` }0 ta   6}1 xH |, D]@ } t jb t j j3 |  j jB |  t j j3 |1 |  d@ t q*
Wx|. D]\ }2 }  |  j    r
t t j |    qu
n  |  j j r
t |  d  r
t t j |    |2 |  f |- t |   <qu
n  |/ j   |2 j$ dA  k rM|2 j$ dB  p&|2 j$ dC  rMt jA d" |  j jB  |+ |2 dB <n  dC |2 k rt jb t j j3 |  j |2 dC  |  j j;  n  |2 j$ dD i   j$ dC  }3 |3 rt j j' t j j3 |  j |3   st+ dE j |3    n  t jb t j j3 |  j |3  t j j3 |  j j; |3   n  |2 j$ dF  dG k sX|  j7 sXtc dH j |  jd      t |   }4 |4 | k ru
|4 |- k ru
|	 je dI j |  j     |  jf pt j j< |  j jB  otg t jh |  j jB   d
 k s|	 jR dJ  ne|  jT |  j _i t j? |  j jB  t j? |  j j  t j? |  j jj  |  j! d  }5 |  j! d  }6 |  jk rQ|  jT rQt	 jl |  j jB tm |5  d dK |  j j_ dL |  j jR dM |  j j= dN |  j jn dO tm |  j jo  dP |  j jp dQ |  j jq dR |  j jr dS |  j js dT tm |  j jt  
}
 t	 ju |  j jB |
 d: d dU |  j dK |0 dV |  jk dW |  j   dG k n |6 j% |5  t	 jl |  j j tm |6  d dK |  j jv dL |  j jR dM |  j j= dN |  j jn dO tm |  j jo  dP |  j jp dQ |  j jq dR |  j jr dS |  j js dT tm |  j jt  
} t	 ju |  j j | d: d dU |  j dK |  j jv dV |  jk dW |  j   dG k t.   }7 x9 |2 j$ dB g   D]% } | jw dX  rk|7 jx |  qkqkWdB |2 k rt. |2 dB  |7 |2 dB <n  xH |, D]@ } t jb t j j3 |1 |  t j j3 |  j jB |  d@ t qWt j |  j j   t	 j
 d |     Wd QXty |  dF  sIdG n |  jz }8 t{ |8 |2 |    |  }9 dY |2 k r,x |2 dY jV   D] \ }: }; x |- jV   D] \ } }< |< \ }= } |: |= j$ dY i   k r|= dY |: }> |; |> k rdZ n d[ }? |	 j* d\ j |? |: |2 dA |= dA   qqWqWn  x |9 D] }@ |2 |  f |- |@ <q3W|  j| s_|  j} red? n	 |  j j_ }0 |  jk rt~ dK |0 d] |  j j  dS |  j js dT |  j jt dL |  j jR dM |  j j= dN |  j jn dP |  j jp d^ t  	n  t~ dK |0 d] |  j j  dS |  j js dT |  j jt dL |  j jR dM |  j j= dN |  j jn dP |  j jp d^ t  	qu
qu
WWd QXn | swt d_ |  jd    n  |- S(`   s  
    Build the package with the specified metadata.

    :param m: Package metadata
    :type m: Metadata
    :type post: bool or None. None means run the whole build. True means run
    post only. False means stop just before the post.
    :type need_source_download: bool: if rendering failed to download source
    (due to missing tools), retry here after build env is populated
    R`   Nt   BUILDt   CONDA_BUILD_STATEt   CONDA_PATH_BACKUPt   no_download_sourceRG  s   Packages for s   with variant {} are already built and available from your configured channels (including local) or are otherwise specified to be skipped.i   c         3` s+   |  ]! } t  j j    d  | k Vq d S(   i   N(   R|   Rx   RD  (   R)  R   (   R  (    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>Q  s    s   BUILD START:Ro   c         s` s$   |  ] } | j  d   d k Vq d S(   RF  R1  N(   RO   (   R)  RN  (    (    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>[  s    R   t   pipR1  t	   mercurialt   hgRp   c         s` s*   |  ]  } | j  d   o! d | k Vq d S(   R@  s   3.N(   R{   (   R)  R^  (    (    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>d  s    s   Your recipe depends on %s at build time (for templates), but you have not listed it as a build dependency.  Doing so for this build.s   Your recipe uses mercurial in build, but mercurial does not yet support Python 3.  Please handle all of your mercurial actions outside of your build script.Rm  t   ignore_versiont   pin_run_as_buildt   |c         s` s   |  ] } d  j  |  Vq d S(   s   (?:^{}(?:\s|$|\Z))N(   R^   (   R)  t   exc(    (    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>{  s   t   raise_errort   allow_no_other_outputss   metadata_conda_debug.yamls   source tree in:s&   no source - creating empty work folderR   s   prefix_files.txtR   u   
s   build/scripts   bld.bati    s   utf-8R   R  t   provision_onlys   build.shs   Found a build.sh script and a build/script section inside meta.yaml. Either remove the build.sh script or remove the build/script section in meta.yaml.s   -xs   -et   PREFIXt   SRC_DIRt   BUILD_PREFIXc         ` s)   i  |  ] } |   k r   | |  q S(    (    (   R)  RW   (   Rj  (    s0   lib/python2.7/site-packages/conda_build/build.pys
   <dictcomp>  s   	s   {0} {1}={2}s   .batR-  t   exportt   CONDA_BUILDRj  t   rewrite_stdout_envR  s   building {}t   permit_unsatisfiable_variantsR4  t   symlinksRQ   R   R   R  se   test script specified as {} does not exist.  Please check for typos or create the file and try again.RF  R  s'   output metadata for {} is not finalizeds   Packaging {}s?   Not creating new env for output - already exists from top-levelRP   R  R  Rt   RH  R   RI  RJ  R  R`  RM   R7  RK  s
   conda-metaR  t   Exactt   Inexacts+   {} overlap between {} in packages {} and {}R  t   clear_caches   STOPPING BUILD BEFORE POST:(   t   skipRj   R+   t   get_skip_messageR   R   t   path_prependedRM   R  R(   R  R   R|   t   needs_source_for_renderR4   R  R   R3   R   t   skip_existingt   is_package_builtRS   R/   RQ   Rx   R^   R$  RD  R  R   R  t   remove_existing_packagesR  RO  R^  Rw   RO   R   t   uses_vcs_in_buildR   R   R   R   R  RU  RN   R-  R  R  R;  t   compileR   R6   Rd  t   warn_on_use_of_SRC_DIRt   finalt   parse_until_resolvedR1   R.   R   R   R  R}   R  R   R  Ry   R   t   build_folderR   R   R_  R  R   Ru   t   codecst	   getwritert   windowsRo   R@   t   write_build_scriptst
   shell_pathR  t   no_rewrite_stdout_envRQ  t   insertR   R   R  t   remove_pycache_from_scriptsRn   R[   R   R   RY  Rz   RP   R   R~   R  Rv  R  R   R   R  RR  RV  R7  RS  R  Rt   RH  R   RI  RJ  R  R`  RT  Rw  R{   t   addR  RF  t   bundlersR4  R  R,   (A   R`   R  t   postt   need_source_downloadt   need_reparse_in_envt   built_packagesR\  Rr  t   default_returnR   R`  Ra  t   output_metast   skippedt   package_locationst   top_level_pkgt   top_level_needs_finalizingRJ   t   omt   printed_fnst   mst   specst
   vcs_sourcet   vcs_executablet   has_vcs_availablet   exclude_patternt   excludesRZ   R  t   files1R   R   t   build_statst
   build_fileR  t   bft	   work_fileR  t   rewrite_envt   rewrite_varsRW   t   vt   prefix_file_listR  t   new_prefix_filest   new_pkgsR   t   top_level_metaRP   t   prefix_files_backupt   output_dt   test_scriptt   pkg_pathR_  t   sub_build_ms_depst	   to_removet   pkg_typet   newly_built_packagesR   t   csumt   prev_omt   prev_output_dt	   prev_csumt   naturet   built_package(    (   Rj  R  s0   lib/python2.7/site-packages/conda_build/build.pyRo     s   	
	',%%	#	
""%
"!"	!,		
	)	!!	*/$	!	!			$$#c         C` s   i t  j r d d g n d g d 6t j j d d  d d g d	 6d
 d d d g d 6d g d 6} t j j |   d } xQ | j   D]+ \ } } | j   j	 |  r | } Pq q Wt
 d j | |     | S(   Ns   bash.exes   -lRG   s   .sht   COMSPECs   cmd.exes   /ds   /cs   .batt
   powershells   -executionpolicyt   bypasss   -Files   .ps1R@  s   .pyi   sR   Don't know how to run {0} file.   Please specify script_interpreter for {1} output(   R+   Ru   R|   R(   RO   Rx   RD  R   RN  R{   t   NotImplementedErrorR^   (   t   script_filenamet   extensions_to_run_commandst   file_extR   t   commandt   interpreter_command(    (    s0   lib/python2.7/site-packages/conda_build/build.pyR    s    "	c         C` s   t  t j j |  j d   } xk | D]c } t |   } | j   } Wd  QXd | k r% d |  j d  k r% |  j j r% t	 d   q% q% Wd  S(   Ns	   run_test*Rt  t   source_filesR  s)  In conda-build 2.1+, the work dir is removed by default before the test scripts run.  You are using the SRC_DIR variable in your test script, but these files have been deleted.  Please see the  documentation regarding the test/source_files meta.yaml section, or pass the --no-remove-work-dir flag.(
   R%   R|   Rx   R   R   R   Re  RM   t   remove_work_dirR  (   RT   t
   test_filesR   R  t   contents(    (    s0   lib/python2.7/site-packages/conda_build/build.pyR    s    !c         C` s   t  | _ d  | _ i  } t t |  d | d t   d d } t j t  } | j	 d  t j
 | j j  | j j d i   j d  r | j s t | d t  q n  | | f S(	   NRM   t   reset_build_idi    i   s   Testing based on recipes is deprecated as of conda-build 3.16.0.  Please adjust your code to pass your desired conda package to test instead.R  R  Rh  (   R  t   need_cleanupR   R   R3   R0   R+   R   R   R   R  RM   R  Rw   RO   t   source_providedR4   (   R   RM   t
   hash_inputRT   R   (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt(   _construct_metadata_for_test_from_recipe  s    		&	c      	   C` s  t  j |   \ } } | | _ | | _ i  } t j j t j j | d   } t t j j | d    } t	 j
 |  } Wd  QX| d d k r | d | _ n  t j j | d  } t j j |  r t t j j | d    } t	 j
 |  } Wd  QXn t | _ i  } | | _ t  j t  } t j j t j j t j j |     }	 t j j |	  }
 t } x& d D] } |
 j |  rnt } qnqnW| s| j d	  t j j | j | j  } y t j |  Wn n Xt j j | t j j |    }	 t  j |  |	  | }	 n  t j j |	  } t | d
 | j d d y3 t t j j | d  d | d t d d } Wn t t t  f k
 rt! j" i i | d d 6| d d 6d 6i t# | d  d 6| d d 6d 6i | d d 6d 6d | } n X| j$ rd | j% j d <n  t& | j'    | j% _( t& t  j) | j% j*   } t+ |  } g  | D] } | d k ro| n | ^ qW} | | k r| j, d |  n  | | j% _* t  j- | j% j.  | | f S(   NR  s
   index.jsonRP   R4  s   hash_input.jsons   win-s   linux-s   osx-sM  Copying package to conda-build croot.  No packages otherwise alongside yours will be available unless you specify -c local.  To avoid this warning, your package must reside in a channel structure with platform-subfolders.  See more info on what a valid channel is at https://conda.io/docs/user-guide/tasks/create-custom-channels.htmlR  R  i   R   RM   R  i    RQ   RR   t   packaget   build_numbert   numberRo   R   Ro  Rn  Rm  RI   t   local(   s   win-s   linux-s   osx-R4  (/   R+   t   get_recipe_abspathR  R   R|   Rx   R  R   R   R%  R.  Rz   R   R  R  RN   R   R   t   abspathR	   R  R{   R   R   t   crootR}   R~   R-   R  R0   R   t
   SystemExitR   R8   t   fromdictR]   R4  RM   R_  R  t	   used_varsR  R`  R   R  R  R  (   R  RM   R   R  R  R   R   t   package_dataR   t   local_pkg_locationt   last_elementt
   is_channelR   t	   local_dirt   local_channelRT   t   urlst
   local_patht   url(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt)   _construct_metadata_for_test_from_package  sp    		!		*!		+c      
   C` s  t  |  j d  r |  j j n |  j } | rt j j t j j | d   } t j j | d  } t j j |  rAt j j |  rAt	 j
 | |  j j |  j j d t d |  j j d t t j j | d  } g  } t j j |  rt |   } t j |  } Wd  QXn  |  j j d i   } | | d <| |  j d <q|  j j d i   j d	  r|  j s~t |  d
 t q~qn  d  S(   NR   R  R  Rz  Rt   R   s   test_time_dependencies.jsonRp  R  Rh  (   R  RM   R   Rx   R|   R  R   t   existsR   R+   R~   R  R   R   Rt   R   R   R%  R.  Rw   RO   R  R4   R  (   RT   R   R   R  t   dependencies_filet	   test_depsR   t   test_section(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt    _extract_test_files_from_package  s&    '!$
	c         C` sa   t  j j |   s* t  j j |   d k rB t |  |  \ } } n t |  |  \ } } | | f S(   Ns	   meta.yaml(   R|   Rx   R   R  R  R  (   t   recipedir_or_packageRM   R`   R  (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   construct_metadata_for_test;  s    *c   	      C` s  t  j |  j j  3 t  j |  j j   t j d |   } Wd  QXWd  QXd | d <d | d <t | d <t | d <|  j j | d <t | d	 <|  j	 d
 k r t | d <n  t
 |  j j d  } t
 |  j j d  } t | d  q } xN | j   D]@ \ } } | d k r | d  k	 r | j d j | |   q q W|  j rNt | |   n  Wd  QXt | d  | } | j d  | j d j |   | j d  | r| j |  n  t |  r| r| j t |  j    n  Wd  QXt j | d  | | f S(   NR`   Re  Rf  R  t   PIP_NO_BUILD_ISOLATIONt   PIP_NO_DEPENDENCIESt   PIP_IGNORE_INSTALLEDt   PIP_CACHE_DIRt   PIP_NO_INDEXR@  t   PYTHONDONTWRITEBYTECODEs   conda_build.shs   build_env_setup.shR   Rp   s   export {0}="{1}"
s!   if [ -z ${CONDA_BUILD+x} ]; then
s       source {}
s   fi
i  (   R+   R  RM   Ry   R  R(   R  R   t   pip_cache_dirR4  R   R   R   R   R   R   R^   R  R@  R   R   R|   R   (	   R`   R   R  Rj  R  t   env_fileR  RW   R  (    (    s0   lib/python2.7/site-packages/conda_build/build.pyR  C  s:    




 	"c	         C` s  t  j t  }	 t | d  }
 |
 j d j d t  j r? d n d d |   t  j rh |
 j d  n  | r |  j j } |  j	 d  r t
 j d k r | d } n  |
 j d	 j d
 | d t |  j j d    t  j r |
 j d  q n  | rZ|
 j d j d |  j j |  j j |  j j  d t |  j j d    t  j rZ|
 j d  qZn  | r|
 j d j d |  j j |  j j |  j j  d t |  j j d    t  j r|
 j d  qn  | r0|
 j d j d |  j j |  j j |  j j  d t |  j j d    t  j r0|
 j d  q0n  | rx | D] } t  j rt j j |  d d k r|
 j d j d |   |
 j d  q|	 j d  q=t j j |  d d k r=|
 j d j d t d | d |   q=q=Wn  Wd  QXd  S(   NR   s   {source} "{test_env_script}"
R)   t   callt   test_env_scripts   IF %ERRORLEVEL% NEQ 0 exit 1
s   build/osx_is_appR   s   "{python}" -s "{test_file}"
R@  t	   test_files   run_test.pys   "{perl}" "{test_file}"
t   perls   run_test.pls   "{lua}" "{test_file}"
t   luas   run_test.luas   "{r}" "{test_file}"
t   rs
   run_test.ri   s   .bats   call "{test_file}"
sC   Found sh test file on windows.  Ignoring this for now (PRs welcome)s   .shs'   "{shell_path}" {trace}-e "{test_file}"
R  t   trace(   R+   R   R   R   R   R^   Ru   RM   t   test_pythonR   R   R   R   R  t   perl_binRV  t   host_platformt   lua_bint   rscript_binR|   Rx   RD  R   R  (   RT   t   test_run_scriptR  t   py_filest   pl_filest	   lua_filest   r_filest   shell_filesR  R   t   tfR  t
   shell_file(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   _write_test_run_scripty  s`    
						Rp   c         C` s{  |  j  j s |  j   d k rk t j | |  j  j d t } t j rk |  j  j t j	 | d | d <qk n  | j
 t |  j  j   d   | j   D } t j r d n d } t |  j  j d j d |   }	 t |  j  j d	 j d |   }
 t |	 d
  M} t j s(| j d j d |   n  |  j  j rI|  j   d k rIt j rVd n d } t rt j r| j d j t j |  j  j rd n d t j   n | j d j d t j   | j d j d |  j  j   nM | j d j d t j t j j d t j rd n d d | d |  j  j   t j rI| j d  qIn  Wd  QXt |  |
 |	 | | | | | | 	 |
 |	 f S(   NR  t   prepend_prefixt   PATHc         S` s+   i  |  ]! \ } } t  |  t  |   q S(    (   RL   (   R)  RZ   Rg  (    (    s0   lib/python2.7/site-packages/conda_build/build.pys
   <dictcomp>  s   	 R  R  s   conda_test_env_vars.{suffix}R  s   conda_test_runner.{suffix}R   s   set {trace}-e
R  s   .batRp   sr   set "CONDA_SHLVL=" && @CALL {}\condabin\conda_hook.bat {}&& set CONDA_EXE={}&& set _CE_M=-m&& set _CE_CONDA=conda
s   --devs2   eval "$('{sys_python}' -m conda shell.bash hook)"
R2  s   conda activate "{test_env}"
t   test_envs2   {source} "{conda_root}activate{ext}" "{test_env}"
t
   conda_rootR)   R  R   s   IF %ERRORLEVEL% NEQ 0 exit 1
(   RM   R  RQ   R+   t   prepend_bin_pathRV  R   Ru   R|   t   pathsepR.  RA   RN   R   R   R  R^   R   R   R   R   R   R  R6  R5  Rx   R   R  (   RT   R]  R  R  R  R  R  R  R  R  R  R	  R   (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   write_test_scripts  sF    	%		"	c         ` s  t  j t  } i  } t |  d  r0 |  j   n |  } | sL t d |  n  t |  d  rw |  } t  j | j j  n t	 |  |  \ } } | j j
 r d n d }	 t |  t |  d  o t j j |   o |  j t  o t j j |   t d k }
 |
 st j | j   | j  n  t | | j j  t |  \ } } } } } } t | | | | | g  szt d |  t S| j j rx d | j j f d	 | j j f f D] \ } } t j j |  rt j j t j j |  d
 j d | | j   t | j d |  f   } t d | | d |  t j  | |  qqW| j! rt j j t j j | j j"  d
 j d | j   | j j# f   } t d | j j" d |  t j  | j" |  qn | j$ d  t% |  | j& | | | |  } t  j' | j j(  ` t) t j j*        j+ t j, d | d | j(   d   d <t- rdt j d   d <n  Wd QX| j j. s| j/   d k rt  j0   | j j( d t   n  t  j1 r| j j( t j2   d   d <n  | j j(   d <d   k r  d =n  | j3 s| j4 rd n	 | j j# } t  j | j j(  y t j5 | j j( t6 |  d d | d | j j
 d  | j j7 d! | j j8 d" t6 | j j9  d# | j j: d$ | j j; d% | j j< d& | j j= d' t6 | j j>  
} Wn` t? t@ tA tB tC f k
 r7} | j$ d( tD |   tE | d) | d* | j jF d | j   n XtD tG jH  d+ k rSd, n tD tG jH  } tI d- | tJ  K t jK | j j( | d | j d. d d | d/ | jL d0 | j/   d k Wd QXt  j' | j j(  c t) t j j*        j+ t j, d | d | j j(   d   d <t- r5t j d   d <n  Wd QX| j j rZ| j j   d1 <n  tM |   | | | | | |	  \ } } t  j1 rt j jN d2 d3  d4 d5 | g } n, tO g | j j
 rd6 g n g  d7 | g } yqi  } | sJ| j j
 s| j jP r
d } nv   f d8   d d1 g D } | j j7 rxK | jR   D]: \ } } t d9 jS | j d:  rid; n d< | |   q?Wn  t  jT | d.   d= | j j d> | d? | tU | d@ jS | j/     | d k	 r| j jV r| | tW | dA jS | j/     <n  t j jX t | j j dB   r:tY jZ dC d   n  t dD |  n  Wn< tY jZ k
 rtE | d) | d* | j jF d | j   n X| j[ r| j\ d k	 r| rt  j | j\  n  t S(E   sr   
    Execute any test scripts for the given package.

    :param m: Package's metadata.
    :type m: Metadata
    Rv  s   TEST START:RM   s   -x Rp   i    s   Nothing to test for:RG  Ro   RJ   s   %s_prefix_moveds	   %s_subdirs   Renaming %s prefix directory, s    to t
   work_moveds   Renaming work directory, s   Not moving work directory after build.  Your package may depend on files in the work directory that are not included with your packageR`   R   t   TESTRf  Rg  NR  R  R  Rs  Ru  R4  RP   R  R  Rt   RH  R   RI  RJ  R  R`  s;   failed to get install actions, retrying.  exception was: %st   move_brokent
   broken_dirR   R   t   CONDA_PATH_CONFLICTRj  R7  RK  Rt  R  s   cmd.exes   /ds   /cs   -xs   -ec         ` s)   i  |  ] } |   k r   | |  q S(    (    (   R)  RW   (   Rj  (    s0   lib/python2.7/site-packages/conda_build/build.pys
   <dictcomp>  s   	s   {0} {1}={2}s   .batR-  Rv  R  R  Rx  s
   testing {}s   test_{}t   TEST_FAILEDis	   TEST END:(]   R+   R   R   R  Rv  Rj   R  RM   R  R  R  R  R|   Rx   R   R   R   R	   R#   R(   t   clean_pkg_cacheR#  RD   R  R   R  Ry   R  R   R   R   t   shutilt   moveR  R   Rz   R   R=   t   get_test_depsR  RV  R  R   R.  R  R   R  RQ   R  Ru   R  R4  R  RS  R  R  Rt   RH  R   RI  RJ  R  R`  R?   R!   R    R"   R  RL   t   tests_failedR  R   t   path_conflictR$   R   RT  R7  R  RO   R  R  R   R   R^   R  Rn   t   variantsR[   R  R   R   R  R   (   t    recipedir_or_package_or_metadataRM   R  R  Rr  R   R  t   test_package_nameRT   R  t   in_pkg_cacheRJ   R  R  R  R  R  RQ   R   R"  R  RP   t   actionsRo  t   conflict_verbosityR  R  t
   test_statsR  RW   R  (    (   Rj  s0   lib/python2.7/site-packages/conda_build/build.pyR    s    
	
"
!	"

	
%
'	$,		,+%!
c         C` s  t  |  s t j |  n  t |  d  r: t |   } n |  } t | t j j |   } | r t j	 t
  } y7 t j | |  | j d t j j |  | f  Wn t k
 r n Xt t j j t j j |   d | j d d n  t j d t j j |   d S(   s   
    Causes conda to exit if any of the given package's tests failed.

    :param m: Package's metadata
    :type m: Metadata
    RM   s*   Tests failed for %s - moving package to %sR  R  i   s   TESTS FAILED: N(   R   R|   R}   R  R/   R   Rx   R  R+   R   R   R  R  R   R   R-   R	   R  R   R  (   t   package_or_metadataR  R  RM   R  R"  R   (    (    s0   lib/python2.7/site-packages/conda_build/build.pyR    s     4c          C` sW   t  j j d  rS t j d  }  |  d  k rS t  j d t j j	 t j
   qS n  d  S(   Nt   linuxt   patchelfs   Error:
    Did not find 'patchelf' in: %s
    'patchelf' is necessary for building conda packages on Linux with
    relocatable ELF libraries.  You can install patchelf using conda install
    patchelf.
(   R   R   R{   R   R   R   R  R|   R  R   t	   dir_paths(   R(  (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   check_external  s
    c	   :      ` s  g  }	 t  |   }  t j rv t j j t j j t j  d d  }
 t j j	 |
  rv t
 j d j |
  d t qv n  d } t   } g  } t j   } | j } d  } x	|  r
| r t } t } t | _ n | r t } t | _ n d  } yY|  j   } t | d  r| j   n | } t | d  r| } | j | j _ | j } | j r| j   | j k r| j | j   d t n  t j j | j  } |	 j | j    | j s| rt |  n	 t |  } t | | d	 t } qo| t t f f } nq t j j |  } | j  d
  j  d  } |	 j t j j! |   t" | d | d | d	 t d | j# d t } | t t f k r| d  } n  x| D]\ } } } | d  k rt j$ | j j%  t j$ | j j&  t j$ | j j'  n  | j   | j j( k r#| j j | j   d t n  t) | | d | d | d | d | d | } | s'x| j*   D]\ } } | j+ t,  rt j j- |  rt. | d | j j/   d | n  | \ } } | j0 j1 d i   j1 d  } | rt2 t j3 | j j4  t j5 t j j6 t j j t j j |     g  } t j7 t8  } t | d  rqt9 | j:    } | j; d  n t j3 |  } x| D]~} | j< d j |   d j d   t= d  D  } | j> d  t? |  t? d j | j@   jA d d     g }  g  |  D] }! t jB |!  ^ q	}  yX tC d! d" d# |  = }" tD jE |" |  d$ d d% | j jF d& | j jG d' | }# Wd  QXWn5 tH tI f k
 r}$ | j; d( j | |$   qn XtJ | |# d) d* | d+ t }% t. t9 |% jK    d, d, d | j j/   d | qWn  | jL i | | 6 qcWn | jL |  t j jM | j jN  r| j j# pp| j jO pp| jP d-  rt | _ t j j t j j | j jN  d" j d. | j@   | j jF d/ f   }& tQ d0 | j jN d1 |&  y tR jS | j jN |&  Wq5tR jT k
 r1t j$ |&  tR jS | j jN |&  q5XqqW| jU   Wq tI k
 r
}$ d2 d3 d4 d5 d6 d7 g }' g  | j*   D] }( |( d d j ^ q{}) g  }* |  jV | g  xItW |$ jX |$ jY  D]2\ } }+ | jZ d  d, jZ d8  d,   | r$t[   f d9   | j\ d: t  D  r$  n  | |	 k rm| jU d; t  t] d< j |  t^ |$ j_  d= |   n  | |' k r|	 j |  d> } n  t` t j j |     }, |, st` t j j | d?     }, n  t` t j j |   d@   }- |- s	t` t j j | d?   d@   }- n  t }. |, s-	|- r	x |, |- D]  t[  f dA   |) D  s8	t"  d | j }/ xa |/ D]V }0 t ja t? |+  |0 d, |  rv	tQ dB dC dD j |   |* j   t }. qv	qv	Wq8	q8	Wn  |. s| jU d; t    qqW| rq
| jb |  rq
| jb |  tc | j> dE   k rq
| jU d; t  t] d< j |  t^ |$ j_  d= |   n  | j t j j! |   |  jV |*  q Xq W| t d  g k r$g  | D] }1 |1 j+ t,  r
|1 ^ q
}2 g  | D] }1 |1 j+ dF  r
|1 ^ q
}3 td |2 d | te |3 d | n  t j   | }4 tf g  | jK   D] }5 |5 j1 dG  ^ qDped, g  }6 tg g  | jK   D] }5 |5 j1 dH  ^ q{pd, g  }7 tg g  | jK   D] }5 |5 j1 dI  ^ qpd, g  }8 tg g  | jK   D] }5 |5 j1 dJ  ^ qp
d, g  }9 tQ dK dL  tQ dM  tQ dN j th |4    tQ dO j th |8  th |9    tQ dP j t ji |6    tQ dQ j t ji |7    i |4 dR 6|6 dS 6|7 dH 6| dT <| rtj | dU   }1 tk jl | |1  Wd  QXn  t9 | j:    S(V   Nt   pkgss   .trashs   del /s /q "{0}\*.*" >nul 2>&1t   shellRp   RQ   RM   t   resetRy  R   s   \R  R  t   bypass_env_checki   R  R  R  R  R\  R  R  t   downstreamsR  sL   Dictionary keys for downstreams are being ignored right now.  Coming soon...s   Testing downstream package: {}c         s` s(   |  ] } t  j t j t j  Vq d  S(   N(   t   randomt   choiceR   t   ascii_uppercaset   digits(   R)  RJ   (    (    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>@	  s   i
   Rn  Rq  RH   i   R   RJ   R  Rj  RP   RH  R`  sF   Skipping downstream test for spec {}; was unsatisfiable.  Error was {}RG  t   package_subsett   require_filesi    s%   build/no_move_top_level_workdir_loopsR  t   main_build_loops   Renaming work directory, s    to R@  R  s   r-bases   mro-baseR  R  Rr  c         3` s'   |  ] \ } }   | j    k Vq d  S(   N(   RQ   (   R)  RJ   t   output_meta(   t   pkg_name(    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>	  s    RM  t   remove_folderss3   Can't build {0} due to environment creation error:
s   
s   Typically if a conflict is with the Python or R
packages, the other package or one of its dependencies
needs to be rebuilt (e.g., a conflict with 'python 3.5*'
and 'x' means 'x' or one of 'x' dependencies isn't built
for Python 3.5 and needs to be rebuilt.s   ..s
   -feedstockc         3` s   |  ] } | j     Vq d  S(   N(   R{   (   R)  Rx   (   R   (    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>	  s    s!   Missing dependency {0}, but founds    recipe directory, so building s	   {0} firstRo   s   .whlRg   Rh   Re   Rf   t   #iT   s   Resource usage summary:s   
Total time: {}s   CPU usage: sys={}, user={}s!   Maximum memory usage observed: {}s2   Total disk usage observed (not including envs): {}t   timet   memoryt   totalR   (m   R   R+   Ru   R|   Rx   R   R	   R   R6  R   R   R  R^   R   R   R;  t
   stats_fileR   R  t   anaconda_uploadt   popleftR  RQ   RM   t   set_build_idR   t   compute_build_idRS   R  RB   RC   R2   t   rstripR  R0   R[  R  Ry   R  RV  R  Ro   R   R   R   R   R  R   Rw   RO   R  R  R`  t   path2urlR  R   R   R_  R  R   R  t   rangeRO  R   Rv  Rx  RP  R   R(   RS  Rz   RH  R    R?   R5   RX  R.  R  R   t   keep_old_workR   Rj   R  R  t   Errort   cleant
   extendleftt   zipRZ  t
   matchspecsR  R  RY  R  RL   t   messageR%   t   match_peer_jobR
  R   t   handle_anaconda_uploadt   handle_pypi_uploadt   maxt   sumRc   Rk   R   R%  R   (:   t   recipe_listRM   R  t
   build_onlyR  R\  R  R  R  t   to_build_recursivet	   trash_dirt
   extra_helpR  t   retried_recipest   initial_timeR>  RT   R   RQ   t   recipe_parent_dirt	   variants_t   metadata_tuplest   packages_from_thisR  t   dict_and_metaRJ   Rw   R/  R`  R   R  t   r_stringR  R^  R*  R#  R  t
   local_fileR"  t
   skip_namest   entryt   built_package_pathst   add_recipest	   matchspect   recipe_globt   feedstock_globt	   availablet	   dep_metast   dep_metaR   t   tarballst   wheelst
   total_timet   stept   max_memory_usedt
   total_diskt   total_cpu_syst   total_cpu_user(    (   R8  R   s0   lib/python2.7/site-packages/conda_build/build.pyt
   build_tree  st   	'"			!		
		!""+"		!*" *	!	
$*((7777
	
c   	      C` s  d d l  m } t j |   }  t } | j s7 | j r@ t } n | j sV t	 d  n t } d } x! |  D] } | d j
 |  7} qi W| d 7} | s t	 |  d  S| d  } | d  k r t	 |  t j d  n  | g } | j r| j d	 | j g  n  | j d
  | j r'| j d  n  | j rI| j d | j g  n  x$ | j D] } | j d | g  qSWxi |  D]a } y7 t	 d j
 t j j |    t j | | g  Wqwt j k
 rt	 |    qwXqwWd  S(   Ni    (   R   s!   # Automatic uploading is disabledsA   # If you want to upload package(s) to anaconda.org later, type:

s   anaconda upload {}
sl   
# To have conda build upload to anaconda.org automatically, use
# $ conda config --set anaconda_upload yes
t   anacondasf   
Error: cannot locate anaconda command (required for upload)
# Try:
# $ conda install anaconda-client
s   --tokent   uploads   --forces   --users   --labels   Uploading {} to anaconda.org(   t   conda_build.os_utils.externalR   R+   R  R  t   tokent   userR   R?  Rj   R^   R   R   R  R   RS   t   force_uploadt   labelsR|   Rx   R  R   R  R   (	   R  RM   R   Rt  t   no_upload_messageR  Rs  R  t   label(    (    s0   lib/python2.7/site-packages/conda_build/build.pyRN  	  sL    		


				
c         C` s  d d d | j  d | j g } | j r@ | j d | j g  n  | j rb | j d | j g  n  | j r~ | j d g  n  | j r | j d | j g  n  | j r | j d	 | j g  n  | j r | j d | j g  n  t j	 |   }  | j
 rzx |  D]p } t d
 j |   y t j | | g  Wqt j t  j d  t j t  j d j |   qXqWn t d j |    d  S(   Nt   twineRt  s   --sign-withs   --repositorys   --users
   --passwords   --signs
   --identitys   --config-files   Uploading {}sF   wheel upload failed - is twine installed?  Is this package registered?s   Wheel file left in {}s5   anaconda_upload is not set.  Not uploading wheels: {}(   t	   sign_witht
   repositoryRw  R   t   passwordt   signt   identityt   config_fileR+   R  R?  Rj   R^   R  R   R   R   (   Rk  RM   R   R   (    (    s0   lib/python2.7/site-packages/conda_build/build.pyRO  
  s.    							*c         C` si   t  d  t  d d  t  d |  j d  t j |  j  } t  d j d t |    t  d  d  S(	   Ns   
R:  iT   s1   Source and build intermediates have been left in Rq   s-   There are currently {num_builds} accumulated.t
   num_buildss?   To remove them, you can run the ```conda build purge``` command(   Rj   R  R+   t   get_build_foldersR^   R   (   RM   t   build_folders(    (    s0   lib/python2.7/site-packages/conda_build/build.pyt    print_build_intermediate_warning,
  s    
c         C` s=   | s t  j |  j  } n  x | D] } t  j |  q" Wd  S(   N(   R+   R  R  R  (   RM   t   foldersR  (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   clean_build5
  s    c   	      ` s  xX |  j  j D]J } t j j |  s5 t j |  n  t | d |  j  j d t d d q Wt	 |  j  d j
 |   } | r t |  j  j  d g n g  } | t   7} |  j  j r | j |  j  j  n  t d |  j   d |  j   d	 |  j      t r1d
 d l m } t | j   d | d | d f  St d | d |  j  j d |  j  j d | d |  j  j d |  j  j d |  j  j d |  j  j d t  	\ } } } t   f d   | j    D  Sd  S(   NR  R   R  i   s	   {}_subdirR  RQ   RR   Ro   i    (   t
   SubdirDataRY  t   subdirsR4  RP   R  R  R`  R  Rt   R   R}  c         3` s   |  ] }   j  |  Vq d  S(   N(   t   match(   R)  t   prec(   R^  (    s0   lib/python2.7/site-packages/conda_build/build.pys	   <genexpr>S
  s    (!   RM   RH  R|   Rx   R   R}   R-   R  R  R   R^   R   R  R   R`  R   R   RQ   RR   R   R   t	   conda.apiR  R  t	   query_allR,   R  R  Rt   R   R   R  RX  (	   RT   Rj  t   include_localRf  RP   R  R  t   indexRJ   (    (   R^  s0   lib/python2.7/site-packages/conda_build/build.pyR  <
  s&    &$-%(   t   __doc__t
   __future__R    R   R   t   collectionsR   R   R|  R  R%  R|   t   os.pathR   R   R   R   R	   R0  R;  R  R   R   R   R   R;  t   encodings.idnat	   encodingst   bs4R
   R   t   conda.base.constantsR   t	   ExceptionR   t   conda_package_handling.apiR  RW  R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R    R!   R"   R#   R+   R$   R%   R&   t   conda_buildR'   R(   R)   R*   t   conda_build.indexR,   R-   t   conda_build.renderR.   R/   R0   R1   R2   R3   R4   R5   R6   Ru  t   os_utilsR   t   conda_build.metadataR7   R8   R9   t   conda_build.postR:   R;   R<   R=   t   conda_build.exceptionsR>   R?   R@   t   conda_build.variantsRA   RB   RC   t   conda_build.create_testRD   t   conda_build.noarch_pythonR  R  RW  RX  R   t   conda_build.windowsR  R  Ru   R[   Rc   Rn   R   R   R   R   R   R   R   R  R  R  R#  R'  R0  R:  R>  RE  RU  Rk  Rz  R  RA  R  R  R  R1  R  R  R  R  R  R  R(  R-  R0  R  R@  R  Rd  R   R  Ro   R  R  R  R  R  R  R  R  R  R  R  R*  Rr  RN  RO  R  R  R  (    (    (    s0   lib/python2.7/site-packages/conda_build/build.pyt   <module>   s  ("@"								e			8				3			+				"					6								6		&	
	@		M	 }				Y			6	73			 	<			