Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 438 lines (392 sloc) 13.07 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
b7761b6 Fixes to imported EUtils to get it working happily with Bio:
chapmanb authored
12 http://www.biopython.org/documentation/
22df84e Updated setup.py for GenBank
chapmanb authored
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
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
19 Or, if all else fails, feel free to write to the biopython list at
20 biopython@biopython.org and ask for help.
21 """
f726249 merged Andrew's Seq package with the tree
jchang authored
22 import sys
96a6095 Upgrade setup.py for SubsMat
chapmanb authored
23 import os
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
24
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
25 # Make sure I have the right Python version.
26 if sys.version_info[:2] < (2, 2):
27 print "Biopython requires Python 2.2. Python %d.%d detected" % \
28 sys.version_info[:2]
29 sys.exit(-1)
30
31 from distutils.core import setup
32 from distutils.core import Command
33 from distutils.command.install import install
b9fe0cc the EUtils dtd's were not being installed correctly, when the
jchang authored
34 from distutils.command.install_data import install_data
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
35 from distutils.command.build_py import build_py
a8ae40f now installs Martel and doesn't complain about it
jchang authored
36 from distutils.command.build_ext import build_ext
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
37 from distutils.extension import Extension
38
39 def get_yes_or_no(question, default):
40 if default:
41 option_str = "(Y/n)"
42 default_str = 'y'
43 else:
44 option_str = "(y/N)"
45 default_str = 'n'
46
47 while 1:
48 print "%s %s " % (question, option_str),
49 response = raw_input().lower()
50 if not response:
51 response = default_str
52 if response[0] in ['y', 'n']:
53 break
54 print "Please answer y or n."
55 return response[0] == 'y'
56
a8ae40f now installs Martel and doesn't complain about it
jchang authored
57 _CHECKED = None
58 def check_dependencies_once():
59 # Call check_dependencies, but cache the result for subsequent
60 # calls.
61 global _CHECKED
62 if _CHECKED is None:
63 _CHECKED = check_dependencies()
64 return _CHECKED
65
66 def check_dependencies():
67 """Return whether the installation should continue."""
68 # There should be some way for the user to tell specify not to
69 # check dependencies. For example, it probably should not if
70 # the user specified "-q". However, I'm not sure where
71 # distutils stores that information. Also, install has a
72 # --force option that gets saved in self.user_options. It
73 # means overwrite previous installations. If the user has
74 # forced an installation, should we also ignore dependencies?
75 dependencies = [
76 ("mxTextTools", is_mxTextTools_installed, 1,
77 "http://www.lemburg.com/files/python/mxExtensions.html"),
78 #("Martel", is_Martel_installed, 1,
79 # "http://www.biopython.org/~dalke/Martel/"),
80 ("Numerical Python", is_Numpy_installed, 0,
81 "http://numpy.sourceforge.net/"),
82 ("Reportlab", is_reportlab_installed, 0,
b6580cd Fixed spelling error "is you are unsure" ==> "if you are unsure"
mdehoon authored
83 "http://www.reportlab.org/downloads.html"),
a8ae40f now installs Martel and doesn't complain about it
jchang authored
84 ]
85
86 for name, is_installed_fn, is_required, url in dependencies:
87 if is_installed_fn():
88 continue
89
90 print "*** %s *** is either not installed or out of date." % name
91 if is_required:
92
93 print """
94 This package is required for many Biopython features. Please install
95 it before you install Biopython."""
96 default = 0
97 else:
98 print """
99 This package is optional, which means it is only used in a few
b6580cd Fixed spelling error "is you are unsure" ==> "if you are unsure"
mdehoon authored
100 specialized modules in Biopython. You probably don't need this if you
a8ae40f now installs Martel and doesn't complain about it
jchang authored
101 are unsure. You can ignore this requirement, and install it later if
102 you see ImportErrors."""
103 default = 1
104 print "You can find %s at %s." % (name, url)
105 print
106
107 if not get_yes_or_no(
108 "Do you want to continue this installation?", default):
109 return 0
110 return 1
111
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
112 class install_biopython(install):
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
113 """Override the standard install to check for dependencies.
114
115 This will just run the normal install, and then print warning messages
116 if packages are missing.
b7761b6 Fixes to imported EUtils to get it working happily with Bio:
chapmanb authored
117
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
118 """
119 def run(self):
a8ae40f now installs Martel and doesn't complain about it
jchang authored
120 if check_dependencies_once():
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
121 # Run the normal install.
122 install.run(self)
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
123
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
124 class build_py_biopython(build_py):
125 def run(self):
a8ae40f now installs Martel and doesn't complain about it
jchang authored
126 if not check_dependencies_once():
127 return
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
128 # Check to see if Martel is installed. If not, then install
129 # it automatically.
130 if not is_Martel_installed():
131 self.packages.append("Martel")
a8ae40f now installs Martel and doesn't complain about it
jchang authored
132 # Only install the clustering software if Numpy is installed.
133 if is_Numpy_installed():
134 self.packages.append("Bio.Cluster")
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
135 build_py.run(self)
fc90717 Whew, final thing to add! Added code for displaying pretty pictures u…
chapmanb authored
136
a8ae40f now installs Martel and doesn't complain about it
jchang authored
137 class build_ext_biopython(build_ext):
138 def run(self):
139 if not check_dependencies_once():
140 return
141 # Only install the clustering software if Numpy is installed.
142 # Otherwise, it will not compile.
143 if is_Numpy_installed():
144 self.extensions.append(
145 Extension('Bio.Cluster.cluster',
146 ['Bio/Cluster/clustermodule.c',
147 'Bio/Cluster/cluster.c',
148 'Bio/Cluster/ranlib.c',
149 'Bio/Cluster/com.c',
150 'Bio/Cluster/linpack.c'],
151 include_dirs=["Bio/Cluster"]
152 )
153 )
154 build_ext.run(self)
155
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
156 class test_biopython(Command):
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
157 """Run all of the tests for the package.
158
159 This is a automatic test run class to make distutils kind of act like
160 perl. With this you can do:
161
162 python setup.py build
163 python setup.py install
164 python setup.py test
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
165
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
166 """
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
167 description = "Automatically run the test suite for Biopython."
168 user_options = [] # distutils complains if this is not here.
169 def initialize_options(self): # distutils wants this
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
170 pass
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
171 def finalize_options(self): # this too
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
172 pass
173 def run(self):
174 this_dir = os.getcwd()
175
176 # change to the test dir and run the tests
177 os.chdir("Tests")
b720e3d In Python 2.3.2, the current directory '' is not included in the path.
grouse authored
178 sys.path.insert(0, '')
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
179 import run_tests
180 run_tests.main([])
181
182 # change back to the current directory
183 os.chdir(this_dir)
184
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
185 def can_import(module_name):
186 """can_import(module_name) -> module or None"""
187 try:
188 return __import__(module_name)
189 except ImportError:
190 return None
191 raise AssertionError, "how did I get here?"
192
193 def is_Martel_installed():
194 old_path = sys.path[:]
195
196 # First, check the version of the Martel that's bundled with
197 # Biopython.
198 sys.path.insert(0, '') # Make sure I'm importing the current one.
199 m = can_import("Martel")
200 sys.path = old_path
201 if m:
202 bundled_martel_version = m.__version__
203 else:
204 bundled_martel_version = None
205 del sys.modules["Martel"] # Delete the old version of Martel.
206
207 # Now try and import a Martel that's not bundled with Biopython.
208 # To do that, I need to delete all the references to the current
209 # path from sys.path.
210 i = 0
211 while i < len(sys.path):
7adf843 Added fix to Martel check code which keeps is_Martel_Installed from r…
chapmanb authored
212 if sys.path[i] in ['', '.', os.getcwd()]:
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
213 del sys.path[i]
214 else:
215 i += 1
216 m = can_import("Martel")
217 sys.path = old_path
218 if m:
219 old_martel_version = m.__version__
220 else:
221 old_martel_version = None
222
223 installed = 0
224 # If the bundled one is the same or older, then ignore it
225 if old_martel_version and bundled_martel_version and \
226 bundled_martel_version <= old_martel_version:
227 installed = 1
228 return installed
229
230 def is_mxTextTools_installed():
231 if can_import("TextTools"):
232 return 1
233 return can_import("mx.TextTools")
234
235 def is_Numpy_installed():
236 return can_import("Numeric")
237
238 def is_reportlab_installed():
239 return can_import("reportlab")
240
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
241 # --- set up the packages we are going to install
242 # standard biopython packages
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
243 PACKAGES = [
244 'Bio',
245 'Bio.Ais',
246 'Bio.Align',
193e993 initial checking of Bartek Wilczynski's AlignAce module
jchang authored
247 'Bio.AlignAce',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
248 'Bio.Alphabet',
249 'Bio.Application',
250 'Bio.Blast',
251 'Bio.builders',
252 'Bio.builders.Search',
253 'Bio.builders.SeqRecord',
254 'Bio.CDD',
255 'Bio.Clustalw',
256 'Bio.config',
257 'Bio.Crystal',
258 'Bio.Data',
259 'Bio.dbdefs',
260 'Bio.ECell',
261 'Bio.Emboss',
262 'Bio.Encodings',
263 'Bio.Enzyme',
264 'Bio.expressions',
265 'Bio.expressions.blast',
266 'Bio.expressions.embl',
267 'Bio.expressions.swissprot',
b7761b6 Fixes to imported EUtils to get it working happily with Bio:
chapmanb authored
268 'Bio.EUtils',
269 'Bio.EUtils.DTDs',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
270 'Bio.Fasta',
271 'Bio.formatdefs',
272 'Bio.FSSP',
273 'Bio.GA',
274 'Bio.GA.Crossover',
275 'Bio.GA.Mutation',
276 'Bio.GA.Repair',
277 'Bio.GA.Selection',
278 'Bio.GenBank',
279 'Bio.Geo',
280 'Bio.GFF',
281 'Bio.Gobase',
282 'Bio.Graphics',
283 'Bio.HMM',
284 'Bio.IntelliGenetics',
285 'Bio.InterPro',
286 'Bio.Kabat',
287 'Bio.KDTree',
288 'Bio.KEGG',
289 'Bio.KEGG.Compound',
290 'Bio.KEGG.Enzyme',
291 'Bio.KEGG.Map',
1c9b14b Added LocusLink back in to the install since tests pass
chapmanb authored
292 'Bio.LocusLink',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
293 'Bio.Medline',
294 'Bio.MetaTool',
295 'Bio.Mindy',
296 'Bio.MultiProc',
297 'Bio.NBRF',
298 'Bio.Ndb',
299 'Bio.NeuralNetwork',
300 'Bio.NeuralNetwork.BackPropagation',
301 'Bio.NeuralNetwork.Gene',
7bcfbce Adding NMR files kindly contributed by Bob Bussell
chapmanb authored
302 'Bio.NMR',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
303 'Bio.Parsers',
304 'Bio.Pathway',
305 'Bio.Pathway.Rep',
306 'Bio.PDB',
3520916 *** empty log message ***
nisse authored
307 'Bio.PDB.mmCIF',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
308 'Bio.Prosite',
309 'Bio.Rebase',
310 'Bio.Saf',
311 'Bio.SCOP',
312 'Bio.SCOP.tests',
313 'Bio.SeqIO',
314 'Bio.SeqUtils',
315 'Bio.SubsMat',
316 'Bio.SVDSuperimposer',
317 'Bio.SwissProt',
318 'Bio.UniGene',
319 'Bio.writers',
320 'Bio.writers.SeqRecord',
3a5d550 Adding Bio.Wise to the distribution
grouse authored
321 'Bio.Wise',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
322 'Bio.WWW',
323 ]
324
325 EXTENSIONS = [
326 Extension('Bio.cSVM',
327 ['Bio/cSVMmodule.c',
328 'Bio/csupport.c'],
329 include_dirs=["Bio"]
330 ),
331 Extension('Bio.ckMeans',
332 ['Bio/ckMeansmodule.c',
333 'Bio/csupport.c'],
334 include_dirs=["Bio"]
335 ),
336 Extension('Bio.clistfns',
337 ['Bio/clistfnsmodule.c']
338 ),
339 Extension('Bio.cmathfns',
340 ['Bio/cmathfnsmodule.c',
341 'Bio/csupport.c'],
342 include_dirs=["Bio"]
343 ),
344 Extension('Bio.cstringfns',
345 ['Bio/cstringfnsmodule.c']
346 ),
347 Extension('Bio.cdistance',
348 ['Bio/cdistancemodule.c',
349 'Bio/csupport.c'],
350 include_dirs=["Bio"]
351 ),
352 Extension('Bio.cpairwise2',
353 ['Bio/cpairwise2module.c',
354 'Bio/csupport.c'],
355 include_dirs=["Bio"]
356 ),
357 Extension('Bio.trie',
358 ['Bio/triemodule.c',
359 'Bio/trie.c'],
360 include_dirs=["Bio"]
361 ),
362 Extension('Bio.cMarkovModel',
363 ['Bio/cMarkovModelmodule.c',
364 'Bio/csupport.c'],
365 include_dirs=["Bio"]
366 ),
3520916 *** empty log message ***
nisse authored
367 Extension('Bio.PDB.mmCIF.MMCIFlex',
368 ['Bio/PDB/mmCIF/lex.yy.c',
369 'Bio/PDB/mmCIF/MMCIFlexmodule.c'],
370 include_dirs=["Bio"],
b9fe0cc the EUtils dtd's were not being installed correctly, when the
jchang authored
371 libraries=["fl"]
372 ),
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
373 #Extension('Bio.KDTree._KDTreecmodule',
374 # ["Bio/KDTree/_KDTree.C",
375 # "Bio/KDTree/_KDTree.swig.C"],
376 # libraries=["stdc++"]
377 # ),
378 ]
379
9283de6 fixed installation of Bio/EUtils/DTDs
jchang authored
380 DATA_FILES=[
b9fe0cc the EUtils dtd's were not being installed correctly, when the
jchang authored
381 "Bio/EUtils/DTDs/*.dtd",
9283de6 fixed installation of Bio/EUtils/DTDs
jchang authored
382 ]
383
b9fe0cc the EUtils dtd's were not being installed correctly, when the
jchang authored
384 # EUtils contains dtd files that need to be installed in the same
385 # directory as the python modules. Distutils doesn't have a simple
386 # way of handling this, and we need to subclass install_data. This
387 # code is adapted from the mx.TextTools distribution.
388
389 class install_data_biopython(install_data):
390 def finalize_options(self):
391 if self.install_dir is None:
392 installobj = self.distribution.get_command_obj('install')
393 self.install_dir = installobj.install_platlib
394 install_data.finalize_options(self)
395
396 def run (self):
397 import glob
398 if not self.dry_run:
399 self.mkpath(self.install_dir)
400 data_files = self.get_inputs()
401 for entry in data_files:
402 if type(entry) is not type(""):
403 raise ValueError, "data_files must be strings"
404 # Unix- to platform-convention conversion
405 entry = os.sep.join(entry.split("/"))
406 filenames = glob.glob(entry)
407 for filename in filenames:
408 dst = os.path.join(self.install_dir, filename)
409 dstdir = os.path.split(dst)[0]
410 if not self.dry_run:
411 self.mkpath(dstdir)
412 outfile = self.copy_file(filename, dst)[0]
413 else:
414 outfile = dst
415 self.outfiles.append(outfile)
9283de6 fixed installation of Bio/EUtils/DTDs
jchang authored
416
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
417
418 # Install BioSQL.
419 PACKAGES.append("BioSQL")
420
421 setup(
422 name='biopython',
b1e7eb6 updated files for 1.23 release
jchang authored
423 version='1.23',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
424 author='The Biopython Consortium',
425 author_email='biopython@biopython.org',
426 url='http://www.biopython.org/',
427 cmdclass={
428 "install" : install_biopython,
429 "build_py" : build_py_biopython,
a8ae40f now installs Martel and doesn't complain about it
jchang authored
430 "build_ext" : build_ext_biopython,
b9fe0cc the EUtils dtd's were not being installed correctly, when the
jchang authored
431 "install_data" : install_data_biopython,
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
432 "test" : test_biopython,
433 },
434 packages=PACKAGES,
435 ext_modules=EXTENSIONS,
9283de6 fixed installation of Bio/EUtils/DTDs
jchang authored
436 data_files=DATA_FILES,
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
437 )
Something went wrong with that request. Please try again.