ó
ß™xTc           @   sq  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 y% d d l Z e d e j ƒ  ƒ Z Wn e k
 r£ d Z n Xe j e j e j e ƒ ƒ ƒ Z e e j k rç e j j e ƒ n  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 Td e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   s9	  
Template for building Unix/Linux installers for CCTBX-based packages, e.g.
Phenix or LABELIT.  This is derived from the Phenix installer, with options
specific to Phenix removed.

The installer makes several assumptions about the distribution bundle, and
will break if it does not encounter the expected files and directories.  The
recommended way to create an installer package is to start with the script
setup_installer.py in the same directory.  The expected directory structure is:

INSTALLER_DIR/bin/
INSTALLER_DIR/bin/install   # main executable, subclasses 'installer' class
INSTALLER_DIR/lib
INSTALLER_DIR/lib/libtbx/   # complete libtbx distribution
INSTALLER_DIR/bundles/      # compressed binary distribution
INSTALLER_DIR/source/       # source tarballs
INSTALLER_DIR/dependencies  # third-party software

The last four directories contain the actual distribution; depending on whether
the installer is source or binary, they may not all be present.  The 'bundles'
directory will have one or more tar.gz files containing all compiled files
(and many Python modules).  The 'sources' directory will contain a set of
tar.gz files for the distributed modules, one of which will be a CCTBX source
bundle (plus various add-ons like ccp4io, cbflib, etc.).  'dependencies' is for
third-party packages such as Python that need to be compiled for source
installation.

In addition to the required contents, the installer may also contain files
named README, LICENSE, etc.; these will automatically be propagated to the
installed package.  Information describing the version may also be provided
but the implementation of this is left up to each product.  Installers may also
have additional directories for non-compiled packages such as geometry
restraints or documentation.

To implement an installer for distribution, an install script should be written
along these lines:

  from libtbx.auto_build import install_distribution
  import os.path
  import sys

  class installer (install_distribution.installer) :
    product_name = "PHENIX"
    dest_dir_prefix = "phenix"
    make_apps = ["phenix"]
    installer_dir = os.path.dirname(os.path.dirname(__file__))

  if (__name__ == "__main__") :
    installer(sys.argv[1:])

Note that the location of the install script is not mandatory, but it must be
able to correctly detect the base installer directory.
iÿÿÿÿ(   t   division(   t   OptionParserNi   i   (   t   write_gui_dispatcher_include(   t   regenerate_module_files(   t   install_base_packages(   t   create_mac_app(   t   package_defs(   t   *t   InstallerErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyR   R   s   t	   installerc           B   sM  e  Z d  Z d Z d Z d Z e j j e d d# ƒ Z
 e Z e Z g  Z d g Z d d g Z g  Z d d	 d
 d g Z e j d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! d „  Z" d „  Z# d „  Z$ d „  Z% d „  Z& d „  Z' d „  Z( d „  Z) d  „  Z* d! „  Z+ d" „  Z, RS($   sk   
  Base class for installers.  Some methods and class attributes must be
  re-implemented in subclasses!
  t   CCTBXs
   /usr/localt   cctbxt
   _INSTALLERt   cctbx_bundlet   mmtbxt   smtbxs   intel-linux-2.6s   intel-linux-2.6-x86_64s   mac-intel-osxs   mac-intel-osx-x86_64c         C   so   | |  _  | |  _ t ƒ  |  j ƒ  |  j ƒ  |  j ƒ  |  j ƒ  |  j rW |  j ƒ  n
 |  j	 ƒ  |  j
 ƒ  d  S(   N(   t   argst   outt   check_python_versiont   parse_optionst   basic_setupt   determine_installation_typet   setup_directoriest   binary_installt   install_from_binaryt   install_from_sourcet   install_finalize(   t   selfR   R   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyt   __init__t   s    		



	
c         C   s‰  t  d d d d d |  j ƒ } | j d d d d	 d
 d d |  j d |  j ƒ| j d d d d	 d
 d d d d d t ƒ|  j r­ | j d d d d	 d d d d t ƒn  | j d d d d	 d d d d t ƒ| j d d d d	 d d d d d9 ƒ| j d d d d	 d d d d d9 ƒ| 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 rÛ| j d, d d- d	 d. d d/ ƒn | j d0 d d- d	 d d d1 ƒ| j d2 d d3 d	 d d t d d4 ƒ| j d5 d t d	 d d d6 ƒ| j d7 d t d	 d d d8 ƒ|  j	 | ƒ | j
 |  j ƒ \ |  _ } d9 S(:   s‹   
    Process command-line options.  These may be supplemented by subclasses that
    override the method add_product_specific_options.
    t   descriptions.   Command-line installer for %s crystallography s?   software on Mac and Linux systems.  Please note that Mac users sD   may also use the graphical installer, but this is limited to single s   workstations.s   --prefixt   destt   prefixt   actiont   storet   helps%   Directory where %s is to be installedt   defaults   --nproct   nproct   typet   ints'   Number of processors for source installs   --no-guit   no_guit
   store_trues:   Disable building of GUI dependencies (source install only)s   --base-onlyt	   base_onlys%   Only install base libraries and filess   --binaryt   binarys   Use pre-compiled binary installs   --sourcet   sources   Force source installations   --openmpt   openmps%   Enable OpenMP compilation if possibles   --no-optt   no_opts'   Disable optimization during compilations   --no-appt   no_apps)   Disable generation of Mac app launcher(s)s   --debugt   debugs$   Turn on debugging during compilations   --no-compactt   compactt   store_falses7   Don't remove unnecessary files such as compiled sourcess	   --compacts?   Remove unnecessary files such as compiled sources to save spaces   --try-unsupportedt   try_unsupporteds.   Attempt source install on unsupported platforms   --python_statics<   Compile Python as static executable and library (Linux only)s
   --makedirss6   Create installation path prefix if not already presentN(   R   t   product_namet
   add_optiont   destinationt   NPROC_DEFAULTt   include_gui_packagest   Falset   Nonet   remove_sources_defaultt   add_product_specific_optionst
   parse_argsR   t   options(   R   t   parserR   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyR   ‚   sP    
	
	
c         C   s   t  ƒ  S(   sÕ   
    Determine the mtype string.  The four pre-defined mtypes will be detected
    automatically (with Linux kernel 3.x treated as 2.6), but additional mtypes
    can be used if this method is re-implemented.
    (   t   machine_type(   R   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyRA   ³   s    c         C   sæ  |  j  } |  j ƒ  |  _ |  j ƒ  |  _ |  j d  k	 s< t ‚ t j |  j	 d ƒ |  _
 t j |  j	 d ƒ |  _ t j |  j	 d ƒ |  _ | d i |  j d 6|  j d 6|  j d 6t ƒ  d 6t j d	 d
 6|  j j d 6|  j j d 6IJ|  j d  k r t d ƒ ‚ nF |  j |  j k rF|  j j rFt d i |  j d 6|  j d 6ƒ ‚ n  t j |  j j ƒ s�|  j j rjq�t d d |  j j d d ƒ ‚ n  t |  _ |  j r´|  j j |  _ n  |  j t j d |  j <|  j	 t j d |  j <d  S(   NR-   t   bundlest   dependenciessÎ  
  ==========================================================================
                        %(product)s Installation

                        version: %(version)s
                   machine type: %(mtype)s
                     OS version: %(os)s
                     user shell: %(shell)s
                    destination: %(dest)s
                # of processors: %(nproc)s
  =========================================================================
  t   productt   versiont   mtypet   ost   SHELLt   shellR    R&   s   Machine type not recognizedsÏ   
  %(mtype)s is not a supported platform, installation aborted
    use the --try-unsupported option to attempt installation on this platform
    use the --no-gui option for a core %(product)s installation
  s&   Destination directory does not exist:
s     %ss@   If you are sure you want to install here, re-run with the extra
s   argument --makedirs.s   %s_MTYPEs   %s_INSTALLER(   R   RA   RF   t   get_versionRE   R;   t   AssertionErrort   opt   joint   installer_dirt   src_dirt
   bundle_dirt   dependencies_dirR5   t   get_os_versionRG   t   environR?   R!   R&   R   t   supported_mtypesR4   t   isdirt   makedirsR:   t   flag_build_guiR9   R)   (   R   R   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyR   »   s@    	


$		c   
      C   sí  |  j  } d } } t j |  j ƒ r. t } n  t j |  j d ƒ } t j |  j d |  j	 |  j
 f ƒ |  _ t j |  j d |  j	 |  j
 f ƒ |  _ |  j
 |  _ t j |  j ƒ rº t } n‘ |  j
 j d ƒ rKt j d d |  j
 ƒ } t j | d |  j	 | f ƒ } t j | ƒ rK| d IJ| d |  j IJ| |  _ t } | |  _ qKn  | s×| d	 |  j
 IJt j | ƒ rÆ| d
 IJx% t j | ƒ D] } | d | IJq‹W| d IJ| t j |  j ƒ IJq×| r×d GHq×n  | rû| rût d |  j
 ƒ ‚ nB | r=| r=|  j j r&| d IJt } q=| d d IJt } n  | rš|  j ršt j d k ršt d d ƒ } t j d | ƒ }	 |	 d k	 ršt |	 ƒ ‚ qšn  | |  _ | |  _  t j |  j d |  j	 |  j f ƒ |  _ t j |  j ƒ |  _! t S(   sž   
    Inspect the installer contents to determine whether this is a binary
    distribution or source packages.  If both are present, binary is preferred.
    RB   s   base-%s-%s.tar.gzs   bundle-%s-%s.tar.gzt   x86_64s   -x86_64t    s,   This is the 32-bit build for your platform- s+   automatically switching machine type to %s.s   No binary bundles found for %ss   bundles directory contents:s     %ss	   expected:s-   Okay, this must be the source-only installer.s+   no binary installer found for %s, aborting.s   performing source installations0   source and binary both available, defaulting to s   binary install
t   darwins	   /dev/nullt   wt   logN("   R   R;   RL   RU   RO   t   TrueRM   RN   RP   RE   RF   t   base_bundlet   bundle_filet   alias_mtypet   isfilet   endswitht   ret   subRG   t   listdirt   basenameR   R?   R-   R:   RW   t   syst   platformt   openR   t!   check_wxpython_build_dependenciest   source_installR   t   base_binary_install(
   R   R   Rk   R   RP   t   mtype_32bitt   bundle32t	   file_namet   tmp_logt   error(    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyR   î   sp    	
		

	


						c         C   s  |  j  } t j ƒ  d j d ƒ d } t j |  j d |  j | ƒ |  _ t j	 |  j ƒ sl t j
 |  j ƒ n  t j |  j j d |  j |  j f ƒ |  _ t j	 |  j ƒ sy t j
 |  j ƒ WqVt k
 r} | j d k r÷ t d |  j j ƒ ‚ qt d |  j | f ƒ ‚ qVXn? | d	 |  j IJt j |  j t j ƒ sVt d |  j ƒ ‚ n  t j |  j d
 ƒ |  _ t j |  j d ƒ |  _ t j |  j ƒ s«t j
 |  j ƒ n  t j |  j ƒ sÐt j
 |  j ƒ n  |  j t j d |  j <|  j t j d |  j <d  S(   Ni   t   .i    t   install_tmps   %s-%si   s'   you do not have write permissions to %ss   can't create '%s': %ss/   Warning: %s already exists, will be overwrittent   buildt   bases   %s_LOCs   %s_BUILD(   R   RG   t   unamet   splitRL   RM   RN   RF   t   tmp_dirRU   RV   R?   R!   t   dest_dir_prefixRE   t   dest_dirt   OSErrort   errnoR   t   accesst   W_OKt	   build_dirt   base_dirt   existsRS   R5   (   R   R   t   hostnamet   e(    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyR   .  s:    	 
c         C   sM   |  j  } | d i |  j d 6|  j d 6|  j d 6|  j d 6|  j d 6IJd  S(   Ns  
%(product)s installation target directory <%(product)s_LOC> set to:
   %(dest_dir)s
%(product)s installation source directory set to:
   %(inst_dir)s
%(product)s installation build directory set to:
   %(build_dir)s
%(product)s temporary build directory set to:
   %(tmp_dir)s
RD   Rz   R   t   inst_dirRx   (   R   R5   Rz   R   RN   Rx   (   R   R   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyt   show_installation_pathsP  s    		


c         C   sÀ  |  j  } |  j ƒ  |  j rn t j |  j ƒ | d IJt |  j d | d t d t	 d t	 ƒt j |  j
 ƒ nÓ d |  j d |  j d |  j d |  j d	 |  j j d
 g |  j } t j |  j t j ƒ } |  j ró t j | ƒ ró | j d ƒ n  |  j j r| j d ƒ n  |  j j s+| j d ƒ n  t j d | d | ƒ t j |  j d d ƒ } t j | ƒ snt ‚ | d IJ| d IJ| d IJ| d IJ| d IJ| d d IJ| d IJ| d |  j IJ|  j j rê| d |  j IJd  Sxý |  j  D]ò } t j |  j | d ƒ } t j | ƒ s5t! d | ƒ ‚ n  | d t j" | ƒ IJt j |  j d | ƒ } t# | d ƒ } t j |  j ƒ t | d | d t d t	 d d | k ƒ| j$ ƒ  | j% d ƒ rôt j& d ƒ sæt! d ƒ ‚ qæqôqôWt j |  j d  ƒ }	 t j |	 ƒ r0t j' |	 t j |  j d! ƒ ƒ n  |  j( d | ƒ t j |  j d" |  j) ƒ } t# | d ƒ } t j |  j* ƒ t j d# ƒ ršt j+ d# ƒ n  t j |  j d d$ d% ƒ }
 d& d' |  j, d( |  j* g |  j- } |  j j. rõ| j d) ƒ n  |  j j r%| d* |  j I| j/ d+ d, ƒ nQ |  j j0 rU| d- |  j I| j/ d+ d. ƒ n! | d/ |  j I| j/ d+ d0 ƒ t1 | |
 g | d | ƒ| d1 IJd2 g } t j2 j3 d3 ƒ d> k rË| j d4 ƒ n  | j5 d5 t6 |  j j ƒ g ƒ | d6 |  j It j |  j* d d7 ƒ } t j | ƒ s(t ‚ t1 | g | d | ƒ| d8 IJ|  j7 d | ƒ | d IJd9 |  j } | d: t8 | ƒ d; IJ| d< | d= IJ| d: t8 | ƒ d; IJ| d IJd  S(?   Ns    Using precompiled base bundle...R\   t   verboset   change_ownershipt   check_output_paths   --build_dir=%ss   --tmp_dir=%ss   --pkg_dir=%ss
   --nproc=%ss   --no-downloads   --guis   --debugs   --python-sharedR   t   bint   pythonRY   s   ******************************s   * BASE INSTALLATION COMPLETE *t   -iP   s   Building core %s componentss3   --base-only was specified, so skipping %s librariess   .tar.gzs   Can't find %ss     unwrapping %s...s   %s.logR[   R   t   cctbx_projects$   Directory 'cctbx_project' not found!t   TAGt   cctbx_bundle_TAGs   compile_%s.logt   libtbx_refresh_is_completedt   libtbxs   configure.pys   --scan_boosts   --command_version_suffix=%ss    --current_working_directory="%s"s    --enable-openmp-if-possible=Trues+   configuring %s components with debugging...i    s   --build=debugs1   configuring %s components with no optimization...s   --build=quicks.   configuring %s components with optimization...s   --build=releaset   okRr   t   LIBTBX_FULL_TESTINGs   -ks   -js4   compiling %s components - this might take an hour...s   libtbx.sconst   dones   %s INSTALLATION COMPLETER   i   s   * s    *(   NRY   (9   R   R…   Rl   RG   t   chdirRz   t   untarR^   R]   R:   RN   Rx   RO   RQ   R?   R&   t   base_package_optionsRL   RM   R   t   WXPYTHON_PKGRW   Ra   t   appendR1   t   python_staticR   R   R€   RK   R5   R+   t   source_packagest   RuntimeErrorRf   Ri   t   closet
   startswithRU   t   renamet%   product_specific_setup_before_compileRy   R   t   removeRE   t   configure_modulesR.   t   insertR/   t   callRS   t   getR;   t   extendt   strt   product_specific_source_installt   len(   R   R   t	   base_argst   wxpython_filet
   python_bint   pkg_namet   pkg_filet   log_fileR\   t   tag_filet   config_patht   config_argst
   scons_argst	   scons_bint   msg(    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyR   d  sÈ    	
	





	







"	





	


c      
   C   s¦  |  j  } t j |  j d ƒ } t j |  j d ƒ } t | d ƒ } t j | ƒ ru | d It j | ƒ | d IJn  t j	 | ƒ | d IJt j |  j
 d ƒ } t j | ƒ rÔ | d It j | ƒ | d IJn  t j |  j ƒ r| d	 It j |  j ƒ | d IJn  | d
 It j |  j ƒ t |  j d | d t d t d t ƒ|  j r}t |  j d | d t d t d t ƒn  t j | ƒ s t j |  j ƒ r¼t d | |  j f ƒ ‚ n  t j d k rêt j |  j d ƒ t j d <n  | d IJ|  j d | ƒ t j |  j
 ƒ | d |  j I|  j d | ƒ | d IJ| d IJd |  j } | d t | ƒ d IJ| d | d IJ| d t | ƒ d IJ| d IJd S(   sC   
    Unpackage the binary bundle in the destination directory.
    R,   s
   binary.logR[   s(   removing existing temporary directory...R‘   s!   finding existing installations...t   libs%   Removing out-of-date lib directory...s/   Removing out-of-date base software directory...s    Installing new binary package...R\   R†   R‡   Rˆ   s*   One or more missing directories:
  %s
  %sRZ   t   LD_LIBRARY_PATHs   Configuring %s components...RY   s   %s BINARY INSTALLATION COMPLETER   i   s   * s    *N(   R   RL   RM   Rx   Ri   R�   t   shutilt   rmtreeRG   RV   R   R€   R”   Rz   R•   R_   R]   R:   Rl   R^   RU   R›   Rg   Rh   RS   t   product_specific_binary_installR5   t   reconfigureR¨   (   R   R   t   tmp_bin_dirR®   R\   t   lib_dirR´   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyR   Ù  sV    	




	#


c         C   sz   t  j |  j ƒ d |  j d |  j d |  j g |  j } y t d | d | ƒ Wn! t k
 ru t d d ƒ ‚ n Xd S(	   sM   
    Run libtbx/configure.py to configure the build in the new location.
    s   "%s/bin/python"s&   "%s/cctbx_project/libtbx/configure.py"s   --current_working_directory=%sR   R\   s1   configuration step incomplete!  See the log file s   for detailed error messages.N(	   RG   R”   R   R€   Rz   R¡   R£   R›   R   (   R   R\   R   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyRº     s    


c      	   C   sö  |  j  } | d IJ| d d IJ| d |  j IJt j |  j d ƒ } | d | IJt | d ƒ } |  j r¾ t j d k r¾ t j |  j	 d	 d
 ƒ t
 j d <t j d d |  j	 g d | ƒ n  | d |  j IJ| d IJt j |  j d |  j ƒ } t j | ƒ rt
 j | ƒ n  d j d |  j |  j	 f d |  j |  j f d |  j d |  j |  j f g |  j ƒ  ƒ } d j |  j ƒ  ƒ } d |  j d |  j d |  j d d g } |  j sÈ| j d ƒ n  t j d | d | d | d | ƒ t j | ƒ sÿt ‚ |  j | ƒ | d |  j IJt
 j |  j ƒ t j d ƒ rLt
 j d ƒ n  |  j d | ƒ t
 j |  j ƒ t j d  ƒ s�t ‚ t j |  j d! ƒ } d" | t
 j d# f t
 j d# <| d$ It
 j |  j	 ƒ t d d% g d | ƒ | d& IJx` d' d( d) d* d+ g D]I }	 t j |  j |	 ƒ }
 t j |
 ƒ rt  |
 t j |  j	 |	 ƒ ƒ qqWt j d k r¿t! |  j" ƒ d, k r¿|  j# j$ r¿t
 j |  j ƒ | d- Ix |  j" D]} d. | d/ | |  j f d0 |  j	 g } |  j d1 k rñ| j d2 ƒ n  y t d | d | ƒ Wn1 t% k
 r;} d GHd3 GHd4 t& | ƒ GHd5 GHq¦Xt j |  j	 d6 | |  j f ƒ } t j | ƒ s€| d7 IJd: } q¦| d& IJd8 t
 j k r¦t d d9 |  j	 g d | ƒ q¦q¦Wn  |  j# j( rÛ|  j) | ƒ n  |  j* | ƒ |  j+ ƒ  d: S(;   sQ   
    Set up dispatchers and assorted shell scripts, create app bundles, etc.
    RY   R   iH   s   FINALIZING %s INSTALLATIONs   install_finalize.logs     log file is %sR[   RZ   Ru   Rµ   R¶   R   s   --build_dir=%sR   s3   generating %s environment additions for dispatcherss   dispatcher_include_%s.shs   
s   export %s="%s"s   export %s_VERSION=%ss   export %s_ENVIRONMENT=1s   export %s_MTYPE=%ss   --base_dir=%ss   --suffix=%ss   --gtk_version=2.10.0s   --quiets   --ignore_missing_dirst   prologuet   epilogues   configuring %s components...R�   R\   s   setpaths.shR‰   s   %s:%st   PATHs   precompiling .py files...s   libtbx.py_compile_allR‘   t   CHANGESt   LICENSEt   READMEs
   README-DEVt   SOURCESi    s   Generating Mac app launchers...s   libtbx.create_mac_apps   --app_name=%s-%ss	   --dest=%ss   mac-intel-osx-x86_64s   --alias_builds     ERROR:s     s$     installation will continue anyway.s	   %s-%s.apps    failed.t
   SSH_CLIENTRi   N(,   R   R5   RL   RM   Rx   Ri   RW   Rg   Rh   Rz   RG   RS   R   t   runR   Ry   Ra   R    RE   RF   t$   product_specific_dispatcher_prologuet$   product_specific_dispatcher_epilogueR€   R˜   R   RK   t   write_environment_filesR”   R�   Rº   R£   RN   t	   copy_fileR¨   t	   make_appsR?   R0   R›   R¦   R;   R2   t   reduce_installation_sizet!   product_specific_finalize_installt   display_final_message(   R   R   t   log_pathR\   t
   dispatcherR½   R¾   t   dispatcher_optst   bin_dirRo   t   src_filet   app_nameR   Rƒ   t   app_file(    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyR      s¬    	







			

#$
	
	
&c         C   sw  | d |  j  IJt j |  j d |  j ƒ } | d |  j |  j f IJt | d ƒ } | j d ƒ | j d ƒ | j d |  j  |  j f ƒ | j d |  j  |  j f ƒ | j d	 |  j  ƒ | j ƒ  t j |  j d
 |  j ƒ } | d | IJt | d ƒ } | j d ƒ | j d ƒ | j d |  j  |  j f ƒ | j d |  j  |  j f ƒ | j d |  j  ƒ | j ƒ  d S(   s  
    Generate shell scripts in the top-level installation directory that can
    be used to set up the user environment to run the software.  This is
    implemented as a separate method because some products (e.g. Phenix) may
    have their own needs.
    s(   generating %s environment setup scripts:s
   %s_env.cshs     csh: %s/%s_env.cshR[   s   #!/bin/csh -f
s   #
s   setenv %s "%s"
s   setenv %s_VERSION %s
s   source $%s/build/setpaths.csh
s	   %s_env.shs	     sh:  %ss
   #!/bin/sh
s   export %s="%s"
s   export %s_VERSION=%s
s   . $%s/build/setpaths.sh
N(	   R5   RL   RM   Rz   Ry   Ri   t   writeRE   Rœ   (   R   R   t   csh_filet   env_csht   sh_filet   env_sh(    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyRÈ   �  s(    

c         C   sA   t  j |  j d ƒ } t  j | ƒ r: t | ƒ j ƒ  j ƒ  St ƒ  S(   sÏ   
    Determine the version suffix (if any) for the destination directory.  This
    must be implemented by subclasses unless a file named VERSION is present
    at the top level of the installer folder.
    t   VERSION(   RL   RM   RN   Ra   Ri   t   readt   stript   NotImplementedError(   R   t   version_file(    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyRJ   «  s    c         C   s  | d Id d d d d g } d } x¸ t  j |  j ƒ D]¤ \ } } } x’ | D]Š } x� | D]y } | j | ƒ r[ t j | | ƒ }	 y t  j |	 ƒ Wn1 t k
 rÆ }
 | d |	 IJ| t |
 ƒ IJqÔ X| d	 7} q[ q[ WqN Wq8 W|  j	 | ƒ } | d k	 r| | 7} n  | d
 | IJd S(   s  
    Remove all files not required for program execution to save disk space,
    such as any C++ sources.  This can potentially save well over 100MB and is
    recommended for purely user-facing packages, but may make it more difficult
    to use packages for development purposes.
    s2   Removing unnecessary files to reduce disk usage...s   .cpps   .ccs   .hpps   .hs   .hhi    s     WARNING: error removing %si   s   %d files deletedN(   RG   t   walkRz   Rb   RL   RM   R    t	   ExceptionR¦   t)   produce_specific_reduce_installation_sizeR;   (   R   R   t   remove_extensionst	   n_deletedt   dirnamet   dirnamest	   filenamesRo   t   extt	   full_pathRƒ   t   n_deleted_other(    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyRË   ¶  s$    
"c         C   s   d S(   sG   
    Add command-line options specific to the distributed package.
    N(    (   R   R@   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyR=   Ô  s    c         C   s   d S(   sd   
    Perform additional actions required for the binary installation of a
    specific product.
    N(    (   R   R\   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyR¹   Ú  s    c         C   s   d S(   sR   
    Perform any necessary modifications to the sources prior to compilation.
    N(    (   R   R\   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyRŸ   á  s    c         C   s   d S(   s0   
    Build additional sources, e.g. Rosetta
    N(    (   R   R\   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyR§   ç  s    c         C   s   g  S(   sU   
    Environment modifications to be included near the start of the dispatchers.
    (    (   R   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyRÆ   í  s    c         C   s   g  S(   sQ   
    Environment modifications to be included at the end of the dispatchers.
    (    (   R   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyRÇ   ó  s    c         C   s   d S(   sI   
    Additional installation setup, file cleanup, more add-ons, etc.
    N(    (   R   R\   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyRÌ   ù  s    c         C   s   d S(   sV   
    Remove unused files specific to this product, and return the number deleted.
    i    (    (   R   R\   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyRá   ÿ  s    c         C   s   d S(   s+   
    Final instructions for user, etc.
    N(    (   R   (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyRÍ     s    N(-   R	   R
   t   __doc__R5   R7   Ry   RG   RS   R¤   R;   RN   R]   R9   R:   R<   R–   Rš   R¡   RÊ   RT   Rg   t   stdoutR   R   RA   R   R   R   R…   R   R   Rº   R   RÈ   RJ   RË   R=   R¹   RŸ   R§   RÆ   RÇ   RÌ   Rá   RÍ   (    (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyR   U   sL   			1		3	@	"		u	7		m											(    Rê   t
   __future__R    t   optparseR   t   os.patht   pathRL   R·   t   timeRG   Rg   t   multiprocessingt   mint	   cpu_countR8   Rà   t   abspathRä   t   __file__t   libtbx_pathR˜   t   libtbx.auto_buildR   R   R   R   R   t!   libtbx.auto_build.installer_utilsR   t   objectR   (    (    (    sT   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/install_distribution.pyt   <module>7   s.   
!
