Advertisement
murpholinox

installation script

Feb 13th, 2017
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.61 KB | None | 0 0
  1. [root@eva03 bin]# cat install.py
  2. #
  3. # TOP-LEVEL INSTALLER SCRIPT FOR MAC AND LINUX
  4. #
  5. # Invoked by indirectly by make_dist() in libtbx\auto_build\create_installer.py
  6. # when generating zipped distribution on Windows
  7. #
  8. # This subclasses the base installer class included in CCTBX in this file:
  9. # libtbx/auto_build/install_distribution.py
  10. #
  11.  
  12. from __future__ import division
  13. import shutil
  14. import os.path
  15. op = os.path
  16. import sys
  17. libtbx_path = os.path.join(
  18. os.path.abspath(os.path.dirname(os.path.dirname(__file__))), "lib")
  19. if (not libtbx_path in sys.path) :
  20. sys.path.append(libtbx_path)
  21. from libtbx.auto_build import install_distribution
  22. from libtbx.auto_build.installer_utils import *
  23. from libtbx.auto_build import bootstrap
  24.  
  25. class installer (install_distribution.installer) :
  26. product_name = "Phenix"
  27. dest_dir_prefix = "phenix"
  28. make_apps = ["phenix"]
  29. #"phenix.data_viewer", "phenix.image_viewer", #"phenix.reel"
  30. configure_modules = ["phenix", "phaser", "solve_resolve", "labelit", "dials", "xia2", "iota", "prime"]
  31. include_gui_packages = True
  32. base_package_options = ["--all"]
  33. installer_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  34. base_modules = []
  35. modules = [
  36. # hot
  37. 'annlib',
  38. 'boost',
  39. 'scons',
  40. 'ccp4io',
  41. # base
  42. 'cbflib',
  43. 'cctbx_project',
  44. 'gui_resources',
  45. 'chem_data',
  46. 'ccp4io_adaptbx',
  47. 'annlib_adaptbx',
  48. 'tntbx',
  49. 'clipper',
  50. # phenix hot
  51. 'phaser',
  52. 'phaser_regression',
  53. 'reduce',
  54. 'probe',
  55. 'king',
  56. 'suitename',
  57. # phenix
  58. 'phenix',
  59. 'phenix_regression',
  60. 'phenix_html',
  61. 'phenix_examples',
  62. 'labelit',
  63. 'Plex',
  64. 'PyQuante',
  65. 'elbow',
  66. 'ksdssp',
  67. 'pulchra',
  68. 'solve_resolve',
  69. 'reel',
  70. 'gui_resources',
  71. 'opt_resources',
  72. 'muscle',
  73. "amber_adaptbx",
  74. "dials",
  75. "xia2",
  76. "iota",
  77. "prime",
  78. ]
  79.  
  80. if sys.platform == "win32": # exclude some modules on Windows if necessary
  81. configure_modules = list( set(configure_modules) - set(bootstrap.windows_remove_list) )
  82. modules = list( set(modules) - set(bootstrap.windows_remove_list) )
  83.  
  84. def add_product_specific_options (self, parser) :
  85. parser.add_option("--rosetta", default=False, action="store_true",
  86. help="Also compile Rosetta with Phenix extensions")
  87. parser.add_option("--without-pymol", default=False, action="store_true",
  88. help="Disable installation of PyMOL executable")
  89.  
  90. def product_specific_setup_before_compile (self, log) :
  91. phaser_version_cc = op.join(self.modules_dir, "phaser", "Version.cc")
  92. if not op.isfile(phaser_version_cc) :
  93. open(phaser_version_cc, "w").write("")
  94.  
  95. def product_specific_source_install (self, log) :
  96. out = self.out
  97. if (self.options.rosetta) :
  98. print >> out, "Attempting to compile Rosetta with Python embedded..."
  99. rosetta_build_bin = op.join(self.build_dir, "bin",
  100. "rosetta.build_phenix_interface")
  101. try :
  102. log = open(op.join(self.tmp_dir, "compile_rosetta.log"), "w")
  103. call([rosetta_build_bin, "nproc=%s" % self.options.nproc], log=log)
  104. except RuntimeError :
  105. print >> out, ""
  106. print >> out, "Error: Rosetta build failed. Will continue with normal"
  107. print >> out, "Phenix installation. You can view the command output"
  108. print >> out, "here:"
  109. print >> out, op.join(self.tmp_dir, "compile_rosetta.log")
  110. print >> out, ""
  111. else :
  112. print >> out, " Rosetta compiled successfully."
  113. print >> out, ""
  114. #if (not self.options.without_pymol) :
  115. # self.install_pymol(out=out)
  116.  
  117. def product_specific_dispatcher_epilogue (self) :
  118. if sys.platform == "win32":
  119. return [] # QuantumBio is only available on Linux
  120. return [
  121. # XXX QuantumBio environment variables
  122. """if [ ! -z "$QB_PYTHONPATH" ]; then""",
  123. """ export PYTHONPATH=$PYTHONPATH:$QB_PYTHONPATH""",
  124. """fi""",
  125. """if [ ! -z "$QB_LD_LIBRARY_PATH" ]; then""",
  126. """ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$QB_LD_LIBRARY_PATH""",
  127. """fi""",
  128. """if [ ! -z "$QB_DYLD_LIBRARY_PATH" ]; then""",
  129. """ export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$QB_DYLD_LIBRARY_PATH""",
  130. """fi""",
  131. # XXX end of QBio stuff
  132. """if [ "$PHENIX_MTYPE" != "mac-ppc-osx" ] && \\""",
  133. """ [ "$PHENIX_MTYPE" != "mac-intel-osx" ] && \\""",
  134. """ [ "$PHENIX_MTYPE" != "mac-intel-osx-x86_64" ]; then""",
  135. """ export PYMOL_PATH=$PHENIX/pymol""",
  136. """fi""",
  137. ]
  138.  
  139. def product_specific_finalize_install (self, log) :
  140. out = self.out
  141.  
  142. # solve_resolve license
  143. license_file = os.path.join(self.modules_dir, "solve_resolve", "ext_ref_files", "solve2.access")
  144. f = open(license_file, "w")
  145. print >> out, "Generating SOLVE/RESOLVE license file..."
  146. f.write("Access code for solve for PHENIX users\n")
  147. f.write("31087535G5\n")
  148. f.write("\n")
  149. f.close()
  150.  
  151. # rebuild docs
  152. print >> out, "Rebuilding HTML documentation..."
  153. try:
  154. call([os.path.join(self.build_dir, 'bin', 'phenix_html.rebuild_docs')], log=log)
  155. except RuntimeError:
  156. print >> out, "Error rebuilding documentation!"
  157.  
  158. # generate rotarama pickle files
  159. rotarama_dir = op.join(self.modules_dir, "chem_data", "rotarama_data")
  160. os.chdir(rotarama_dir)
  161. print >> out, "Creating rotamer/Ramachandran database files...",
  162. call([os.path.join(self.build_dir, 'bin', 'mmtbx.rebuild_rotarama_cache')], log=log)
  163. no_update_file = op.join(rotarama_dir, "NO_UPDATE")
  164. open(no_update_file, "w").write("1")
  165. print >> out, "ok"
  166. # verify monomer library
  167. print >> out, "Checking for monomer library files...",
  168. try :
  169. call([os.path.join(self.build_dir, 'bin', 'mmtbx.verify_mon_lib_data')], log=log)
  170. except RuntimeError :
  171. raise InstallerError("Incomplete monomer library installation! "+
  172. "This usually indicates a corrupted installer; please "+
  173. "try downloading again and re-installing.")
  174. print >> out, "ok"
  175.  
  176. if (not self.options.without_pymol) :
  177. self.setup_pymol(out=out)
  178.  
  179. def product_specific_reduce_installation_size (self, out) :
  180. # remove CABLAM raw text files (unnecessary since we have pickles)
  181. cablam_dir = op.join(self.modules_dir, "chem_data", "cablam_data")
  182. for file_name in os.listdir(cablam_dir) :
  183. if file_name.endswith(".stat") :
  184. full_path = op.join(cablam_dir, file_name)
  185. os.remove(full_path)
  186. # top-level directories that we don't need
  187. for dir_name in ["phenix_regression", "phenix_html"] :
  188. full_path = op.join(self.modules_dir, dir_name)
  189. if op.isdir(full_path) :
  190. shutil.rmtree(full_path)
  191. # chem_data stuff
  192. lig_lib_dir = op.join(self.modules_dir, "chem_data", "ligand_lib")
  193. for file_name in lig_lib_dir :
  194. if file_name.startswith("PDB.") :
  195. full_path = op.join(lig_lib_dir, file_name)
  196. os.remove(full_path)
  197. rotarama_dir = op.join(self.modules_dir, "chem_data", "rotarama_data")
  198. for file_name in os.listdir(rotarama_dir) :
  199. if ((file_name.endswith(".data")) and
  200. (not file_name.startswith("rama500"))) :
  201. full_path = op.join(rotarama_dir, file_name)
  202. pkl_file = full_path.replace(".data", ".pickle")
  203. if op.isfile(pkl_file) :
  204. os.remove(full_path)
  205.  
  206. def install_pymol (self, out) :
  207. base_bin_dir = op.join(self.base_dir, "bin")
  208. pymol_dir = op.join(self.installer_dir, "pymol")
  209. if (not op.isdir(pymol_dir)) :
  210. print >> out, "PyMOL not available!"
  211. return False
  212. print >> out, "Installing PyMOL...",
  213. try :
  214. log = open(op.join(self.tmp_dir, "pymol.log"), "w")
  215. os.chdir(self.dest_dir)
  216. if (sys.platform == "darwin") :
  217. pymol_pkg = op.join(pymol_dir, "MacPyMOL.app.tar.gz")
  218. untar(pymol_pkg, log=log, check_output_path=False)
  219. else :
  220. pymol_pkg = op.join(pymol_dir,
  221. "pymol-0_99rc6-bin-linux-x86-glibc23.tar.gz")
  222. untar(pymol_pkg, log=log, check_output_path=False)
  223. except Exception, e :
  224. print >> out, "failed!"
  225. print >> out, "Error message:"
  226. print >> out, " %s" % str(e)
  227. return False
  228. print >> out, "ok"
  229. return True
  230.  
  231. # configure an already in-place PyMOL (Linux only)
  232. def setup_pymol (self, out) :
  233. base_bin_dir = op.join(self.base_dir, "bin")
  234. pymol_dir = op.join(self.dest_dir, "pymol")
  235. if (not op.isdir(pymol_dir)) :
  236. print >> out, "PyMOL not available!"
  237. return False
  238. print >> out, "Creating PyMOL launcher...",
  239. os.chdir(pymol_dir)
  240. args = [ "./setup.sh" ]
  241. log = open(op.join(self.tmp_dir, "pymol_setup.log"), "w")
  242. call(args=args, log=log)
  243. shutil.copyfile(op.join(os.getcwd(), "pymol"),
  244. op.join(base_bin_dir, "pymol"))
  245. print >> out, "ok"
  246. return True
  247.  
  248. def display_final_message (self) :
  249. if sys.platform == "win32":# not applicable for the setup.exe installer
  250. return
  251. print >> self.out, """
  252. ==========================================================================
  253.  
  254. PHENIX installation complete
  255. ----------------------------
  256.  
  257. You can begin using PHENIX now by setting your environment with the
  258. 'source' command:
  259.  
  260. csh users:
  261. source %s/phenix_env.csh
  262.  
  263. bash users:
  264. source %s/phenix_env.sh
  265.  
  266. To use PHENIX, go to a work directory and type:
  267.  
  268. phenix
  269.  
  270. You may wish to put the source statement in your .cshrc or .bashrc
  271. file.
  272.  
  273. """%(self.dest_dir, self.dest_dir)
  274.  
  275. if (__name__ == "__main__") :
  276. installer(sys.argv[1:]).install()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement