Package Martel :: Module setup
[hide private]
[frames] | no frames]

Source Code for Module Martel.setup

  1  """Distutils based setup script for Martel. 
  2   
  3  This uses Distutils (http://python.org/sigs/distutils-sig/) the 
  4  standard python mechanism for installing packages. For the easiest 
  5  installation just type the command: 
  6   
  7    python setup.py install 
  8   
  9  For more details about the options available from distutils, look at 
 10  the 'Installing Python Modules' distutils documentation, available 
 11  from: 
 12   
 13    http://python.org/sigs/distutils-sig/doc/ 
 14   
 15  Or, if all else fails, feel free to write to the biopython list 
 16  at biopython@biopython.org and ask for help. 
 17  """ 
 18   
 19  # This setup.py is a modified vesion of the standard Biopython 
 20  # setup.py, which explains why some of the code is overkill :) 
 21   
 22  import sys, os 
 23   
 24  try: 
 25      from distutils.core import setup 
 26      from distutils.command.install import install 
 27      from distutils.core import Command 
 28  except ImportError: 
 29      print "Martel installation requires distutils, available with python 2.0" 
 30      print "or better, or from:" 
 31      print "  http://python.org/sigs/distutils-sig/download.html" 
 32      sys.exit(0) 
 33   
 34   
 35  # --- check for installed programs needed by Martel 
 36   
37 -def check_install(name, check_library, location, other_messages = None):
38 """Check if a program is installed and print a warning message if not. 39 40 This helps users at least know they are missing some installed stuff 41 and where to get it when they install Martel. 42 43 Arguments: 44 45 o check_library -- a function to check whether or not the specified 46 program and version is present, returns 1 if it is, 0 otherwise. 47 48 o name -- the name of the library we are looking for 49 50 o location -- a URL where the library can be downloaded 51 52 o other_messages -- other random messages to print if the library 53 is not present (ie. version information, etc...) 54 """ 55 if not(check_library()): 56 print "\nWARNING -- %s is not installed." % name 57 print "You should install this from:" 58 print location 59 print "because otherwise Martel will not be useful" 60 if other_messages: 61 print other_messages
62 63 # -- functions to check for specific libraries and versions. 64
65 -def check_mxTextTools():
66 try: 67 from mx import TextTools 68 return 1 69 except ImportError: 70 pass 71 try: 72 import TextTools 73 return 1 74 except ImportError: 75 pass 76 return 0
77
78 -class my_install(install):
79 """Override the standard install to check for dependencies. 80 81 This will just run the normal install, and then print warning messages 82 if packages are missing. 83 """
84 - def run(self):
85 # run the normal install and everthing 86 install.run(self) 87 88 # now print warning messages if we are missing stuff 89 check_install("mxTextTools", check_mxTextTools, 90 "http://www.lemburg.com/files/python/mxExtensions.html")
91
92 -class run_local_tests(Command):
93 """Run all of the tests for the package using uninstalled (local) files 94 95 This is a automatic test run class to make distutils kind of act like 96 perl. With this you can do: 97 98 python setup.py test 99 100 """ 101 description = "Automatically run the test suite for the package." 102 103 user_options = [] 104
105 - def initialize_options(self):
106 pass
107
108 - def finalize_options(self):
109 pass
110
111 - def run(self):
112 this_dir = os.getcwd() 113 114 # change to the test dir and run the tests 115 os.chdir("test") 116 import run_tests 117 run_tests.local_test_main([]) 118 119 # change back to the current directory 120 os.chdir(this_dir)
121 122
123 -class run_install_tests(run_local_tests):
124 """Run all of the tests for the package using installed files 125 126 This is a automatic test run class to make distutils kind of act like 127 perl. With this you can do: 128 129 python setup.py install 130 python setup.py installtest 131 132 """
133 - def run(self):
134 this_dir = os.getcwd() 135 136 # change to the test dir and run the tests 137 os.chdir("test") 138 import run_tests 139 run_tests.install_test_main([]) 140 141 # change back to the current directory 142 os.chdir(this_dir)
143 144 setup(name = "Martel", 145 version = "1.43", 146 description = "Parse flat-file formats as if they are in XML", 147 author = "Dalke Scientific Software, LLC; " \ 148 "member of the The Biopython Consortium", 149 author_email = "dalke@dalkescientific.com", 150 url = "http://www.dalkescientific.com/Martel", 151 license = "Biopython license", 152 153 cmdclass = {"install" : my_install, 154 "test" : run_local_tests, 155 "installtest" : run_install_tests, 156 }, 157 package_dir = {"Martel": ""}, 158 packages = ["Martel"], 159 ) 160