Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 437 lines (391 sloc) 13.055 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',
302 'Bio.Parsers',
303 'Bio.Pathway',
304 'Bio.Pathway.Rep',
305 'Bio.PDB',
3520916 *** empty log message ***
nisse authored
306 'Bio.PDB.mmCIF',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
307 'Bio.Prosite',
308 'Bio.Rebase',
309 'Bio.Saf',
310 'Bio.SCOP',
311 'Bio.SCOP.tests',
312 'Bio.SeqIO',
313 'Bio.SeqUtils',
314 'Bio.SubsMat',
315 'Bio.SVDSuperimposer',
316 'Bio.SwissProt',
317 'Bio.UniGene',
318 'Bio.writers',
319 'Bio.writers.SeqRecord',
3a5d550 Adding Bio.Wise to the distribution
grouse authored
320 'Bio.Wise',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
321 'Bio.WWW',
322 ]
323
324 EXTENSIONS = [
325 Extension('Bio.cSVM',
326 ['Bio/cSVMmodule.c',
327 'Bio/csupport.c'],
328 include_dirs=["Bio"]
329 ),
330 Extension('Bio.ckMeans',
331 ['Bio/ckMeansmodule.c',
332 'Bio/csupport.c'],
333 include_dirs=["Bio"]
334 ),
335 Extension('Bio.clistfns',
336 ['Bio/clistfnsmodule.c']
337 ),
338 Extension('Bio.cmathfns',
339 ['Bio/cmathfnsmodule.c',
340 'Bio/csupport.c'],
341 include_dirs=["Bio"]
342 ),
343 Extension('Bio.cstringfns',
344 ['Bio/cstringfnsmodule.c']
345 ),
346 Extension('Bio.cdistance',
347 ['Bio/cdistancemodule.c',
348 'Bio/csupport.c'],
349 include_dirs=["Bio"]
350 ),
351 Extension('Bio.cpairwise2',
352 ['Bio/cpairwise2module.c',
353 'Bio/csupport.c'],
354 include_dirs=["Bio"]
355 ),
356 Extension('Bio.trie',
357 ['Bio/triemodule.c',
358 'Bio/trie.c'],
359 include_dirs=["Bio"]
360 ),
361 Extension('Bio.cMarkovModel',
362 ['Bio/cMarkovModelmodule.c',
363 'Bio/csupport.c'],
364 include_dirs=["Bio"]
365 ),
3520916 *** empty log message ***
nisse authored
366 Extension('Bio.PDB.mmCIF.MMCIFlex',
367 ['Bio/PDB/mmCIF/lex.yy.c',
368 'Bio/PDB/mmCIF/MMCIFlexmodule.c'],
369 include_dirs=["Bio"],
b9fe0cc the EUtils dtd's were not being installed correctly, when the
jchang authored
370 libraries=["fl"]
371 ),
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
372 #Extension('Bio.KDTree._KDTreecmodule',
373 # ["Bio/KDTree/_KDTree.C",
374 # "Bio/KDTree/_KDTree.swig.C"],
375 # libraries=["stdc++"]
376 # ),
377 ]
378
9283de6 fixed installation of Bio/EUtils/DTDs
jchang authored
379 DATA_FILES=[
b9fe0cc the EUtils dtd's were not being installed correctly, when the
jchang authored
380 "Bio/EUtils/DTDs/*.dtd",
9283de6 fixed installation of Bio/EUtils/DTDs
jchang authored
381 ]
382
b9fe0cc the EUtils dtd's were not being installed correctly, when the
jchang authored
383 # EUtils contains dtd files that need to be installed in the same
384 # directory as the python modules. Distutils doesn't have a simple
385 # way of handling this, and we need to subclass install_data. This
386 # code is adapted from the mx.TextTools distribution.
387
388 class install_data_biopython(install_data):
389 def finalize_options(self):
390 if self.install_dir is None:
391 installobj = self.distribution.get_command_obj('install')
392 self.install_dir = installobj.install_platlib
393 install_data.finalize_options(self)
394
395 def run (self):
396 import glob
397 if not self.dry_run:
398 self.mkpath(self.install_dir)
399 data_files = self.get_inputs()
400 for entry in data_files:
401 if type(entry) is not type(""):
402 raise ValueError, "data_files must be strings"
403 # Unix- to platform-convention conversion
404 entry = os.sep.join(entry.split("/"))
405 filenames = glob.glob(entry)
406 for filename in filenames:
407 dst = os.path.join(self.install_dir, filename)
408 dstdir = os.path.split(dst)[0]
409 if not self.dry_run:
410 self.mkpath(dstdir)
411 outfile = self.copy_file(filename, dst)[0]
412 else:
413 outfile = dst
414 self.outfiles.append(outfile)
9283de6 fixed installation of Bio/EUtils/DTDs
jchang authored
415
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
416
417 # Install BioSQL.
418 PACKAGES.append("BioSQL")
419
420 setup(
421 name='biopython',
b1e7eb6 updated files for 1.23 release
jchang authored
422 version='1.23',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
423 author='The Biopython Consortium',
424 author_email='biopython@biopython.org',
425 url='http://www.biopython.org/',
426 cmdclass={
427 "install" : install_biopython,
428 "build_py" : build_py_biopython,
a8ae40f now installs Martel and doesn't complain about it
jchang authored
429 "build_ext" : build_ext_biopython,
b9fe0cc the EUtils dtd's were not being installed correctly, when the
jchang authored
430 "install_data" : install_data_biopython,
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
431 "test" : test_biopython,
432 },
433 packages=PACKAGES,
434 ext_modules=EXTENSIONS,
9283de6 fixed installation of Bio/EUtils/DTDs
jchang authored
435 data_files=DATA_FILES,
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
436 )
Something went wrong with that request. Please try again.