-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathsetup.py
More file actions
142 lines (120 loc) · 5.58 KB
/
Copy pathsetup.py
File metadata and controls
142 lines (120 loc) · 5.58 KB
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
import platform
import sys
from glob import glob
from setuptools import (
Extension,
setup,
)
def main():
metadata = {"scripts": glob("scripts/*.py")}
if len(sys.argv) >= 2 and (
"--help" in sys.argv[1:] or sys.argv[1] in ("--help-commands", "egg_info", "--version", "clean", "sdist")
):
# For these actions, NumPy and Cython are not required.
#
# They are required to succeed without them, for example when pip is
# used to install when NumPy is not yet present in the system.
#
# "sdist" does not need to compile anything: the .pyx/.pxd/.h sources
# in MANIFEST.in are enough to rebuild later, and skipping ext_modules
# here keeps setuptools' sdist file list from also pulling in the
# cythonized .c files as extension sources.
pass
else:
try:
import numpy
from Cython.Build import cythonize
# Suppress numpy tests
numpy.test = None
except Exception as e:
raise Exception(f"NumPy and Cython must be installed to build: {e}")
ext_modules = get_extension_modules(numpy_include=numpy.get_include())
# Force re-cythonization instead of reusing the .c files shipped in the
# sdist: those were generated with whichever NumPy/Cython versions were
# used for the bx-python release, which can be incompatible with the
# NumPy/Cython versions installed in the environment actually doing the
# build (e.g. "implicit declaration" errors for PyDataType_* functions
# when building against an older NumPy than the one used to release).
metadata["ext_modules"] = cythonize(ext_modules, force=True)
setup(**metadata)
# ---- 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()