ó
ß™xTc           @   s¡   d  Z  d d l m Z d d l Z d d l j Z d d l Z d d l Z d d l	 Z	 d d l
 Z
 d d l Td „  Z d „  Z e d k r� e e	 j d ƒ n  d S(	   s|   
Package the CCTBX bundle used for various installers (Phenix, etc.) using
sources in the specified repositories directory.
iÿÿÿÿ(   t   divisionN(   t   *c      
   C   sÜ  t  j d t  j ƒ  ƒ } t j ƒ  } | j d d d d d d d d	 | ƒ| j d
 d d d d d d d	 t ƒ| j d d d d d d d d	 t ƒ| j d d d d d d d d	 t ƒ| j d d d d d d d d	 t j ƒ  ƒ| j d d d d d d d d	 d ƒ| j d d d d d d d d	 d  ƒ| j
 |  ƒ \ } }  t |  ƒ d k rjt j |  d ƒ } nB t |  ƒ d k s‚t ‚ t j t j t j t j t ƒ ƒ ƒ ƒ } d  | GHt j | ƒ sÊt ‚ | t j | j ƒ k sèt ‚ t j | j ƒ t j d! ƒ rt j d! ƒ n  t j d! ƒ t j d! ƒ d" d# d$ g } d% d& d' g } d( d) d* d+ g } t d, d- ƒ j | j ƒ d, g } x– | D]Ž }	 t j | |	 ƒ }
 |
 d. } t j |
 ƒ rþt j | ƒ rþ| j sît d/ |	 | f ƒ ‚ qt j  |	 ƒ n t! |
 | ƒ | j" |	 ƒ qŠWxÄ | D]¼ }	 t j | |	 ƒ }
 |
 d. } t j |
 ƒ rÅt j | ƒ rÅ| j r~t j  |	 ƒ qÒ| j# r¨t$ j% d0 d1 |	 | f ƒ q#qÒt d2 d3 |	 | f ƒ ‚ n t! |
 | ƒ | j" |	 ƒ q#WxÄ | D]¼ }	 t j | |	 ƒ }
 |
 d. } t j |
 ƒ rŒt j | ƒ rŒ| j rEt j  |	 ƒ q™| j& sot$ j% d4 d1 |	 | f ƒ qêq™t d5 d6 |	 | f ƒ ‚ n t! |
 | ƒ | j" |	 ƒ qêWt' d7 | j( d8 j | ƒ f d9 t) j* ƒd: | j( GH| j+ d  k	 rbt j | j+ ƒ st ‚ t j t j | j+ | j( ƒ ƒ rIt j, t j | j+ | j( ƒ ƒ n  t j- | j( | j+ ƒ nY t j t j | j | j( ƒ ƒ r¥t j, t j | j | j( ƒ ƒ n  t j- | j( | j ƒ t j | j ƒ t j d! ƒ d  S(;   Ns   %Y_%m_%ds   --tagt   destt   tagt   actiont   storet   helps   Bundle identifiert   defaults   --ignore-missingt   ignore_missingt
   store_trues   Skip missing secondary packagess   --require-allt   require_alls/   Require all listed packages, even optional oness
   --downloadt   downloads'   Download any packages not found locallys   --tmpt   tmp_dirs   Temporary directorys	   --tarfilet   tarfiles   Output tarfile names!   cctbx_bundle_for_installer.tar.gzs   --destt   destinations   Final destination for tarfilei   i    s"   Using '%s' as repository directoryt	   cctbx_tmpt   boostt   cctbx_projectt   sconst   cbflibt   ccp4iot   ccp4io_adaptbxt   gui_resourcest   tntbxt   annlibt   annlib_adaptbxt   cctbx_bundle_TAGt   ws   _hot.tar.gzs&   Essential module '%s' not found in %s!s/   Skipping recommended module '%s' (not found in s   repositories directory %s)s6   Recommended module '%s' not found in %s!  If you want s>   to continue without this module, re-run with --ignore-missing.s,   Skipping optional module '%s' (not found in s3   Required module '%s' not found in %s!  If you want s>   to continue without this module, re-run without --require-all.s   tar -cvzf %s %st    t   logs   Wrote %s(.   t   timet   strftimet	   localtimet   optparset   OptionParsert
   add_optiont   Falset   ost   getcwdt   Nonet
   parse_argst   lent   opt   abspatht   AssertionErrort   dirnamet   __file__t   isdirR   t   chdirt   existst   shutilt   rmtreet   mkdirt   opent   writeR   t   joint   isfileR   t   OSErrort   package_defst   fetch_remote_packaget	   copy_distt   appendR   t   warningst   warnR
   t   callR   t   syst   stdoutR   t   removet   move(   t   argst	   datestampt   parsert   optionst   repositoriest   requiredt   recommendedt   optionalt   have_modulest   module_namet   module_patht   tarfile_path(    (    sa   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/create_cctbx_bundle_for_installer.pyt   run   s¼    *					
 		
 			
 			
!"!"c         C   sO   t  j | ƒ r2 d | GHt d | d t j ƒn d |  GHt |  d t ƒd  S(   Ns   Untarring %s...s
   tar zxf %sR   s   Copying %s...t   create_tarfile(   R*   R8   R@   RA   RB   t   archive_distR$   (   t   dir_namet	   file_name(    (    sa   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/create_cctbx_bundle_for_installer.pyR<   ˆ   s
    		t   __main__i   (   t   __doc__t
   __future__R    R!   t   os.patht   pathR*   R   R%   RA   R:   t   installer_utilsRQ   R<   t   __name__t   argv(    (    (    sa   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/create_cctbx_bundle_for_installer.pyt   <module>   s   
	w	