Skip to content
Newer
Older
100644 362 lines (317 sloc) 10.8 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 insta…
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,…
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…
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,…
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,…
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,…
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 insta…
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 insta…
chapmanb authored
119 """
4e4c3aa @chapmanb Add support for single-version-externally-managed flag which pip asks…
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 insta…
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 insta…
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 u…
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
a573247 Even more kludgy fix for c++ compiling with setup.py -- this time it …
chapmanb authored
154 # add software that requires NumPy to install
4c9d7e7 @peterjc Explicitly disable C extensions using numpy on Python 3
peterjc authored
155 # TODO - Convert these for Python 3
156 if is_Numpy_installed() and sys.version_info[0] < 3:
2669c4d - Updates to move from Numeric python to NumPy. Python modules have b…
chapmanb authored
157 import numpy
379fbb7 Switched from the old Numerical Python to the new NumPy. Bio.KDTree i…
mdehoon authored
158 numpy_include_dir = numpy.get_include()
159 self.extensions.append(
2669c4d - Updates to move from Numeric python to NumPy. Python modules have b…
chapmanb authored
160 Extension('Bio.Cluster.cluster',
161 ['Bio/Cluster/clustermodule.c',
162 'Bio/Cluster/cluster.c'],
379fbb7 Switched from the old Numerical Python to the new NumPy. Bio.KDTree i…
mdehoon authored
163 include_dirs=[numpy_include_dir],
164 ))
165 self.extensions.append(
166 Extension('Bio.KDTree._CKDTree',
167 ["Bio/KDTree/KDTree.c",
168 "Bio/KDTree/KDTreemodule.c"],
169 include_dirs=[numpy_include_dir],
2669c4d - Updates to move from Numeric python to NumPy. Python modules have b…
chapmanb authored
170 ))
622bb8e Adding a helper module to enable fast calculation of position-weight …
mdehoon authored
171 self.extensions.append(
172 Extension('Bio.Motif._pwm',
173 ["Bio/Motif/_pwm.c"],
174 include_dirs=[numpy_include_dir],
175 ))
a8ae40f now installs Martel and doesn't complain about it
jchang authored
176 build_ext.run(self)
177
a151e5c workaround for bug in distutils that prevents one from compiling both…
grouse authored
178
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
179 class test_biopython(Command):
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
180 """Run all of the tests for the package.
181
182 This is a automatic test run class to make distutils kind of act like
183 perl. With this you can do:
184
185 python setup.py build
186 python setup.py install
187 python setup.py test
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
188
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
189 """
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
190 description = "Automatically run the test suite for Biopython."
844496e @peterjc Removing the now redundant --no-gui argument for the test suite.
peterjc authored
191 user_options = []
1d16b65 The modification to setup.py gives the option of --no-gui for the com…
lasher authored
192
193 def initialize_options(self):
844496e @peterjc Removing the now redundant --no-gui argument for the test suite.
peterjc authored
194 pass
1d16b65 The modification to setup.py gives the option of --no-gui for the com…
lasher authored
195
196 def finalize_options(self):
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
197 pass
1d16b65 The modification to setup.py gives the option of --no-gui for the com…
lasher authored
198
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
199 def run(self):
200 this_dir = os.getcwd()
201
202 # change to the test dir and run the tests
203 os.chdir("Tests")
b720e3d In Python 2.3.2, the current directory '' is not included in the path.
grouse authored
204 sys.path.insert(0, '')
844496e @peterjc Removing the now redundant --no-gui argument for the test suite.
peterjc authored
205 import run_tests
206 run_tests.main([])
b50486d Allow setup.py to be able to run tests with python setup.py test
chapmanb authored
207
208 # change back to the current directory
209 os.chdir(this_dir)
210
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
211 def can_import(module_name):
212 """can_import(module_name) -> module or None"""
213 try:
214 return __import__(module_name)
215 except ImportError:
216 return None
217
218 def is_Numpy_installed():
7452113 @peterjc Simplify the dependency checking code since we only care about NumPy,…
peterjc authored
219 return bool(can_import("numpy"))
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
220
7db13b0 Updated to check for dependencies and print out warnings and to insta…
chapmanb authored
221 # --- set up the packages we are going to install
222 # standard biopython packages
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
223 PACKAGES = [
224 'Bio',
225 'Bio.Align',
32c4f4b @peterjc Adding wrapper from Cymon Cox for the MUSCLE alignment tool, with bas…
peterjc authored
226 'Bio.Align.Applications',
1231257 @peterjc Include Bio.AlignIO in installation
peterjc authored
227 'Bio.AlignIO',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
228 'Bio.Alphabet',
229 'Bio.Application',
230 'Bio.Blast',
0cd0e9c Modified Files:
idoerg authored
231 'Bio.CAPS',
76ce5ca Added Compass parsing code contributed by James Casbon.
chapmanb authored
232 'Bio.Compass',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
233 'Bio.Clustalw',
234 'Bio.Crystal',
235 'Bio.Data',
236 'Bio.Emboss',
8521e25 Moving Bio/Entrez.py to Bio/Entrez/__init__.py.
mdehoon authored
237 'Bio.Entrez',
c23628e Now that Bio/ExPASy.py was replaced by Bio/ExPASy/__init__.py, we nee…
mdehoon authored
238 'Bio.ExPASy',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
239 'Bio.FSSP',
240 'Bio.GA',
241 'Bio.GA.Crossover',
242 'Bio.GA.Mutation',
243 'Bio.GA.Repair',
244 'Bio.GA.Selection',
245 'Bio.GenBank',
246 'Bio.Geo',
247 'Bio.GFF',
248 'Bio.Graphics',
cace008 @peterjc Initial check in of GenomeDiagram by Leighton Pritchard, converted fo…
peterjc authored
249 'Bio.Graphics.GenomeDiagram',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
250 'Bio.HMM',
251 'Bio.InterPro',
252 'Bio.KEGG',
253 'Bio.KEGG.Compound',
254 'Bio.KEGG.Enzyme',
255 'Bio.KEGG.Map',
256 'Bio.Medline',
9deacf3 added Bio.Motif to setup.py
bartek authored
257 'Bio.Motif',
fc68931 @peterjc Need to install Bio.Motif.PArsers
peterjc authored
258 'Bio.Motif.Parsers',
594a86a @peterjc Include Bio.Motif.Applications module
peterjc authored
259 'Bio.Motif.Applications',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
260 'Bio.NeuralNetwork',
261 'Bio.NeuralNetwork.BackPropagation',
262 'Bio.NeuralNetwork.Gene',
c2c11a9 Biopython now works with Python >= 2.3
idoerg authored
263 'Bio.Nexus',
7bcfbce Adding NMR files kindly contributed by Bob Bussell
chapmanb authored
264 'Bio.NMR',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
265 'Bio.Parsers',
266 'Bio.Pathway',
267 'Bio.Pathway.Rep',
268 'Bio.PDB',
983daba Add Bio.PDB.mmCIF (but not MMFIFlex) as a module to make sure that
mdehoon authored
269 'Bio.PDB.mmCIF',
4f07b8a Added Bio.PopGen module by Tiago Antao.
mdehoon authored
270 'Bio.PopGen',
271 'Bio.PopGen.Async',
272 'Bio.PopGen.FDist',
273 'Bio.PopGen.GenePop',
96f01d5 2375: Activating SimCoal on Biopython setup
tiagoantao authored
274 'Bio.PopGen.SimCoal',
05f9ba2 Added Restriction enzyme package contributed by Frederic Sohm. This i…
chapmanb authored
275 'Bio.Restriction',
276 'Bio.Restriction._Update',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
277 'Bio.SCOP',
278 'Bio.SeqIO',
279 'Bio.SeqUtils',
2214cae Added Sequencing directory to packages
chapmanb authored
280 'Bio.Sequencing',
42be9a8 Add Novoalign commandline submitted by Osvaldo Zagordi; Bug 2904
chapmanb authored
281 'Bio.Sequencing.Applications',
7738632 Added Bio.Statistics.
mdehoon authored
282 'Bio.Statistics',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
283 'Bio.SubsMat',
284 'Bio.SVDSuperimposer',
285 'Bio.SwissProt',
eb394c0 @chapmanb Whoops. Revert setup.py to latest version
chapmanb authored
286 'Bio.Phylo',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
287 'Bio.UniGene',
3a5d550 Adding Bio.Wise to the distribution
grouse authored
288 'Bio.Wise',
d81c27e @peterjc Removed the Martel special case code (it should be safe to assume tha…
peterjc authored
289 #Other top level packages,
290 'BioSQL',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
291 ]
292
593e65e Added Affymetrix package from Harry Zuzan
chapmanb authored
293 # packages that require Numeric Python
294 NUMPY_PACKAGES = [
295 'Bio.Affy',
296 'Bio.Cluster',
379fbb7 Switched from the old Numerical Python to the new NumPy. Bio.KDTree i…
mdehoon authored
297 'Bio.KDTree',
593e65e Added Affymetrix package from Harry Zuzan
chapmanb authored
298 ]
299
ae19435 @peterjc Fix from Kyle Ellrott to get setup.py to work on Jython 2.5.0 by not …
peterjc authored
300 if os.name == 'java' :
301 # Jython doesn't support C extensions
302 EXTENSIONS = []
f048890 @peterjc Update setup.py to make testing with 2to3 easier
peterjc authored
303 elif sys.version_info[0] == 3:
304 # TODO - Must update our C extensions for Python 3
305 EXTENSIONS = []
ae19435 @peterjc Fix from Kyle Ellrott to get setup.py to work on Jython 2.5.0 by not …
peterjc authored
306 else :
307 EXTENSIONS = [
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
308 Extension('Bio.cpairwise2',
c21a741 Put csupport in the pairwise2 module, as currently it is not used any…
Michiel de Hoon authored
309 ['Bio/cpairwise2module.c'],
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
310 include_dirs=["Bio"]
311 ),
312 Extension('Bio.trie',
313 ['Bio/triemodule.c',
314 'Bio/trie.c'],
315 include_dirs=["Bio"]
316 ),
844496e @peterjc Removing the now redundant --no-gui argument for the test suite.
peterjc authored
317 #Commented out due to the build dependency on flex, see Bug 2619
318 # Extension('Bio.PDB.mmCIF.MMCIFlex',
319 # ['Bio/PDB/mmCIF/lex.yy.c',
320 # 'Bio/PDB/mmCIF/MMCIFlexmodule.c'],
321 # include_dirs=["Bio"],
322 # libraries=["fl"]
323 # ),
2800c6c *** empty log message ***
idoerg authored
324 Extension('Bio.Nexus.cnexus',
c2c11a9 Biopython now works with Python >= 2.3
idoerg authored
325 ['Bio/Nexus/cnexus.c']
326 ),
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
327 ]
328
ae19435 @peterjc Fix from Kyle Ellrott to get setup.py to work on Jython 2.5.0 by not …
peterjc authored
329
839c345 @peterjc Adding Bio.__version__ and using this in setup.py automatically. The …
peterjc authored
330 #We now define the Biopython version number in Bio/__init__.py
331 #Here we can't use "import Bio" then "Bio.__version__" as that would
332 #tell us the version of Biopython already installed (if any).
333 __version__ = "Undefined"
334 for line in open('Bio/__init__.py'):
335 if (line.startswith('__version__')):
336 exec(line.strip())
337
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
338 setup(
339 name='biopython',
839c345 @peterjc Adding Bio.__version__ and using this in setup.py automatically. The …
peterjc authored
340 version=__version__,
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
341 author='The Biopython Consortium',
342 author_email='biopython@biopython.org',
343 url='http://www.biopython.org/',
65df9bd Minor changes to setup file to make it compatible with the python pac…
chapmanb authored
344 description='Freely available tools for computational molecular biology.',
345 download_url='http://biopython.org/DIST/',
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
346 cmdclass={
347 "install" : install_biopython,
348 "build_py" : build_py_biopython,
a8ae40f now installs Martel and doesn't complain about it
jchang authored
349 "build_ext" : build_ext_biopython,
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
350 "test" : test_biopython,
351 },
352 packages=PACKAGES,
353 ext_modules=EXTENSIONS,
eb394c0 @chapmanb Whoops. Revert setup.py to latest version
chapmanb authored
354 package_data = {'Bio.Entrez': ['DTDs/*.dtd', 'DTDs/*.ent', 'DTDs/*.mod'],
e49dd38 Use Python 2.4 capabilities to install data files.
mdehoon authored
355 'Bio.PopGen': ['SimCoal/data/*.par'],
356 },
844496e @peterjc Removing the now redundant --no-gui argument for the test suite.
peterjc authored
357 #install_requires = ['numpy>=1.0'],
65df9bd Minor changes to setup file to make it compatible with the python pac…
chapmanb authored
358 #extras_require = {
359 # 'PDF' : ['reportlab>=2.0']
360 # }
fdcb82e added code so that it now checks for dependencies before biopython is
jchang authored
361 )
Something went wrong with that request. Please try again.