-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.py
More file actions
51 lines (43 loc) · 1.19 KB
/
setup.py
File metadata and controls
51 lines (43 loc) · 1.19 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
from skbuild import setup
import os
import sys
import subprocess
def get_nanobind_dir():
"""Try to get nanobind directory from Python package."""
try:
import nanobind
return os.path.dirname(nanobind.__file__)
except ImportError:
pass
# Try using python -m nanobind --cmake_dir
try:
result = subprocess.run(
[sys.executable, "-m", "nanobind", "--cmake_dir"],
capture_output=True,
text=True,
check=False
)
if result.returncode == 0:
return result.stdout.strip()
except Exception:
pass
return None
# Set NANOBIND_DIR environment variable if found
nanobind_dir = get_nanobind_dir()
if nanobind_dir:
os.environ["NANOBIND_DIR"] = nanobind_dir
print(f"Setting NANOBIND_DIR to: {nanobind_dir}")
setup(
packages=["sdu_controllers"],
package_dir={"": "python"},
zip_safe=False,
cmake_args=[
"-DBUILD_TESTING=OFF",
"-DBUILD_PYTHON=ON",
"-DBUILD_PYTHON_STUBS=ON",
"-DBUILD_FOR_PIP_INSTALL=ON",
"-DBUILD_DOCS=OFF",
"-DCMAKE_BUILD_TYPE=Release",
],
cmake_install_dir="python/sdu_controllers",
)