-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathmeson.build
More file actions
78 lines (71 loc) · 2.87 KB
/
Copy pathmeson.build
File metadata and controls
78 lines (71 loc) · 2.87 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
# Copyright 2026 AI for Oncology Research Group. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
project('direct', 'cpp',
version : '2.1.1',
license : 'Apache-2.0',
meson_version : '>=1.3',
default_options : [
'warning_level=1',
'cpp_std=c++20',
'default_library=static',
# Optimized by default (mirrors the Bazel `--config=release` -O3 -DNDEBUG).
# Override on the CLI with e.g. `meson setup builddir --buildtype=debug`.
'buildtype=release',
'b_ndebug=if-release',
])
py = import('python').find_installation(pure : false)
# nanobind resolves from subprojects/nanobind.wrap (with subprojects/robin-map.wrap
# as its transitive dependency). Under --wrap-mode=forcefallback (set in
# pyproject.toml) it always builds from source, so the extensions are
# self-contained. Pinned to the same version as `nanobind_bazel` in MODULE.bazel.
nanobind_dep = dependency('nanobind')
# Repo root on the include path, matching CMake's `_direct_includes` and Bazel's
# `strip_include_prefix = "/"`, so the sources can `#include "direct/common/..."`.
inc = include_directories('.')
# Each entry: [module name, source file, package subdirectory]. Every extension
# targets the CPython 3.12 stable ABI (abi3), so a single wheel per platform
# loads on every supported interpreter.
extensions = [
['_gaussian', 'direct/common/_gaussian.cpp', 'direct/common'],
['_poisson', 'direct/common/_poisson.cpp', 'direct/common'],
['_gaussian_fill', 'direct/ssl/_gaussian_fill.cpp', 'direct/ssl'],
]
foreach ext : extensions
py.extension_module(ext[0], ext[1],
include_directories : inc,
dependencies : nanobind_dep,
limited_api : '3.12',
install : true,
subdir : ext[2])
endforeach
# Pure-Python package. The native extensions above install alongside these into
# the same site-packages `direct/` directory. The C++ sources/headers, Bazel
# build files, and bytecode caches have no place in the wheel, so drop them;
# the `.pyi` type stubs are kept.
install_subdir('direct',
install_dir : py.get_install_dir(),
exclude_files : [
'BUILD.bazel',
'common/BUILD.bazel',
'common/_gaussian.cpp',
'common/_gaussian_impl.h',
'common/_gaussian_test.cc',
'common/_poisson.cpp',
'common/_poisson_impl.h',
'common/rng.h',
'ssl/BUILD.bazel',
'ssl/_gaussian_fill.cpp',
'ssl/_gaussian_fill_impl.h',
],
exclude_directories : ['__pycache__'])