-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup.py
130 lines (110 loc) · 3.98 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
import os
import sys
from pathlib import Path
from farm_ng.package.commands import (
BuildProtosDevelop,
BuildProtosEggInfo,
BuildProtosInstall,
CleanFilesCommand,
)
from pybind11.setup_helpers import ParallelCompile, Pybind11Extension, build_ext
from setuptools import setup
# This must match the version in setup.cfg.
__version__ = "2.3.2"
platform_cxx_flags = []
if sys.platform.startswith("darwin"):
print("Running on macOS")
platform_cxx_flags = [
"-std=c++20",
"-mmacosx-version-min=11.0",
"-D_LIBCPP_DISABLE_DEPRECATION_WARNINGS=1",
# GCC and Clang may support slightly different sets of warning options.
# GCC will tolerate unknown ones by default, but Clang needs this.
"-Wno-unknown-warning-option",
]
os.environ["MACOSX_DEPLOYMENT_TARGET"] = "11.0"
elif sys.platform.startswith("linux"):
print("Running on Linux")
platform_cxx_flags = [
"-std=gnu++17",
"-fconcepts",
]
else:
print("Running on another operating system")
PROTO_ROOT: str = "protos"
PACKAGE_ROOT: str = "py"
BuildProtosDevelop.user_options.append(("proto-root=", None, PROTO_ROOT))
BuildProtosDevelop.user_options.append(("package-root=", None, PACKAGE_ROOT))
BuildProtosInstall.user_options.append(("proto-root=", None, PROTO_ROOT))
BuildProtosInstall.user_options.append(("package-root=", None, PACKAGE_ROOT))
BuildProtosEggInfo.user_options.append(("proto-root=", None, PROTO_ROOT))
BuildProtosEggInfo.user_options.append(("package-root=", None, PACKAGE_ROOT))
CleanFilesCommand.user_options.append(("package-root=", None, PACKAGE_ROOT))
# Optional multithreaded build
ParallelCompile("CMAKE_BUILD_PARALLEL_LEVEL", default=4).install()
source_path = Path(__file__).resolve()
source_dir = source_path.parent
# 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(
"farm_ng_core_pybind",
[
# farm-ng-control
"py/pybind/farm_ng_core_pybind.cpp",
"py/pybind/linalg_pybind.cpp",
"py/pybind/lie_pybind.cpp",
# fmt
"cpp/thirdparty/fmt/src/format.cc",
"cpp/thirdparty/fmt/src/os.cc",
# farm-ng-core
"cpp/farm_ng/core/logging/backtrace.cpp",
"cpp/farm_ng/core/logging/expected.cpp",
"cpp/farm_ng/core/logging/format.cpp",
"cpp/farm_ng/core/logging/logger.cpp",
],
define_macros=[("VERSION_INFO", __version__)],
extra_compile_args=[
*platform_cxx_flags,
"-Wall",
"-Wextra",
"-Werror",
"-Wno-unused-parameter",
"-Wno-missing-field-initializers",
"-Wno-unused-but-set-variable",
"-Wno-unused-variable",
"-Wno-unused-function",
"-Wno-maybe-uninitialized",
# Treat thirdparty libraries as system header directories to
# suppress warnings from them.
# This might allow removing some of the -Wno-* flags above.
"-isystem",
str(source_dir / "cpp/thirdparty/expected/include"),
"-isystem",
str(source_dir / "cpp/thirdparty/farm_pp/include"),
"-isystem",
str(source_dir / "cpp/thirdparty/fmt/include"),
"-isystem",
str(source_dir / "cpp/thirdparty/eigen"),
],
include_dirs=[
source_dir / "cpp",
],
),
]
setup(
ext_modules=ext_modules,
cmdclass={
"install": BuildProtosInstall,
"develop": BuildProtosDevelop,
"egg_info": BuildProtosEggInfo,
"clean": CleanFilesCommand,
"build_ext": build_ext,
},
)