-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathmeson.build
More file actions
239 lines (208 loc) · 7.33 KB
/
meson.build
File metadata and controls
239 lines (208 loc) · 7.33 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
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
project(
'dysgu', ['c', 'cpp'],
meson_version : '>=0.64',
default_options: [
'warning_level=1',
'cpp_std=c++17',
'c_std=c99'
]
)
# ---------------------------------------------------------------------------
# Imports
# ---------------------------------------------------------------------------
py_mod = import('python')
cython = find_program('cython')
if run_command(cython, '--version',
check: true
).stdout().strip().split()[-1].version_compare('<3.0.0')
error('Cython ≥3.0.0 is required (needed for NumPy2 support)')
endif
# ---------------------------------------------------------------------------
# Python interpreter and numpy / pysam discovery
# ---------------------------------------------------------------------------
py3 = py_mod.find_installation(pure : false) # ← the interpreter that is running Meson
py3_dep = py3.dependency()
python_info = run_command(
py3,
['-c', 'import sys; print(f"Using Python {sys.version} at {sys.executable}")'],
check : true
).stdout().strip()
message(python_info)
numpy_include = run_command(py3,
['-c', 'import numpy, sys; print(numpy.get_include())'],
check : true).stdout().strip()
pysam_includes = run_command(py3,
['-c', 'import pysam, sys; print(":".join(pysam.get_include()))'],
check : true).stdout().strip().split(':')
# ---------------------------------------------------------------------------
# Compiler flags
# ---------------------------------------------------------------------------
extra_args = [
'-Wno-sign-compare', '-Wno-unused-function',
'-Wno-unused-result', '-Wno-ignored-qualifiers',
'-Wno-deprecated-declarations'
]
cpp_defines = ['-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION']
# ---------------------------------------------------------------------------
# htslib
# ---------------------------------------------------------------------------
htslib_prefix = get_option('htslib_prefix')
if htslib_prefix != ''
# Use the system-provided htslib
hts_lib = declare_dependency(
include_directories : include_directories(
join_paths(htslib_prefix, 'include'),
join_paths(htslib_prefix, 'include/htslib')),
link_args : ['-L' + join_paths(htslib_prefix, 'lib'), '-lhts'])
else
# Try to get libdeflate, but make it optional
libdeflate_dep = dependency('libdeflate', required: false)
# Set htslib options based on whether libdeflate was found
htslib_options = []
if libdeflate_dep.found()
message('libdeflate found, enabling it for htslib')
htslib_options += 'libdeflate=true'
else
message('libdeflate not found, building htslib without it')
htslib_options += 'libdeflate=false'
endif
# Build htslib as a dependency
hts_lib = dependency('htslib',
fallback : ['htslib', 'htslib_dep'],
required : true,
default_options: htslib_options)
endif
# ---------------------------------------------------------------------------
# Common include directories
# ---------------------------------------------------------------------------
includes = [
include_directories('.'),
include_directories(numpy_include),
include_directories('dysgu/include')
]
foreach inc : pysam_includes
includes += include_directories(inc)
endforeach
includes += include_directories('dysgu')
# ---------------------------------------------------------------------------
# Cython handling and module definitions
# ---------------------------------------------------------------------------
# Define the main Cython modules (those in the main dysgu directory)
main_modules = [
'sv2bam', 'io_funcs', 'graph', 'coverage', 'consensus',
'call_component', 'map_set_utils', 'cluster',
'sv_category', 'extra_metrics', 'merge_svs'
]
# Generate Cython targets for all modules
cython_targets = {}
# Special modules first
# edlib module
cython_targets += {
'edlib' : custom_target(
'cythonize_edlib',
input : join_paths('dysgu', 'edlib', 'edlib.pyx'),
output : 'edlib.cpp',
command : [
cython,
'--cplus',
'-3',
'-I', meson.current_source_dir(),
'@INPUT@',
'-o', '@OUTPUT@'
],
)
}
# ssw_wrapper module
cython_targets += {
'_ssw_wrapper' : custom_target(
'cythonize_ssw_wrapper',
input : join_paths('dysgu', 'scikitbio', '_ssw_wrapper.pyx'),
output : '_ssw_wrapper.c',
command : [
cython,
'-3',
'-I', meson.current_source_dir(),
'@INPUT@',
'-o', '@OUTPUT@'
],
)
}
# Main modules
foreach module : main_modules
cython_targets += {
module : custom_target(
'cythonize_' + module,
input : join_paths('dysgu', module + '.pyx'),
output : module + '.cpp',
command : [
cython,
'--cplus',
'-3',
'-I', meson.current_source_dir(),
'-I', join_paths(meson.current_source_dir(), 'dysgu'),
'@INPUT@',
'-o', '@OUTPUT@'
],
)
}
endforeach
# ---------------------------------------------------------------------------
# Extension modules
# ---------------------------------------------------------------------------
# Special case modules
py3.extension_module(
'edlib',
[cython_targets['edlib'], join_paths('dysgu', 'edlib', 'src', 'edlib.cpp')],
include_directories : [includes, include_directories('dysgu/edlib')],
cpp_args : ['-O3', '-std=c++17'] + cpp_defines,
install : true,
install_dir : py3.get_install_dir() / 'dysgu/edlib'
)
py3.extension_module(
'_ssw_wrapper',
[cython_targets['_ssw_wrapper'], join_paths('dysgu', 'scikitbio', 'ssw.c')],
include_directories : [includes, include_directories('dysgu/scikitbio')],
c_args : ['-Wno-deprecated-declarations'] + cpp_defines,
install : true,
install_dir : py3.get_install_dir() / 'dysgu/scikitbio'
)
# Main modules
foreach module : main_modules
py3.extension_module(
module,
[cython_targets[module]],
include_directories : includes,
dependencies : [py3_dep, hts_lib],
cpp_args : extra_args + cpp_defines,
install : true,
install_dir : py3.get_install_dir() / 'dysgu'
)
endforeach
# ---------------------------------------------------------------------------
# Install Python source files
# ---------------------------------------------------------------------------
# Absolute path where Python packages go (e.g. site‑packages)
py_pkg_root = py3.get_install_dir() / 'dysgu'
python_sources = [
'__init__.py', 'main.py', 'python_api.py',
'sites_utils.py', 'filter_normals.py', 'post_call.py',
're_map.py', 'view.py'
]
# Install Python sources
foreach source : python_sources
py3.install_sources(join_paths('dysgu', source), subdir : 'dysgu')
endforeach
# Install data files
install_data(
join_paths('dysgu', 'dysgu_model.1.pkl.gz'),
install_dir : py_pkg_root
)
# Install sub‑packages
foreach pkg : ['tests', 'scikitbio', 'edlib']
# copies dysgu/<pkg>/… into <site‑packages>/dysgu/<pkg>/…
install_subdir(
join_paths('dysgu', pkg),
install_dir : py_pkg_root,
exclude_files : ['*.pyx', '*.c', '*.cpp', '*.h', '*.hpp']
)
endforeach