ó
à™xTc           @   s  d  Z  d d l m Z d d l m Z d d l j Z d d l Z d d l	 Z	 d d l
 Z
 d d l Z e j e j e j e j e ƒ ƒ ƒ ƒ Z e e j k r¶ e GHe j j e ƒ n  d d l Td d l m Z e j d „ Z e d k rÿ e e j d	 ƒ n  d S(
   sk  
Create a "bundle" (.tar.gz) of all Python modules and compiled code in a
product.  The target directory is expected to look something like this:

CCTBX-<version>/
CCTBX-<version>/base/
CCTBX-<version>/build/
CCTBX-<version>/build/lib/
CCTBX-<version>/cctbx_project/

plus any number of module directories in the top level.  The resulting bundle
will be named bundle-<version>-<mtype>.tar.gz.

Since the base modules take an especially long time to compile, they are now
part of a separate bundle.  This will allow re-use of precompiled base packages
with the latest source, which should speed up installer generation.
iÿÿÿÿ(   t   division(   t   OptionParserN(   t   *(   t   rpathc      
   C   sŽ  t  j d t  j ƒ  ƒ } t ƒ  } | j d d d d d d d d	 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	 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	 d  ƒ| j d d d d d ƒ| j
 |  ƒ \ } }  |  d } t j | ƒ s€t | ƒ ‚ t j | ƒ } | j d  k	 r¹t j | j ƒ s¹t ‚ n  t j | j ƒ t j | ƒ } t j | d  ƒ } t j | d! ƒ } t j }	 | j s)t d" d# ƒ }
 |
 t _ n  | d$ IJt j | g ƒ | d% IJt j | g ƒ |	 t _ t j | j d& | ƒ } t j | ƒ sšt | ƒ ‚ t j | ƒ r¹t j | ƒ n  t j | ƒ t j | ƒ | d' IJt t j | d! ƒ t j | d! ƒ ƒ | d( IJt j | d  ƒ } t j | ƒ t t j | d) ƒ d# ƒ j  | j! ƒ t t j | d* ƒ t j | d* ƒ ƒ | d+ IJ| j" j# d, ƒ } x€ t j$ | ƒ D]o } | dO k s¡| | k rÅq¡n  t j | | ƒ } t j | ƒ r¡| d- | IJt | t j | | ƒ ƒ q¡q¡WxT d. d/ d0 d1 d2 d3 d4 g D]7 } t j | | ƒ } t j | ƒ r0t j | ƒ q0q0Wt j | d5 ƒ } t% | d6 d7 ƒt j& j' d8 ƒ rÁt( t j | d! d* ƒ d9 | ƒn  | d: IJx� t j$ | ƒ D]~ } t j | ƒ } t j | ƒ rÛ| } xQ t j$ | ƒ D]= } | d; k rt t j | | ƒ t j | | | ƒ ƒ qqWqÛqÛWt% | d< d= ƒt% | d< d> ƒt% | d< d? ƒt% | d6 d@ ƒt% | d6 dA ƒt% | d6 dB ƒ| j) rt% | d< dC ƒt% | d< dD ƒt% | d< dE ƒt% | d< dF ƒt% | d< dG ƒn  t j | ƒ | j* sÞdH i | j+ d 6| j! d 6} t, dI i | dJ 6d9 | ƒt j d! ƒ t j- | ƒ sŠt ‚ | j d  k	 rÍt j. | | j ƒ t j | j t j | ƒ ƒ } n  | dK | IJn  dL i | j+ d 6| j! d 6} t, dM i | dJ 6d9 | ƒt j- | ƒ s,t ‚ | j d  k	 rot j. | | j ƒ t j | j t j | ƒ ƒ } n  | dN | IJt j | ƒ d  S(P   Ns   %Y_%m_%ds	   --tmp_dirt   destt   tmp_dirt   actiont   storet   helps   Temporary staging directoryt   defaults	   --versiont   versions   Version number or codes   --mtypet   mtypes   Architecture types   --ignoret   ignores   Subdirectories to ignoret    s   --remove_srct
   remove_srct
   store_trues-   Remove compiled source files (.h, .cpp, etc.)s   --keep_baset	   keep_bases#   Keep base packages with main bundles   --dests)   Destination directory for bundle tarfiless	   --verboset   verbosei    t   buildt   bases	   rpath.logt   ws!   Setting rpath in base packages...s$   Setting rpath in shared libraries...s   %s_tmps   Copying dependencies...s   Copying shared libraries...t   MTYPEt   libs   Copying base modules...t   ,s     copying %s...s   base/bin/gtk-demos   base/mans   base/docs	   base/infos   base/share/gtk-docs   base/share/locales   base/lib/python2.7/tests    base/lib/python2.7/site-packagest	   file_namet   testst   linuxt   logs!   Copying standalone executables...t   exet   file_exts   .pycs   .os   .pyos	   .sconsignt   CVSs   .svns   .cpps   .hpps   .ccs   .cs   .hs$   ../base-%(version)s-%(mtype)s.tar.gzs   tar -czf %(tarfile)s baset   tarfiles     created base bundle %ss&   ../bundle-%(version)s-%(mtype)s.tar.gzs   tar -czf %(tarfile)s .s     created bundle %s(   s   builds   base(/   t   timet   strftimet	   localtimeR   t
   add_optiont   ost   getcwdt   machine_typet   Falset   Nonet
   parse_argst   opt   isdirt   AssertionErrort   abspathR   t   chdirR   t   basenamet   joint   syst   stdoutR   t   openR   t   runt   existst   shutilt   rmtreet   mkdirt	   copy_treet   makedirst   writeR   R   t   splitt   listdirt   find_and_delete_filest   platformt
   startswitht
   strip_libsR   R   R
   t   callt   isfilet   move(   t   argst   outt	   datestampt   parsert   optionst
   target_dirt   pkg_dirt	   build_dirt   base_dirt
   stdout_oldt   fR   t   tmp_build_dirt   ignore_dirsR   t	   full_patht   dir_namet   site_pkg_dirt   module_namet   base_tarfilet   pkg_tarfile(    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/make_bundle.pyR4   &   sæ    	
		

	
%
%%
 "
$		!!t   __main__i   (   t   __doc__t
   __future__R    t   optparseR   t   os.patht   pathR*   R6   R    R$   R1   R-   t   dirnamet   __file__t   libtbx_patht   appendt!   libtbx.auto_build.installer_utilst   libtbx.auto_buildR   R2   R4   t   __name__t   argv(    (    (    sK   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/make_bundle.pyt   <module>   s    *
�