ó
à™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 d d l Z e j e j e j e ƒ ƒ ƒ Z e e j k r´ e j j e ƒ n  d d l Td d l Td „  Z e d k rñ e e j d ƒ n  d S(	   s  
Script to set up an installer directory tree and copy over most of the
necessary files.  We used to just keep the entire (Phenix) installer in a
separate SVN tree, but this is inconvenient when we have multiple packages
using the same system and also many third-party dependencies which need to be
kept up to date.  Note that this script provides only the bare minimum
functionality for building CCTBX installers, and other distributions will
probably need to perform additional modifications to the installer tree
before it can be tarred.
iÿÿÿÿ(   t   division(   t   OptionParserN(   t   *c         C   sD  t  ƒ  } | j d d d d d d d d t j d	 t j ƒ  ƒ ƒ| 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 t ƒ| j d d d d d d d d t ƒ| j d 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 t	 j
 t d' ƒ ƒ| j d( d d) d d d d* d t	 j
 t d+ ƒ ƒ| j d, d d- d d d d. d d  ƒ| j d/ d d0 d d d d1 d d  ƒ| j d2 d d3 d d d d4 d d  ƒ| j d5 d d6 d d d d7 d d  ƒ| j |  ƒ \ } }  t |  ƒ d8 k s”t ‚ |  d9 } | j d  k r¹| | _ n  | j d  k	 røt	 j | j ƒ sàt ‚ t	 j | j ƒ | _ n  t j | j ƒ d: | | j f } t j | ƒ t j | ƒ t j d; ƒ t j d< ƒ | j sut j d= ƒ t j d> ƒ n  t	 j
 t j ƒ  d< ƒ } t j t t	 j
 | d? ƒ ƒ t | d@ dA ƒt | dB dC ƒt dD dE ƒ j | j ƒ t	 j | j ƒ rt dF dE ƒ j t | j ƒ j ƒ  ƒ n  t	 j | j ƒ rVt dG dE ƒ j t | j ƒ j ƒ  ƒ n  | j sŸdH GHdI GHdH GHt  dJ t	 j
 | j | d> ƒ dK t! j" d | j# dL | j$ p¶| j% p¶| j& dM | j$ pÑ| j' pÑ| j& ƒ t( dJ t	 j
 | j | d= ƒ dK t! j" d | j# dN t) ƒ } t j t	 j
 | j | d= ƒ ƒ | j* d  k rb| dO dP dQ dR ƒ t j+ dP dS ƒ n( t	 j | j* ƒ szt ‚ t, | j* dS ƒ | j- d  k	 rŸdH GHdT GHdH GHg  } xë | j- j. dU ƒ D]Ô } xË | j# D]À }	 t	 j
 |	 | ƒ }
 t	 j
 |	 | dV ƒ } t	 j/ | ƒ r?dW | | f GHt, | | dX ƒ | j0 | ƒ PqÑt	 j1 |
 ƒ rÑdW | |
 f GHt2 |
 ƒ t	 j | dX ƒ s€t ‚ | j0 | ƒ PqÑqÑWqÁWqŸn  t j t	 j
 | j | ƒ ƒ | j d  k	 r
t	 j | j ƒ sât ‚ t dY dE ƒ j t | j ƒ j ƒ  ƒ nÙ g  } | j- d  k	 r4| j- j. dU ƒ } n  g  } | j% sL| j& r\| j0 d ƒ n  | j$ sw| j& sw| j' r‡| j0 d ƒ n  t dY dE ƒ } | j dZ i | d[ 6| j d\ 6| d0 6| d] 6| j% pÐ| j& d 6ƒ | j3 ƒ  t d^ dE ƒ } | j d_ ƒ | j3 ƒ  t j4 d^ ƒ } t j5 d^ | j6 t4 j7 Bt4 j8 Bt4 j9 Bƒ d  S(`   Ns	   --versiont   destt   versiont   actiont   storet   helps   Package versiont   defaults   %Y_%m_%ds   --binaryt   binarys4   Setup for binary installer only (no source packages)s	   --pkg_dirt   pkg_dirst   appends   Directory with source packagess   --basict   basict
   store_trues(   Only include basic prerequisite packagess   --xia2t   xia2s   Include xia2 dependenciess   --dialst   dialss   Include DIALS dependenciess   --guit   guis   Include GUI dependenciess   -as   --allt   alls$   Include all recommended dependenciess   --dests   Destination folders   --readmet   readmes   Readme files   COPYRIGHT_2_0.txts	   --licenset   licenses   License files   LICENSE_2_0.txts   --scriptt   scripts   Final installation scripts	   --modulest   moduless   Local modules to includes   --product_namet   product_names   Name of installed packages   --cctbx_bundlet   cctbx_bundles2   Path to CCTBX installer bundle (if not downloaded)i   iÿÿÿÿs   %s-installer-%st   bint   libt   sourcet   dependenciest   libtbxt   file_exts   .pyct	   file_names   .svnt   VERSIONt   wt   READMEt   LICENSEt    s+   ********** FETCHING DEPENDENCIES **********t   dest_dirt   logt   gui_packagest   dials_packagest
   copy_filest   pkg_names!   cctbx_bundle_for_installer.tar.gzt   pkg_urls(   http://cci.lbl.gov/build/results/currents   cctbx_bundle.tar.gzs&   ********** FETCHING MODULES **********t   ,s   _hot.tar.gzs   using module '%s' from %ss   .tar.gzs   bin/install.pysÒ  import os.path
import sys
libtbx_path = os.path.join(
  os.path.abspath(os.path.dirname(os.path.dirname(__file__))), "lib")
if (not libtbx_path in sys.path) :
  sys.path.append(libtbx_path)
from libtbx.auto_build import install_distribution

class installer (install_distribution.installer) :
  product_name = "%(product)s"
  dest_dir_prefix = "%(pkg)s"
  make_apps = []
  configure_modules = install_distribution.installer.configure_modules + \
    %(modules)s
  include_gui_packages = %(gui)s
  base_package_options = %(baseopts)s
  source_packages = [ "cctbx_bundle" ] + %(modules)s

  installer_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

if (__name__ == "__main__") :
  installer(sys.argv[1:])
t   pkgt   productt   baseoptst   installs²  #!/bin/bash
#
#

UNAME=`uname`
if [ -z "$PYTHON_EXE" ]; then
  PYTHON_EXE='/usr/bin/python'
  if [ -f "/usr/bin/python2.7" ]; then
    PYTHON_EXE='/usr/bin/python2.7'
  elif [ -f "/usr/bin/python2.6" ]; then
    PYTHON_EXE='/usr/bin/python2.6'
  elif [ -f "/usr/bin/python2.5" ]; then
    PYTHON_EXE='/usr/bin/python2.5'
  elif [ -f "/usr/bin/python2" ]; then
    PYTHON_EXE='/usr/bin/python2'
  fi
fi
$PYTHON_EXE ./bin/install.py $@
(:   R   t
   add_optiont   timet   strftimet	   localtimet   Falset   Nonet   ost   getcwdt   opt   joint   libtbx_patht
   parse_argst   lent   AssertionErrorR   R   t   isfilet   abspatht   chdirR   R   t   mkdirR	   t   shutilt   copytreet   find_and_delete_filest   opent   writeR   t   readR   t   fetch_all_dependenciest   syst   stdoutR
   R   R   R   R   t   fetch_packagest   TrueR   t   renamet	   copy_fileR   t   splitt   existsR   t   isdirt   archive_distt   closet   statt   chmodt   st_modet   S_IXUSRt   S_IXGRPt   S_IXOTH(   t   argst   parsert   optionst   package_namet   installer_dirt   lib_dirt   fetch_packaget   have_modulest   module_namet   pkg_dirt   dist_dirt   tarfilet   modules_listt   base_package_optionst   ft   st(    (    sO   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/setup_installer.pyt   run   sø    	
	((						
(

t   __main__i   (   t   __doc__t
   __future__R    t   optparseR   t   os.patht   pathR8   RB   R1   RT   R6   RI   R?   t   dirnamet   __file__R:   R   t   installer_utilst   package_defsRj   t   __name__t   argv(    (    (    sO   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/setup_installer.pyt   <module>   s    !

	°