-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsetup.py
More file actions
47 lines (42 loc) · 1.46 KB
/
setup.py
File metadata and controls
47 lines (42 loc) · 1.46 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
import subprocess
from pathlib import Path
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
PACKAGE_NAME = "fastmap"
THIS_DIR = Path(__file__).parent
SOURCE_DIR = THIS_DIR / "cuda"
class BuildExtWithCompDb(BuildExtension):
def run(self):
super().run() # regular build
build_dir = Path(self.build_temp) # e.g. build/temp.linux‑…
ninja_file = build_dir / "build.ninja"
if ninja_file.exists():
compdb = subprocess.check_output(
["ninja", "-C", str(build_dir), "-t", "compdb"]
)
(Path.cwd() / "compile_commands.json").write_bytes(compdb)
setup(
name=PACKAGE_NAME,
version="0.1",
ext_modules=[
CUDAExtension(
name=f"{PACKAGE_NAME}.cuda",
sources=[
str(SOURCE_DIR / "rotation.cu"),
str(SOURCE_DIR / "translation.cu"),
str(SOURCE_DIR / "epipolar.cu"),
str(SOURCE_DIR / "interface.cc"),
],
extra_compile_args={
"cxx": ["-O3"],
"nvcc": [
"-O3",
# Uncomment & tweak for specific GPU arch if desired:
# "-gencode=arch=compute_80,code=sm_80",
],
# "nvcc": ["-O0", "-g", "-lineinfo"],
},
)
],
cmdclass={"build_ext": BuildExtWithCompDb.with_options(no_python_abi_suffix=True)},
)