-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathsetup.py
154 lines (123 loc) · 3.72 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
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext
import os
import subprocess
import sys
__version__ = "2.3.0"
ROOT_DIR = os.getcwd()
SUBMOD_DIR = os.path.join(ROOT_DIR, "submods")
SUBMODS = [
"bwa",
"fast5",
"hdf5",
"pdqsort",
"toml11"
]
class get_pybind_include(object):
"""Helper class to determine the pybind11 include path
The purpose of this class is to postpone importing pybind11
until it is actually installed, so that the ``get_include()``
method can be invoked. """
def __str__(self):
import pybind11
return pybind11.get_include()
class pre_build(build_ext):
def run(self):
submods_loaded = True
for submod in SUBMODS:
if not os.path.exists(os.path.join(SUBMOD_DIR, submod)):
submods_loaded = False
break
if not submods_loaded:
sys.stderr.write("Downloading submodules\n")
subprocess.check_call([
"git", "submodule", "update", "--init"
])
else:
sys.stderr.write("All submodules present\n")
if os.path.exists("./submods/bwa/libbwa.a"):
sys.stderr.write("Found libbwa.a\n")
else:
sys.stderr.write("building libbwa\n")
subprocess.check_call([
"make",
"-C", "./submods/bwa",
"-f", "../../src/Makefile_bwa"
])
if os.path.exists("./submods/hdf5/lib/libhdf5.a"):
sys.stderr.write("Found libhdf5.a\n")
else:
hdf5_dir = os.path.join(ROOT_DIR, "submods/hdf5")
os.chdir(hdf5_dir)
subprocess.check_call([
"./configure",
"--enable-threadsafe",
"--disable-hl",
"--prefix", hdf5_dir,
"--enable-shared=no",
"--with-pic=yes"
])
subprocess.check_call(["make"])
subprocess.check_call(["make", "install"])
os.chdir(ROOT_DIR)
build_ext.run(self)
uncalled = Extension(
"_uncalled",
sources = [
"src/pybinder.cpp",
"src/event_profiler.cpp",
"src/client_sim.cpp",
"src/fast5_reader.cpp",
"src/mapper.cpp",
"src/self_align_ref.cpp",
"src/map_pool.cpp",
"src/event_detector.cpp",
"src/read_buffer.cpp",
"src/chunk.cpp",
"src/realtime_pool.cpp",
"src/seed_tracker.cpp",
"src/normalizer.cpp",
"src/range.cpp"
],
include_dirs = [
"./submods",
"./submods/hdf5/include",
"./submods/fast5/include",
"./submods/pdqsort",
"./submods/toml11",
get_pybind_include()
],
library_dirs = [
"./submods/bwa"
],
extra_objects = [
"./submods/hdf5/lib/libhdf5.a"
],
libraries = ["bwa", "z", "dl", "m"],
extra_compile_args = ["-std=c++11", "-O3"],
define_macros = [("PYBIND", None)]
)
setup(
name = "uncalled",
version = __version__,
description = "Rapidly maps raw nanopore signal to DNA references",
author = "Sam Kovaka",
author_email = "[email protected]",
url = "https://github.com/skovaka/UNCALLED",
classifiers=[
"Programming Language :: Python :: 3"
],
python_requires=">=3.6",
setup_requires=[
'pybind11>=2.5.0'
],
install_requires=[
'read-until==3.0.0',
'minknow-api>=5.0'
],
packages=find_packages(),
include_package_data=True,
scripts = ['scripts/uncalled'],
ext_modules = [uncalled],
cmdclass={'build_ext': pre_build},
)