Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 389 lines (343 sloc) 11.597 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
b4379ed @peterjc Dropping support for Python 2.3
peterjc authored
10 Biopython manual, linked to from:
22df84e Updated setup.py for GenBank
chapmanb authored
11
e4e4dc4 @peterjc Updating the documentation URL
peterjc authored
12 http://biopython.org/wiki/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
0277345 @peterjc Clarify the mailing list bit
peterjc authored
19 Or, if all else fails, feel free to write to the sign up to the Biopython
e4e4dc4 @peterjc Updating the documentation URL
peterjc authored
20 mailing list and ask for help. See:
21
22 http://biopython.org/wiki/Mailing_lists
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
23 """
f726249 merged Andrew's Seq package with the tree
jchang authored
24 import sys
96a6095 Upgrade setup.py for SubsMat
chapmanb authored
25 import os
1eeed11 @peterjc Call 2to3 from setup.py on Python 3 (like NumPy)
peterjc authored
26 import shutil
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
27
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
28 def get_yes_or_no(question, default):
29 if default:
30 option_str = "(Y/n)"
31 default_str = 'y'
32 else:
33 option_str = "(y/N)"
34 default_str = 'n'
35
e4e4dc4 @peterjc Updating the documentation URL
peterjc authored
36 while True:
adcfd49 @peterjc Tweak the setup.py y/n prompt to look sensible on Python 2.7
peterjc authored
37 print ("%s %s:" % (question, option_str))
942ef84 @tiagoantao setup.py is now Python 3 aware
tiagoantao authored
38 if sys.version_info[0] == 3:
39 response = input().lower()
40 else:
41 response = raw_input().lower()
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
42 if not response:
43 response = default_str
44 if response[0] in ['y', 'n']:
45 break
942ef84 @tiagoantao setup.py is now Python 3 aware
tiagoantao authored
46 print ("Please answer y or n.")
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
47 return response[0] == 'y'
48
942ef84 @tiagoantao setup.py is now Python 3 aware
tiagoantao authored
49 # Make sure I have the right Python version.
50 if sys.version_info[:2] < (2, 4):
51 print ("Biopython requires Python 2.4 or better (but not Python 3 " \
52 + "yet). Python %d.%d detected" % sys.version_info[:2])
53 sys.exit(-1)
54 elif sys.version_info[:2] == (2,4):
1eeed11 @peterjc Call 2to3 from setup.py on Python 3 (like NumPy)
peterjc authored
55 print ("WARNING - Biopython no longer officially supports Python 2.4")
942ef84 @tiagoantao setup.py is now Python 3 aware
tiagoantao authored
56 elif sys.version_info[0] == 3:
1eeed11 @peterjc Call 2to3 from setup.py on Python 3 (like NumPy)
peterjc authored
57 print("WARNING - Biopython does not yet officially support Python 3")
58 import do2to3
59 python3_source = "build/py%i.%i" % sys.version_info[:2]
60 if "clean" in sys.argv:
61 if os.path.isdir(python3_source):
62 shutil.rmtree(python3_source)
63 del python3_source #so we don't try to change to it below
64 else:
65 if not os.path.isdir("build"):
66 os.mkdir("build")
67 do2to3.main(".", python3_source)
942ef84 @tiagoantao setup.py is now Python 3 aware
tiagoantao authored
68
69 from distutils.core import setup
70 from distutils.core import Command
71 from distutils.command.install import install
72 from distutils.command.build_py import build_py
73 from distutils.command.build_ext import build_ext
74 from distutils.extension import Extension
75
a8ae40f now installs Martel and doesn't complain about it
jchang authored
76 _CHECKED = None
77 def check_dependencies_once():
78 # Call check_dependencies, but cache the result for subsequent
79 # calls.
80 global _CHECKED
81 if _CHECKED is None:
82 _CHECKED = check_dependencies()
83 return _CHECKED
84
85 def check_dependencies():
86 """Return whether the installation should continue."""
87 # There should be some way for the user to tell specify not to
88 # check dependencies. For example, it probably should not if
89 # the user specified "-q". However, I'm not sure where
90 # distutils stores that information. Also, install has a
91 # --force option that gets saved in self.user_options. It
92 # means overwrite previous installations. If the user has
93 # forced an installation, should we also ignore dependencies?
7452113 @peterjc Simplify the dependency checking code since we only care about NumPy,…
peterjc authored
94
95 # We only check for NumPy, as this is a compile time dependency
96 if is_Numpy_installed() : return True
0627102 @peterjc Don't nag Jython users about NumPy not being installed. Fix from Kyle…
peterjc authored
97
98 if os.name=='java':
99 return True #NumPy is not avaliable for Jython (for now)
100
942ef84 @tiagoantao setup.py is now Python 3 aware
tiagoantao authored
101 print ("""
7452113 @peterjc Simplify the dependency checking code since we only care about NumPy,…
peterjc authored
102 Numerical Python (NumPy) is not installed.
103
a8ae40f now installs Martel and doesn't complain about it
jchang authored
104 This package is required for many Biopython features. Please install
7452113 @peterjc Simplify the dependency checking code since we only care about NumPy,…
peterjc authored
105 it before you install Biopython. You can install Biopython anyway, but
106 anything dependent on NumPy will not work. If you do this, and later
107 install NumPy, you should then re-install Biopython.
108
109 You can find NumPy at http://numpy.scipy.org
942ef84 @tiagoantao setup.py is now Python 3 aware
tiagoantao authored
110 """)
7452113 @peterjc Simplify the dependency checking code since we only care about NumPy,…
peterjc authored
111 # exit automatically if running as part of some script
112 # (e.g. PyPM, ActiveState's Python Package Manager)
113 if not sys.stdout.isatty() :
114 sys.exit(-1)
115 # We can ask the user
116 return get_yes_or_no("Do you want to continue this installation?", False)
a8ae40f now installs Martel and doesn't complain about it
jchang authored
117
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
118 class install_biopython(install):
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
119 """Override the standard install to check for dependencies.
120
121 This will just run the normal install, and then print warning messages
122 if packages are missing.
b7761b6 Fixes to imported EUtils to get it working happily with Bio:
chapmanb authored
123
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
124 """
4e4c3aa @chapmanb Add support for single-version-externally-managed flag which pip asks…
chapmanb authored
125 # Adds support for the single-version-externally-managed flag
126 # which is present in setuptools but not distutils. pip requires it.
127 # In setuptools this forces installation the "old way" which we
128 # only support here, so we just make it a no-op.
129 user_options = install.user_options + [
130 ('single-version-externally-managed', None,
131 "used by system package builders to create 'flat' eggs"),
132 ]
133 boolean_options = install.boolean_options + [
134 'single-version-externally-managed',
135 ]
136 def initialize_options(self):
137 install.initialize_options(self)
138 self.single_version_externally_managed = None
139
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
140 def run(self):
a8ae40f now installs Martel and doesn't complain about it
jchang authored
141 if check_dependencies_once():
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
142 # Run the normal install.
143 install.run(self)
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
144
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
145 class build_py_biopython(build_py):
146 def run(self):
a8ae40f now installs Martel and doesn't complain about it
jchang authored
147 if not check_dependencies_once():
148 return
593e65e Added Affymetrix package from Harry Zuzan
chapmanb authored
149 # Add software that requires Numpy to be installed.
a8ae40f now installs Martel and doesn't complain about it
jchang authored
150 if is_Numpy_installed():
593e65e Added Affymetrix package from Harry Zuzan
chapmanb authored
151 self.packages.extend(NUMPY_PACKAGES)
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
152 build_py.run(self)
fc90717 Whew, final thing to add! Added code for displaying pretty pictures u…
chapmanb authored
153
94b412a See bug #2375. Copy data files to the build directory, so the tests run
mdehoon authored
154
a8ae40f now installs Martel and doesn't complain about it
jchang authored
155 class build_ext_biopython(build_ext):
156 def run(self):
157 if not check_dependencies_once():
158 return
159 build_ext.run(self)
160
a151e5c workaround for bug in distutils that prevents one from compiling both…
grouse authored
161
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
162 class test_biopython(Command):
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
163 """Run all of the tests for the package.
164
165 This is a automatic test run class to make distutils kind of act like
166 perl. With this you can do:
167
168 python setup.py build
169 python setup.py install
170 python setup.py test
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
171
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
172 """
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
173 description = "Automatically run the test suite for Biopython."
844496e @peterjc Removing the now redundant --no-gui argument for the test suite.
peterjc authored
174 user_options = []
1d16b65 The modification to setup.py gives the option of --no-gui for the com…
lasher authored
175
176 def initialize_options(self):
844496e @peterjc Removing the now redundant --no-gui argument for the test suite.
peterjc authored
177 pass
1d16b65 The modification to setup.py gives the option of --no-gui for the com…
lasher authored
178
179 def finalize_options(self):
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
180 pass
1d16b65 The modification to setup.py gives the option of --no-gui for the com…
lasher authored
181
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
182 def run(self):
183 this_dir = os.getcwd()
184
185 # change to the test dir and run the tests
186 os.chdir("Tests")
b720e3d In Python 2.3.2, the current directory '' is not included in the path.
grouse authored
187 sys.path.insert(0, '')
844496e @peterjc Removing the now redundant --no-gui argument for the test suite.
peterjc authored
188 import run_tests
189 run_tests.main([])
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
190
191 # change back to the current directory
192 os.chdir(this_dir)
193
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
194 def can_import(module_name):
195 """can_import(module_name) -> module or None"""
196 try:
197 return __import__(module_name)
198 except ImportError:
199 return None
200
201 def is_Numpy_installed():
7452113 @peterjc Simplify the dependency checking code since we only care about NumPy,…
peterjc authored
202 return bool(can_import("numpy"))
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
203
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
204 # --- set up the packages we are going to install
205 # standard biopython packages
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
206 PACKAGES = [
207 'Bio',
208 'Bio.Align',
32c4f4b @peterjc Adding wrapper from Cymon Cox for the MUSCLE alignment tool, with bas…
peterjc authored
209 'Bio.Align.Applications',
1231257 @peterjc Include Bio.AlignIO in installation
peterjc authored
210 'Bio.AlignIO',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
211 'Bio.Alphabet',
212 'Bio.Application',
213 'Bio.Blast',
0cd0e9c Modified Files:
idoerg authored
214 'Bio.CAPS',
76ce5ca Added Compass parsing code contributed by James Casbon.
chapmanb authored
215 'Bio.Compass',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
216 'Bio.Clustalw',
217 'Bio.Crystal',
218 'Bio.Data',
219 'Bio.Emboss',
8521e25 Moving Bio/Entrez.py to Bio/Entrez/__init__.py.
mdehoon authored
220 'Bio.Entrez',
c23628e Now that Bio/ExPASy.py was replaced by Bio/ExPASy/__init__.py, we nee…
mdehoon authored
221 'Bio.ExPASy',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
222 'Bio.FSSP',
223 'Bio.GA',
224 'Bio.GA.Crossover',
225 'Bio.GA.Mutation',
226 'Bio.GA.Repair',
227 'Bio.GA.Selection',
228 'Bio.GenBank',
229 'Bio.Geo',
230 'Bio.Graphics',
cace008 @peterjc Initial check in of GenomeDiagram by Leighton Pritchard, converted fo…
peterjc authored
231 'Bio.Graphics.GenomeDiagram',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
232 'Bio.HMM',
233 'Bio.InterPro',
234 'Bio.KEGG',
235 'Bio.KEGG.Compound',
236 'Bio.KEGG.Enzyme',
237 'Bio.KEGG.Map',
238 'Bio.Medline',
9deacf3 added Bio.Motif to setup.py
bartek authored
239 'Bio.Motif',
fc68931 @peterjc Need to install Bio.Motif.PArsers
peterjc authored
240 'Bio.Motif.Parsers',
594a86a @peterjc Include Bio.Motif.Applications module
peterjc authored
241 'Bio.Motif.Applications',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
242 'Bio.NeuralNetwork',
243 'Bio.NeuralNetwork.BackPropagation',
244 'Bio.NeuralNetwork.Gene',
c2c11a9 Biopython now works with Python >= 2.3
idoerg authored
245 'Bio.Nexus',
7bcfbce Adding NMR files kindly contributed by Bob Bussell
chapmanb authored
246 'Bio.NMR',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
247 'Bio.Parsers',
248 'Bio.Pathway',
249 'Bio.Pathway.Rep',
250 'Bio.PDB',
983daba Add Bio.PDB.mmCIF (but not MMFIFlex) as a module to make sure that
mdehoon authored
251 'Bio.PDB.mmCIF',
4f07b8a Added Bio.PopGen module by Tiago Antao.
mdehoon authored
252 'Bio.PopGen',
253 'Bio.PopGen.Async',
254 'Bio.PopGen.FDist',
255 'Bio.PopGen.GenePop',
96f01d5 2375: Activating SimCoal on Biopython setup
tiagoantao authored
256 'Bio.PopGen.SimCoal',
05f9ba2 Added Restriction enzyme package contributed by Frederic Sohm. This i…
chapmanb authored
257 'Bio.Restriction',
258 'Bio.Restriction._Update',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
259 'Bio.SCOP',
260 'Bio.SeqIO',
261 'Bio.SeqUtils',
2214cae Added Sequencing directory to packages
chapmanb authored
262 'Bio.Sequencing',
42be9a8 Add Novoalign commandline submitted by Osvaldo Zagordi; Bug 2904
chapmanb authored
263 'Bio.Sequencing.Applications',
7738632 Added Bio.Statistics.
mdehoon authored
264 'Bio.Statistics',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
265 'Bio.SubsMat',
266 'Bio.SVDSuperimposer',
267 'Bio.SwissProt',
eb394c0 @chapmanb Whoops. Revert setup.py to latest version
chapmanb authored
268 'Bio.Phylo',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
269 'Bio.UniGene',
3a5d550 Adding Bio.Wise to the distribution
grouse authored
270 'Bio.Wise',
d81c27e @peterjc Removed the Martel special case code (it should be safe to assume tha…
peterjc authored
271 #Other top level packages,
272 'BioSQL',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
273 ]
274
593e65e Added Affymetrix package from Harry Zuzan
chapmanb authored
275 # packages that require Numeric Python
276 NUMPY_PACKAGES = [
277 'Bio.Affy',
278 'Bio.Cluster',
379fbb7 Switched from the old Numerical Python to the new NumPy. Bio.KDTree i…
mdehoon authored
279 'Bio.KDTree',
593e65e Added Affymetrix package from Harry Zuzan
chapmanb authored
280 ]
281
ae19435 @peterjc Fix from Kyle Ellrott to get setup.py to work on Jython 2.5.0 by not …
peterjc authored
282 if os.name == 'java' :
283 # Jython doesn't support C extensions
284 EXTENSIONS = []
f048890 @peterjc Update setup.py to make testing with 2to3 easier
peterjc authored
285 elif sys.version_info[0] == 3:
286 # TODO - Must update our C extensions for Python 3
9b58027 Updating cpairwise2module for Python 3. This module could use some fu…
Michiel de Hoon authored
287 EXTENSIONS = [
288 Extension('Bio.cpairwise2',
289 ['Bio/cpairwise2module.c'],
290 include_dirs=["Bio"]
291 ),
234fb50 modified Bio.Nexus.cnexus for Python 3
Michiel de Hoon authored
292 Extension('Bio.Nexus.cnexus',
293 ['Bio/Nexus/cnexus.c']
294 ),
9b58027 Updating cpairwise2module for Python 3. This module could use some fu…
Michiel de Hoon authored
295 ]
ae19435 @peterjc Fix from Kyle Ellrott to get setup.py to work on Jython 2.5.0 by not …
peterjc authored
296 else :
297 EXTENSIONS = [
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
298 Extension('Bio.cpairwise2',
c21a741 Put csupport in the pairwise2 module, as currently it is not used any…
Michiel de Hoon authored
299 ['Bio/cpairwise2module.c'],
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
300 include_dirs=["Bio"]
301 ),
302 Extension('Bio.trie',
303 ['Bio/triemodule.c',
304 'Bio/trie.c'],
305 include_dirs=["Bio"]
306 ),
844496e @peterjc Removing the now redundant --no-gui argument for the test suite.
peterjc authored
307 #Commented out due to the build dependency on flex, see Bug 2619
308 # Extension('Bio.PDB.mmCIF.MMCIFlex',
309 # ['Bio/PDB/mmCIF/lex.yy.c',
310 # 'Bio/PDB/mmCIF/MMCIFlexmodule.c'],
311 # include_dirs=["Bio"],
312 # libraries=["fl"]
313 # ),
2800c6c *** empty log message ***
idoerg authored
314 Extension('Bio.Nexus.cnexus',
c2c11a9 Biopython now works with Python >= 2.3
idoerg authored
315 ['Bio/Nexus/cnexus.c']
316 ),
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
317 ]
318
48d1716 @peterjc Seems must define list of extensions earlier for them to be installed…
peterjc authored
319 #Add extensions that requires NumPy to build
320 if is_Numpy_installed():
321 import numpy
322 numpy_include_dir = numpy.get_include()
323 EXTENSIONS.append(
324 Extension('Bio.Cluster.cluster',
325 ['Bio/Cluster/clustermodule.c',
326 'Bio/Cluster/cluster.c'],
327 include_dirs=[numpy_include_dir],
328 ))
329 EXTENSIONS.append(
330 Extension('Bio.KDTree._CKDTree',
331 ["Bio/KDTree/KDTree.c",
332 "Bio/KDTree/KDTreemodule.c"],
333 include_dirs=[numpy_include_dir],
334 ))
335 EXTENSIONS.append(
336 Extension('Bio.Motif._pwm',
337 ["Bio/Motif/_pwm.c"],
338 include_dirs=[numpy_include_dir],
339 ))
340
ae19435 @peterjc Fix from Kyle Ellrott to get setup.py to work on Jython 2.5.0 by not …
peterjc authored
341
839c345 @peterjc Adding Bio.__version__ and using this in setup.py automatically. The…
peterjc authored
342 #We now define the Biopython version number in Bio/__init__.py
343 #Here we can't use "import Bio" then "Bio.__version__" as that would
344 #tell us the version of Biopython already installed (if any).
345 __version__ = "Undefined"
346 for line in open('Bio/__init__.py'):
347 if (line.startswith('__version__')):
348 exec(line.strip())
349
1eeed11 @peterjc Call 2to3 from setup.py on Python 3 (like NumPy)
peterjc authored
350 #Simple trick to use the 2to3 converted source under Python 3,
351 #change the current directory before/after running setup.
352 #Note as a side effect there will be a build folder underneath
353 #the python3_source folder.
354 old_path = os.getcwd()
355 try:
356 src_path = python3_source
357 except NameError:
358 src_path = os.path.dirname(os.path.abspath(sys.argv[0]))
359 os.chdir(src_path)
360 sys.path.insert(0, src_path)
361 try:
362 setup(
363 name='biopython',
364 version=__version__,
365 author='The Biopython Consortium',
366 author_email='biopython@biopython.org',
367 url='http://www.biopython.org/',
368 description='Freely available tools for computational molecular biology.',
369 download_url='http://biopython.org/DIST/',
370 cmdclass={
371 "install" : install_biopython,
372 "build_py" : build_py_biopython,
373 "build_ext" : build_ext_biopython,
374 "test" : test_biopython,
375 },
376 packages=PACKAGES,
377 ext_modules=EXTENSIONS,
378 package_data = {'Bio.Entrez': ['DTDs/*.dtd', 'DTDs/*.ent', 'DTDs/*.mod'],
379 'Bio.PopGen': ['SimCoal/data/*.par'],
380 },
381 #install_requires = ['numpy>=1.0'],
382 #extras_require = {
383 # 'PDF' : ['reportlab>=2.0']
384 # }
385 )
386 finally:
387 del sys.path[0]
388 os.chdir(old_path)
Something went wrong with that request. Please try again.