Module dep_check
[hide private]
[frames] | no frames]

Source Code for Module dep_check

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2008-2012 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docstring. 
 24  """Module for checking relax dependencies. 
 25   
 26  If essential dependencies are missing, then an error message is printed and the program terminated. 
 27  """ 
 28   
 29  # Python modules. 
 30  import platform 
 31  from os import F_OK, access, sep 
 32  import sys 
 33   
 34   
 35  # Essential packages. 
 36  ##################### 
 37   
 38  # numpy. 
 39  try: 
 40      import numpy 
 41  except ImportError: 
 42      sys.stderr.write("The dependency 'numpy' has not been installed.\n") 
 43      sys.exit() 
 44   
 45  # Command line option parser. 
 46  try: 
 47      import optparse 
 48  except ImportError: 
 49      sys.stderr.write("The dependency 'Optik' has not been installed.\n") 
 50      sys.exit() 
 51   
 52  # Minfx python package check. 
 53  try: 
 54      import minfx 
 55  except ImportError: 
 56      sys.stderr.write("The dependency 'minfx' has not been installed (see https://sourceforge.net/projects/minfx/).\n") 
 57      sys.exit() 
 58   
 59  # Optional packages. 
 60  #################### 
 61   
 62  # Bmrblib python package check. 
 63  try: 
 64      import bmrblib 
 65      bmrblib_module = True 
 66  except ImportError: 
 67      bmrblib_module = False 
 68   
 69  # wx module. 
 70  try: 
 71      import wx 
 72      wx_module = True 
 73  except ImportError: 
 74      wx_module = False 
 75   
 76  # epydoc module. 
 77  try: 
 78      import epydoc 
 79      epydoc_module = True 
 80  except ImportError: 
 81      epydoc_module = False 
 82   
 83  # Readline module. 
 84  try: 
 85      import readline 
 86      readline_module = True 
 87  except ImportError: 
 88      readline_module = False 
 89   
 90  # runpy module. 
 91  try: 
 92      import runpy 
 93      runpy_module = True 
 94  except ImportError: 
 95      runpy_module = False 
 96   
 97  # profile module (python development packages required). 
 98  try: 
 99      import profile 
100      profile_module = True 
101  except ImportError: 
102      profile_module = False 
103   
104  # BZ2 compression module. 
105  try: 
106      import bz2 
107      bz2_module = True 
108  except ImportError, message: 
109      bz2_module = False 
110      bz2_module_message = message.args[0] 
111   
112  # Gzip compression module. 
113  try: 
114      import gzip 
115      gzip_module = True 
116  except ImportError, message: 
117      gzip_module = False 
118      gzip_module_message = message.args[0] 
119   
120  # Devnull. 
121  try: 
122      import os 
123      from os import devnull 
124      del devnull 
125      devnull_import = True 
126  except ImportError, message: 
127      devnull_import = False 
128      devnull_import_message = message.args[0] 
129   
130  # Scipy import. 
131  try: 
132      import scipy 
133      scipy_module = True 
134  except ImportError: 
135      scipy_module = False 
136   
137  # Numeric python package check. 
138  try: 
139      import Numeric 
140      numeric_module = True 
141  except ImportError: 
142      numeric_module = False 
143   
144  # VMD module imports. 
145  try: 
146      from Scientific.Visualization import VMD    # This requires Numeric to be installed (at least in Scientific 2.7.8). 
147      del VMD 
148      vmd_module = True 
149  except ImportError: 
150      vmd_module = False 
151   
152  # mpi4py. 
153  try: 
154      import mpi4py 
155      mpi4py_module = True 
156  except ImportError, message: 
157      mpi4py_module = False 
158   
159      # The error message. 
160      mpi4py_message = """The dependency 'mpi4py' has not been installed. You should either: 
161   
162  1. Run without multiprocessor support i.e. remove the --multi mpi4py flag from the command line. 
163   
164  2. Install mpi4py. 
165   
166  3. Choose another multi processor method to give to the --multi command line flag.\n 
167      """ 
168    
169  # PyMOL. 
170  try: 
171      import pymol 
172      pymol_module = True 
173  except ImportError, message: 
174      pymol_module = False 
175   
176  # XML. 
177  try: 
178      import xml 
179      xml_module = True 
180  except ImportError, message: 
181      xml_module = False 
182  if xml_module: 
183      # The XML version mess! 
184      if hasattr(xml, '_MINIMUM_XMLPLUS_VERSION'): 
185          xml_version = "%s.%s.%s" % xml._MINIMUM_XMLPLUS_VERSION 
186          xml_type = 'internal' 
187      elif hasattr(xml, '__version__'): 
188          xml_version = xml.__version__ 
189          xml_type = 'PyXML' 
190      else: 
191          xml_version = '' 
192          xml_type = '' 
193   
194   
195   
196  # Compiled C modules. 
197  ##################### 
198   
199  # Relaxation curve fitting. 
200  try: 
201      from maths_fns import relax_fit 
202      from maths_fns.relax_fit import setup 
203      del setup 
204      C_module_exp_fn = True 
205  except ImportError, message: 
206      # The OS. 
207      system = platform.system() 
208   
209      # Does the compiled file exist. 
210      file = 'relax_fit.so' 
211      if system == 'Windows' or system == 'Microsoft': 
212          file = 'relax_fit.pyd' 
213      if not access('maths_fns' + sep + file, F_OK): 
214          C_module_exp_fn_mesg = "ImportError: relaxation curve fitting is unavailable, the corresponding C modules have not been compiled." 
215   
216      # Show the full error. 
217      else: 
218          C_module_exp_fn_mesg = "ImportError: " + message[0] + "\nRelaxation curve fitting is unavailable, try compiling the C modules." 
219   
220      # Set the flag. 
221      C_module_exp_fn = False 
222