forked from bxlab/bx-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
227 lines (194 loc) · 8.89 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
import platform
import sys
from distutils.core import Command
from glob import glob
if sys.version_info < (2, 6):
sys.exit("ERROR: bx-python requires Python 2.6 or greater")
elif sys.version_info > (3, ) and sys.version_info < (3, 3):
sys.exit("ERROR: bx-python requires Python 3.3 or greater")
try:
from setuptools import setup, find_packages
except ImportError:
from ez_setup import use_setuptools
use_setuptools()
from setuptools import Extension # noqa: E402
def main():
metadata = dict(
name="bx-python",
version="0.8.6",
setup_requires=['numpy', 'cython'],
install_requires=['numpy', 'six'],
py_modules=['psyco_full'],
package_dir={'': 'lib'},
package_data={'': ['*.ps']},
scripts=glob("scripts/*.py"),
test_suite='nose.collector',
tests_require=['nose', 'python-lzo'],
author="James Taylor, Bob Harris, David King, Brent Pedersen, Kanwei Li, and others",
author_email="[email protected]",
description="Tools for manipulating biological data, particularly multiple sequence alignments",
url="https://github.com/bxlab/bx-python",
license="MIT",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Software Development :: Libraries :: Python Modules"],
zip_safe=False,
dependency_links=[],
cmdclass=command_classes)
numpy = None
try:
import numpy
# Suppress numpy tests
numpy.test = None
except Exception:
pass
if len(sys.argv) >= 2 and \
('--help' in sys.argv[1:] or sys.argv[1] in ('--help-commands', 'egg_info', '--version', 'clean')):
# For these actions, NumPy is not required.
#
# They are required to succeed without Numpy for example when
# pip is used to install when Numpy is not yet present in
# the system.
pass
else:
if numpy is None:
raise Exception("numpy must be installed to build")
metadata['packages'] = find_packages('lib')
metadata['ext_modules'] = get_extension_modules(numpy_include=numpy.get_include())
setup(**metadata)
# ---- Commands -------------------------------------------------------------
# Use build_ext from Cython if found
command_classes = {}
try:
import Cython.Distutils
command_classes['build_ext'] = Cython.Distutils.build_ext
except Exception:
pass
# Run 2to3 builder if we're on Python 3.x, from
# http://wiki.python.org/moin/PortingPythonToPy3k
try:
from distutils.command.build_py import build_py_2to3 as build_py
except ImportError:
# 2.x
from distutils.command.build_py import build_py
command_classes['build_py'] = build_py
# Use epydoc if found
try:
import pkg_resources
pkg_resources.require("epydoc")
import epydoc.cli
import os
import os.path
# Create command class to build API documentation
class BuildAPIDocs(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
# Save working directory and args
old_argv = sys.argv
old_cwd = os.getcwd()
# Build command line for Epydoc
sys.argv = """epydoc.py bx --verbose --html --simple-term
--exclude=._
--exclude=_tests
--docformat=reStructuredText
--output=../doc/docbuild/html/apidoc""".split()
# Make output directory
if not os.path.exists("./doc/docbuild/html/apidoc"):
os.mkdir("./doc/docbuild/html/apidoc")
# Move to lib directory (so bx package is in current directory)
os.chdir("./lib")
# Invoke epydoc
epydoc.cli.cli()
# Restore args and working directory
sys.argv = old_argv
os.chdir(old_cwd)
# Add to extra_commands
command_classes['build_apidocs'] = BuildAPIDocs
except Exception:
pass
# ---- Extension Modules ----------------------------------------------------
# # suppress C++ #warning, e.g., to silence NumPy deprecation warnings:
# from functools import partial
# _Extension = Extension
# Extension = partial(_Extension, extra_compile_args=["-Wno-cpp"])
def get_extension_modules(numpy_include=None):
extensions = []
# Bitsets
extensions.append(Extension("bx.bitset",
["lib/bx/bitset.pyx",
"src/binBits.c",
"src/kent/bits.c",
"src/kent/common.c"],
include_dirs=["src/kent", "src"]))
# Interval intersection
extensions.append(Extension("bx.intervals.intersection", ["lib/bx/intervals/intersection.pyx"]))
# Alignment object speedups
extensions.append(Extension("bx.align._core", ["lib/bx/align/_core.pyx"]))
# NIB reading speedups
extensions.append(Extension("bx.seq._nib", ["lib/bx/seq/_nib.pyx"]))
# 2bit reading speedups
extensions.append(Extension("bx.seq._twobit", ["lib/bx/seq/_twobit.pyx"]))
# Translation if character / integer strings
extensions.append(Extension("bx._seqmapping", ["lib/bx/_seqmapping.pyx"]))
# BGZF
extensions.append(Extension("bx.misc.bgzf",
["lib/bx/misc/bgzf.pyx", "src/samtools/bgzf.c"],
include_dirs=["src/samtools"],
libraries=['z']))
# The following extensions won't (currently) compile on windows
if platform.system() not in ('Microsoft', 'Windows'):
# Interval clustering
extensions.append(Extension("bx.intervals.cluster",
["lib/bx/intervals/cluster.pyx",
"src/cluster.c"],
include_dirs=["src"]))
# Position weight matrices
extensions.append(Extension("bx.pwm._position_weight_matrix",
["lib/bx/pwm/_position_weight_matrix.pyx", "src/pwm_utils.c"],
include_dirs=["src"]))
extensions.append(Extension("bx.motif._pwm", ["lib/bx/motif/_pwm.pyx"],
include_dirs=[numpy_include]))
# Sparse arrays with summaries organized as trees on disk
extensions.append(Extension("bx.arrays.array_tree", ["lib/bx/arrays/array_tree.pyx"], include_dirs=[numpy_include]))
# Reading UCSC "big binary index" files
extensions.append(Extension("bx.bbi.bpt_file", ["lib/bx/bbi/bpt_file.pyx"]))
extensions.append(Extension("bx.bbi.cirtree_file", ["lib/bx/bbi/cirtree_file.pyx"]))
extensions.append(Extension("bx.bbi.bbi_file", ["lib/bx/bbi/bbi_file.pyx"], include_dirs=[numpy_include]))
extensions.append(Extension("bx.bbi.bigwig_file", ["lib/bx/bbi/bigwig_file.pyx"], include_dirs=[numpy_include]))
extensions.append(Extension("bx.bbi.bigbed_file", ["lib/bx/bbi/bigbed_file.pyx"], include_dirs=[numpy_include]))
# EPO and Chain arithmetics and IO speedups
extensions.append(Extension("bx.align._epo", ["lib/bx/align/_epo.pyx"], include_dirs=[numpy_include]))
# Reading UCSC bed and wiggle formats
extensions.append(Extension("bx.arrays.bed", ["lib/bx/arrays/bed.pyx"]))
extensions.append(Extension("bx.arrays.wiggle", ["lib/bx/arrays/wiggle.pyx"]))
# CpG masking
extensions.append(Extension("bx.align.sitemask._cpg",
["lib/bx/align/sitemask/_cpg.pyx",
"lib/bx/align/sitemask/find_cpg.c"]))
# Counting n-grams in integer strings
extensions.append(Extension("bx.intseq.ngramcount", ["lib/bx/intseq/ngramcount.pyx"],
include_dirs=["src"]))
# Seekable access to bzip2 files
extensions.append(Extension("bx.misc._seekbzip2",
["lib/bx/misc/_seekbzip2.pyx",
"src/bunzip/micro-bunzip.c"],
include_dirs=["src/bunzip"]))
return extensions
if __name__ == "__main__":
main()