forked from biopython/biopython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
264 lines (227 loc) · 7.68 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
"""setuptools based setup script for Biopython.
This uses setuptools which is now the standard python mechanism for
installing packages. If you have downloaded and uncompressed the
Biopython source code, or fetched it from git, for the simplest
installation just type the command::
python setup.py install
However, you would normally install the latest Biopython release from
the PyPI archive with::
pip install biopython
For more in-depth instructions, see the installation section of the
Biopython manual, linked to from:
http://biopython.org/wiki/Documentation
Or, if all else fails, feel free to write to the sign up to the Biopython
mailing list and ask for help. See:
http://biopython.org/wiki/Mailing_lists
"""
import sys
import os
import ast
try:
from setuptools import setup
from setuptools import Command
from setuptools import Extension
except ImportError:
sys.exit(
"We need the Python library setuptools to be installed. "
"Try running: python -m ensurepip"
)
if "bdist_wheel" in sys.argv:
try:
import wheel # noqa: F401
except ImportError:
sys.exit(
"We need both setuptools AND wheel packages installed "
"for bdist_wheel to work. Try running: pip install wheel"
)
# Make sure we have the right Python version.
MIN_PY_VER = (3, 8)
if sys.version_info[:2] < MIN_PY_VER:
sys.stderr.write(
("ERROR: Biopython requires Python %i.%i or later. " % MIN_PY_VER)
+ ("Python %d.%d detected.\n" % sys.version_info[:2])
)
sys.exit(1)
class test_biopython(Command):
"""Run all of the tests for the package.
This is a automatic test run class to make distutils kind of act like
perl. With this you can do:
python setup.py build
python setup.py install
python setup.py test
"""
description = "Automatically run the test suite for Biopython."
user_options = [("offline", None, "Don't run online tests")]
def initialize_options(self):
"""No-op, initialise options."""
self.offline = None
def finalize_options(self):
"""No-op, finalise options."""
pass
def run(self):
"""Run the tests."""
this_dir = os.getcwd()
# change to the test dir and run the tests
os.chdir("Tests")
sys.path.insert(0, "")
import run_tests
if self.offline:
run_tests.main(["--offline"])
else:
run_tests.main([])
# change back to the current directory
os.chdir(this_dir)
def can_import(module_name):
"""Check we can import the requested module."""
try:
return __import__(module_name)
except ImportError:
return None
# Using requirements.txt is preferred for an application
# (and likely will pin specific version numbers), using
# setup.py's install_requires is preferred for a library
# (and should try not to be overly narrow with versions).
REQUIRES = ["numpy"]
# --- set up the packages we are going to install
# standard biopython packages
PACKAGES = [
"Bio",
"Bio.Affy",
"Bio.Align",
"Bio.Align.Applications",
"Bio.Align.substitution_matrices",
"Bio.AlignIO",
"Bio.Alphabet",
"Bio.Application",
"Bio.Blast",
"Bio.CAPS",
"Bio.Cluster",
"Bio.codonalign",
"Bio.Compass",
"Bio.Data",
"Bio.Emboss",
"Bio.Entrez",
"Bio.ExPASy",
"Bio.GenBank",
"Bio.Geo",
"Bio.Graphics",
"Bio.Graphics.GenomeDiagram",
"Bio.HMM",
"Bio.KEGG",
"Bio.KEGG.Compound",
"Bio.KEGG.Enzyme",
"Bio.KEGG.Gene",
"Bio.KEGG.Map",
"Bio.PDB.mmtf",
"Bio.KEGG.KGML",
"Bio.Medline",
"Bio.motifs",
"Bio.motifs.applications",
"Bio.motifs.jaspar",
"Bio.Nexus",
"Bio.NMR",
"Bio.Pathway",
"Bio.Pathway.Rep",
"Bio.PDB",
"Bio.phenotype",
"Bio.PopGen",
"Bio.PopGen.GenePop",
"Bio.Restriction",
"Bio.SCOP",
"Bio.SearchIO",
"Bio.SearchIO._model",
"Bio.SearchIO.BlastIO",
"Bio.SearchIO.HHsuiteIO",
"Bio.SearchIO.HmmerIO",
"Bio.SearchIO.ExonerateIO",
"Bio.SearchIO.InterproscanIO",
"Bio.SeqIO",
"Bio.SeqUtils",
"Bio.Sequencing",
"Bio.Sequencing.Applications",
"Bio.SVDSuperimposer",
"Bio.PDB.QCPSuperimposer",
"Bio.SwissProt",
"Bio.TogoWS",
"Bio.Phylo",
"Bio.Phylo.Applications",
"Bio.Phylo.PAML",
"Bio.UniGene",
"Bio.UniProt",
# Other top level packages,
"BioSQL",
]
EXTENSIONS = [
Extension("Bio.Align._codonaligner", ["Bio/Align/_codonaligner.c"]),
Extension("Bio.Align._pairwisealigner", ["Bio/Align/_pairwisealigner.c"]),
Extension("Bio.cpairwise2", ["Bio/cpairwise2module.c"]),
Extension("Bio.Nexus.cnexus", ["Bio/Nexus/cnexus.c"]),
Extension(
"Bio.PDB.QCPSuperimposer.qcprotmodule",
["Bio/PDB/QCPSuperimposer/qcprotmodule.c"],
),
Extension("Bio.motifs._pwm", ["Bio/motifs/_pwm.c"]),
Extension(
"Bio.Cluster._cluster", ["Bio/Cluster/cluster.c", "Bio/Cluster/clustermodule.c"]
),
Extension("Bio.PDB.kdtrees", ["Bio/PDB/kdtrees.c"]),
Extension("Bio.PDB.ccealign", ["Bio/PDB/ccealignmodule.c"]),
Extension("Bio.SeqIO._twoBitIO", ["Bio/SeqIO/_twoBitIO.c"]),
]
def get_version():
"""Get version number from __init__.py."""
for line in open("Bio/__init__.py"):
if line.startswith("__version__ = "):
return ast.literal_eval(line.split("=")[1].strip())
return "Undefined"
__version__ = get_version()
# We now load in our reStructuredText README.rst file to pass explicitly in the
# metadata, since at time of writing PyPI did not do this for us.
#
# Must make encoding explicit to avoid any conflict with the local default.
# Currently keeping README as ASCII (might switch to UTF8 later if needed).
# If any invalid character does appear in README, this will fail and alert us.
with open("README.rst", encoding="ascii") as handle:
readme_rst = handle.read()
setup(
name="biopython",
version=__version__,
author="The Biopython Contributors",
author_email="[email protected]",
url="https://biopython.org/",
description="Freely available tools for computational molecular biology.",
long_description=readme_rst,
project_urls={
"Documentation": "https://biopython.org/wiki/Documentation",
"Source": "https://github.com/biopython/biopython/",
"Tracker": "https://github.com/biopython/biopython/issues",
},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: Freely Distributable",
# Technically the "Biopython License Agreement" is not OSI approved,
# but is almost https://opensource.org/licenses/HPND so might put:
# 'License :: OSI Approved',
# To resolve this we are moving to dual-licensing with 3-clause BSD:
# 'License :: OSI Approved :: BSD License',
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Software Development :: Libraries :: Python Modules",
],
cmdclass={"test": test_biopython},
packages=PACKAGES,
ext_modules=EXTENSIONS,
include_package_data=True, # done via MANIFEST.in under setuptools
install_requires=REQUIRES,
python_requires=">=%i.%i" % MIN_PY_VER,
)