Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [root@eva03 bin]# cat install.py
- #
- # TOP-LEVEL INSTALLER SCRIPT FOR MAC AND LINUX
- #
- # Invoked by indirectly by make_dist() in libtbx\auto_build\create_installer.py
- # when generating zipped distribution on Windows
- #
- # This subclasses the base installer class included in CCTBX in this file:
- # libtbx/auto_build/install_distribution.py
- #
- from __future__ import division
- import shutil
- import os.path
- op = 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
- from libtbx.auto_build.installer_utils import *
- from libtbx.auto_build import bootstrap
- class installer (install_distribution.installer) :
- product_name = "Phenix"
- dest_dir_prefix = "phenix"
- make_apps = ["phenix"]
- #"phenix.data_viewer", "phenix.image_viewer", #"phenix.reel"
- configure_modules = ["phenix", "phaser", "solve_resolve", "labelit", "dials", "xia2", "iota", "prime"]
- include_gui_packages = True
- base_package_options = ["--all"]
- installer_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- base_modules = []
- modules = [
- # hot
- 'annlib',
- 'boost',
- 'scons',
- 'ccp4io',
- # base
- 'cbflib',
- 'cctbx_project',
- 'gui_resources',
- 'chem_data',
- 'ccp4io_adaptbx',
- 'annlib_adaptbx',
- 'tntbx',
- 'clipper',
- # phenix hot
- 'phaser',
- 'phaser_regression',
- 'reduce',
- 'probe',
- 'king',
- 'suitename',
- # phenix
- 'phenix',
- 'phenix_regression',
- 'phenix_html',
- 'phenix_examples',
- 'labelit',
- 'Plex',
- 'PyQuante',
- 'elbow',
- 'ksdssp',
- 'pulchra',
- 'solve_resolve',
- 'reel',
- 'gui_resources',
- 'opt_resources',
- 'muscle',
- "amber_adaptbx",
- "dials",
- "xia2",
- "iota",
- "prime",
- ]
- if sys.platform == "win32": # exclude some modules on Windows if necessary
- configure_modules = list( set(configure_modules) - set(bootstrap.windows_remove_list) )
- modules = list( set(modules) - set(bootstrap.windows_remove_list) )
- def add_product_specific_options (self, parser) :
- parser.add_option("--rosetta", default=False, action="store_true",
- help="Also compile Rosetta with Phenix extensions")
- parser.add_option("--without-pymol", default=False, action="store_true",
- help="Disable installation of PyMOL executable")
- def product_specific_setup_before_compile (self, log) :
- phaser_version_cc = op.join(self.modules_dir, "phaser", "Version.cc")
- if not op.isfile(phaser_version_cc) :
- open(phaser_version_cc, "w").write("")
- def product_specific_source_install (self, log) :
- out = self.out
- if (self.options.rosetta) :
- print >> out, "Attempting to compile Rosetta with Python embedded..."
- rosetta_build_bin = op.join(self.build_dir, "bin",
- "rosetta.build_phenix_interface")
- try :
- log = open(op.join(self.tmp_dir, "compile_rosetta.log"), "w")
- call([rosetta_build_bin, "nproc=%s" % self.options.nproc], log=log)
- except RuntimeError :
- print >> out, ""
- print >> out, "Error: Rosetta build failed. Will continue with normal"
- print >> out, "Phenix installation. You can view the command output"
- print >> out, "here:"
- print >> out, op.join(self.tmp_dir, "compile_rosetta.log")
- print >> out, ""
- else :
- print >> out, " Rosetta compiled successfully."
- print >> out, ""
- #if (not self.options.without_pymol) :
- # self.install_pymol(out=out)
- def product_specific_dispatcher_epilogue (self) :
- if sys.platform == "win32":
- return [] # QuantumBio is only available on Linux
- return [
- # XXX QuantumBio environment variables
- """if [ ! -z "$QB_PYTHONPATH" ]; then""",
- """ export PYTHONPATH=$PYTHONPATH:$QB_PYTHONPATH""",
- """fi""",
- """if [ ! -z "$QB_LD_LIBRARY_PATH" ]; then""",
- """ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$QB_LD_LIBRARY_PATH""",
- """fi""",
- """if [ ! -z "$QB_DYLD_LIBRARY_PATH" ]; then""",
- """ export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$QB_DYLD_LIBRARY_PATH""",
- """fi""",
- # XXX end of QBio stuff
- """if [ "$PHENIX_MTYPE" != "mac-ppc-osx" ] && \\""",
- """ [ "$PHENIX_MTYPE" != "mac-intel-osx" ] && \\""",
- """ [ "$PHENIX_MTYPE" != "mac-intel-osx-x86_64" ]; then""",
- """ export PYMOL_PATH=$PHENIX/pymol""",
- """fi""",
- ]
- def product_specific_finalize_install (self, log) :
- out = self.out
- # solve_resolve license
- license_file = os.path.join(self.modules_dir, "solve_resolve", "ext_ref_files", "solve2.access")
- f = open(license_file, "w")
- print >> out, "Generating SOLVE/RESOLVE license file..."
- f.write("Access code for solve for PHENIX users\n")
- f.write("31087535G5\n")
- f.write("\n")
- f.close()
- # rebuild docs
- print >> out, "Rebuilding HTML documentation..."
- try:
- call([os.path.join(self.build_dir, 'bin', 'phenix_html.rebuild_docs')], log=log)
- except RuntimeError:
- print >> out, "Error rebuilding documentation!"
- # generate rotarama pickle files
- rotarama_dir = op.join(self.modules_dir, "chem_data", "rotarama_data")
- os.chdir(rotarama_dir)
- print >> out, "Creating rotamer/Ramachandran database files...",
- call([os.path.join(self.build_dir, 'bin', 'mmtbx.rebuild_rotarama_cache')], log=log)
- no_update_file = op.join(rotarama_dir, "NO_UPDATE")
- open(no_update_file, "w").write("1")
- print >> out, "ok"
- # verify monomer library
- print >> out, "Checking for monomer library files...",
- try :
- call([os.path.join(self.build_dir, 'bin', 'mmtbx.verify_mon_lib_data')], log=log)
- except RuntimeError :
- raise InstallerError("Incomplete monomer library installation! "+
- "This usually indicates a corrupted installer; please "+
- "try downloading again and re-installing.")
- print >> out, "ok"
- if (not self.options.without_pymol) :
- self.setup_pymol(out=out)
- def product_specific_reduce_installation_size (self, out) :
- # remove CABLAM raw text files (unnecessary since we have pickles)
- cablam_dir = op.join(self.modules_dir, "chem_data", "cablam_data")
- for file_name in os.listdir(cablam_dir) :
- if file_name.endswith(".stat") :
- full_path = op.join(cablam_dir, file_name)
- os.remove(full_path)
- # top-level directories that we don't need
- for dir_name in ["phenix_regression", "phenix_html"] :
- full_path = op.join(self.modules_dir, dir_name)
- if op.isdir(full_path) :
- shutil.rmtree(full_path)
- # chem_data stuff
- lig_lib_dir = op.join(self.modules_dir, "chem_data", "ligand_lib")
- for file_name in lig_lib_dir :
- if file_name.startswith("PDB.") :
- full_path = op.join(lig_lib_dir, file_name)
- os.remove(full_path)
- rotarama_dir = op.join(self.modules_dir, "chem_data", "rotarama_data")
- for file_name in os.listdir(rotarama_dir) :
- if ((file_name.endswith(".data")) and
- (not file_name.startswith("rama500"))) :
- full_path = op.join(rotarama_dir, file_name)
- pkl_file = full_path.replace(".data", ".pickle")
- if op.isfile(pkl_file) :
- os.remove(full_path)
- def install_pymol (self, out) :
- base_bin_dir = op.join(self.base_dir, "bin")
- pymol_dir = op.join(self.installer_dir, "pymol")
- if (not op.isdir(pymol_dir)) :
- print >> out, "PyMOL not available!"
- return False
- print >> out, "Installing PyMOL...",
- try :
- log = open(op.join(self.tmp_dir, "pymol.log"), "w")
- os.chdir(self.dest_dir)
- if (sys.platform == "darwin") :
- pymol_pkg = op.join(pymol_dir, "MacPyMOL.app.tar.gz")
- untar(pymol_pkg, log=log, check_output_path=False)
- else :
- pymol_pkg = op.join(pymol_dir,
- "pymol-0_99rc6-bin-linux-x86-glibc23.tar.gz")
- untar(pymol_pkg, log=log, check_output_path=False)
- except Exception, e :
- print >> out, "failed!"
- print >> out, "Error message:"
- print >> out, " %s" % str(e)
- return False
- print >> out, "ok"
- return True
- # configure an already in-place PyMOL (Linux only)
- def setup_pymol (self, out) :
- base_bin_dir = op.join(self.base_dir, "bin")
- pymol_dir = op.join(self.dest_dir, "pymol")
- if (not op.isdir(pymol_dir)) :
- print >> out, "PyMOL not available!"
- return False
- print >> out, "Creating PyMOL launcher...",
- os.chdir(pymol_dir)
- args = [ "./setup.sh" ]
- log = open(op.join(self.tmp_dir, "pymol_setup.log"), "w")
- call(args=args, log=log)
- shutil.copyfile(op.join(os.getcwd(), "pymol"),
- op.join(base_bin_dir, "pymol"))
- print >> out, "ok"
- return True
- def display_final_message (self) :
- if sys.platform == "win32":# not applicable for the setup.exe installer
- return
- print >> self.out, """
- ==========================================================================
- PHENIX installation complete
- ----------------------------
- You can begin using PHENIX now by setting your environment with the
- 'source' command:
- csh users:
- source %s/phenix_env.csh
- bash users:
- source %s/phenix_env.sh
- To use PHENIX, go to a work directory and type:
- phenix
- You may wish to put the source statement in your .cshrc or .bashrc
- file.
- """%(self.dest_dir, self.dest_dir)
- if (__name__ == "__main__") :
- installer(sys.argv[1:]).install()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement