Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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