Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 223 lines (179 sloc) 6.923 kB
22df84e Updated setup.py for GenBank
chapmanb authored
1 """Distutils based setup script for Biopython.
2
3 This uses Distutils (http://python.org/sigs/distutils-sig/) the standard
4 python mechanism for installing packages. For the easiest installation
5 just type the command:
6
7 python setup.py install
8
9 For more in-depth instructions, see the installation section of the
10 biopython manual, linked to from:
11
12 http://biopython.org/wiki/html/BioPython/BiopythonCode.html
13
14 Or for more details about the options available from distutils, look at
15 the 'Installing Python Modules' distutils documentation, available from:
16
17 http://python.org/sigs/distutils-sig/doc/
18
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
19 Or, if all else fails, feel free to write to the biopython list
20 at biopython@biopython.org and ask for help.
22df84e Updated setup.py for GenBank
chapmanb authored
21 """
f726249 merged Andrew's Seq package with the tree
jchang authored
22
23 import sys
96a6095 Upgrade setup.py for SubsMat
chapmanb authored
24 import os
f726249 merged Andrew's Seq package with the tree
jchang authored
25 try:
26 from distutils.core import setup
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
27 from distutils.command.install import install
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
28 from distutils.core import Command
f726249 merged Andrew's Seq package with the tree
jchang authored
29 except ImportError:
96a6095 Upgrade setup.py for SubsMat
chapmanb authored
30 print "Biopython installation requires distutils, avaiable with python 2.0"
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
31 print "or better, or from:"
32 print "http://python.org/sigs/distutils-sig/download.html"
f726249 merged Andrew's Seq package with the tree
jchang authored
33 sys.exit(0)
34
8535499 Support new and old style formats for the extensions
chapmanb authored
35 # check if the distutils has the new extension class stuff
36 try:
37 from distutils.extension import Extension
38 except ImportError:
22df84e Updated setup.py for GenBank
chapmanb authored
39 print "Your version of distutils is really old. You need to upgrade"
40 print "to a newer version. The latest releases of distutils are available"
41 print "from http://python.org/sigs/distutils-sig/download.html"
42 sys.exit(0)
8535499 Support new and old style formats for the extensions
chapmanb authored
43
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
44 # --- check for installed programs needed by Biopython
45
46 def check_install(name, check_library, location, other_messages = None):
47 """Check if a program is installed and print a warning message if not.
48
49 This helps users at least know they are missing some installed stuff
50 and where to get it when they install biopython.
51
52 Arguments:
53
54 o check_library -- a function to check whether or not the specified
55 program and version is present, returns 1 if it is, 0 otherwise.
56
57 o name -- the name of the library we are looking for
58
59 o location -- a URL where the library can be downloaded
60
61 o other_messages -- other random messages to print if the library
62 is not present (ie. version information, etc...)
63 """
64 if not(check_library()):
65 print "\nWARNING -- %s is not installed." % name
66 print "You should install this from:"
67 print location
68 print "to get full functionality from Biopython."
69 if other_messages:
70 print other_messages
71
72 # -- functions to check for specific libraries and versions.
73
74 def check_Martel():
75 """Check for Martel version 0.5 or better.
76 """
77 try:
78 import Martel
79 if str(Martel.__version__) >= "0.5":
80 return 1
81 else:
82 return 0
83 except ImportError:
84 return 0
85
86 def check_mxTextTools():
87 try:
88 import TextTools
89 return 1
90 except ImportError:
91 try:
92 from mx import TextTools
93 return 1
94 except ImportError:
95 return 0
96
97 def check_Numpy():
98 try:
58dc10f Ooops, used 'from blah import *' not in the global scope in my check …
chapmanb authored
99 import Numeric
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
100 return 1
101 except ImportError:
102 return 0
103
104 class my_install(install):
105 """Override the standard install to check for dependencies.
106
107 This will just run the normal install, and then print warning messages
108 if packages are missing.
109 """
110 def run(self):
111 # run the normal install and everthing
112 install.run(self)
113
114 # now print warning messages if we are missing stuff
115 check_install("Martel", check_Martel,
116 "http://www.biopython.org/~dalke/Martel/",
117 "Version 0.5 or better required")
118
119 check_install("mxTextTools", check_mxTextTools,
120 "http://www.lemburg.com/files/python/mxExtensions.html")
121
122 check_install("Numerical Python", check_Numpy,
123 "http://numpy.sourceforge.net/")
124
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
125 class run_tests(Command):
126 """Run all of the tests for the package.
127
128 This is a automatic test run class to make distutils kind of act like
129 perl. With this you can do:
130
131 python setup.py build
132 python setup.py install
133 python setup.py test
134 """
135 description = "Automatically run the test suite for the package."
136
137 user_options = []
138
139 def initialize_options(self):
140 pass
141
142 def finalize_options(self):
143 pass
144
145 def run(self):
146 this_dir = os.getcwd()
147
148 # change to the test dir and run the tests
149 os.chdir("Tests")
150 import run_tests
151 run_tests.main([])
152
153 # change back to the current directory
154 os.chdir(this_dir)
155
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
156 # --- set up the packages we are going to install
157 # standard biopython packages
158 biopython_packages = ['Bio',
159 'Bio.Align',
160 'Bio.Alphabet',
161 'Bio.Blast',
162 'Bio.Clustalw',
163 'Bio.Data',
164 'Bio.Encodings',
165 'Bio.Enzyme',
166 'Bio.Fasta',
167 'Bio.GenBank',
168 'Bio.Gobase',
169 'Bio.Medline',
170 'Bio.PDB',
171 'Bio.Prosite',
172 'Bio.Rebase',
173 'Bio.SCOP',
174 'Bio.SeqIO',
175 'Bio.SubsMat',
176 'Bio.SwissProt',
177 'Bio.Tools',
178 'Bio.Tools.Classification',
ccacabd Added MultiProc code from Jeff to the setup file.
chapmanb authored
179 'Bio.Tools.MultiProc',
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
180 'Bio.Tools.Parsers',
181 'Bio.UniGene',
182 'Bio.WWW'
183 ]
184
185 # Martel -- for building parsers
186 martel_packages = ['Martel',
187 'Martel.formats']
188 # a flag to determine if we should install Martel
189 INSTALL_MARTEL = 0
190
191 # -- setup the packages list
192 all_packages = biopython_packages
193 # only install Martel if we have the flag set
194 if INSTALL_MARTEL:
195 all_packages.extend(martel_packages)
196
f726249 merged Andrew's Seq package with the tree
jchang authored
197 setup(name='biopython',
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
198 version='0.95d01',
f726249 merged Andrew's Seq package with the tree
jchang authored
199 author='The Biopython Consortium',
200 author_email='biopython@biopython.org',
e290097 fixed minor typo in biopython url
jchang authored
201 url='http://www.biopython.org/',
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
202
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
203 cmdclass = {"install" : my_install,
204 "test" : run_tests},
f726249 merged Andrew's Seq package with the tree
jchang authored
205
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
206 packages = all_packages,
96a6095 Upgrade setup.py for SubsMat
chapmanb authored
207
22df84e Updated setup.py for GenBank
chapmanb authored
208 ext_modules = [Extension('Bio.Tools.Classification.cSVM',
209 ['Bio/Tools/Classification/cSVMmodule.c']
210 ),
211 Extension('Bio.Tools.clistfns',
212 ['Bio/Tools/clistfnsmodule.c']
213 ),
214 Extension('Bio.Tools.cmathfns',
215 ['Bio/Tools/cmathfnsmodule.c']
216 ),
217 Extension('Bio.Tools.cstringfns',
218 ['Bio/Tools/cstringfnsmodule.c']
219 )
220 ]
f726249 merged Andrew's Seq package with the tree
jchang authored
221 )
222
Something went wrong with that request. Please try again.