-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
46 lines (39 loc) · 1.65 KB
/
setup.py
File metadata and controls
46 lines (39 loc) · 1.65 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
# Available at setup time due to pyproject.toml
from pybind11.setup_helpers import Pybind11Extension
from setuptools import setup
from glob import glob
import sys
# __version__ = "0.0.1"
exclude_files_from_build = [
"src/bufr_tools/bufresohmsgfrenc.cpp",
"src/bufr_tools/covjson2bufr_main.cpp",
"src/bufr_tools/bufresohmsg.cpp",
"src/bufr_tools/bufrenc.cpp",
]
common_extra_compile_args = []
linux_extra_compile_args = ["--std=c++17"]
windows_extra_compile_args = ["-IC:\\temp\\rapidjson\\rapidjson-1.1.0\\include", "/std:c++17"]
macos_extra_compile_args = ["-I/tmp/rapidjson-1.1.0/include", "--std=c++17"]
if sys.platform == "win32":
extra_compile_args_for_extension = common_extra_compile_args + windows_extra_compile_args
elif sys.platform == "darwin":
extra_compile_args_for_extension = common_extra_compile_args + macos_extra_compile_args
else:
extra_compile_args_for_extension = common_extra_compile_args + linux_extra_compile_args
# The main interface is through Pybind11Extension.
# * You can add cxx_std=11/14/17, and then build_ext can be removed.
# * You can set include_pybind11=false to add the include directory yourself,
# say from a submodule.
#
# Note:
# Sort input source files if you glob sources to ensure bit-for-bit
# reproducible builds (https://github.com/pybind/python_example/pull/53)
ext_modules = [
Pybind11Extension(
"bufr_tools.bufresohmsg_py",
sorted([i for i in glob("src/bufr_tools/*.cpp") if i not in exclude_files_from_build]),
# Example: passing in the version to the compiled code
extra_compile_args=extra_compile_args_for_extension,
),
]
setup(ext_modules=ext_modules)