Spaces:
Running
on
Zero
Running
on
Zero
File size: 1,834 Bytes
4893ce0 |
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 |
import os
from sys import argv
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
from distutils.sysconfig import get_config_vars
(opt,) = get_config_vars("OPT")
os.environ["OPT"] = " ".join(
flag for flag in opt.split() if flag != "-Wstrict-prototypes"
)
def _argparse(pattern, argv, is_flag=True, is_list=False):
if is_flag:
found = pattern in argv
if found:
argv.remove(pattern)
return found, argv
else:
arr = [arg for arg in argv if pattern == arg.split("=")[0]]
if is_list:
if len(arr) == 0: # not found
return False, argv
else:
assert "=" in arr[0], f"{arr[0]} requires a value."
argv.remove(arr[0])
val = arr[0].split("=")[1]
if "," in val:
return val.split(","), argv
else:
return [val], argv
else:
if len(arr) == 0: # not found
return False, argv
else:
assert "=" in arr[0], f"{arr[0]} requires a value."
argv.remove(arr[0])
return arr[0].split("=")[1], argv
INCLUDE_DIRS, argv = _argparse("--include_dirs", argv, False, is_list=True)
include_dirs = []
if not (INCLUDE_DIRS is False):
include_dirs += INCLUDE_DIRS
setup(
name="pointgroup_ops",
packages=["pointgroup_ops"],
package_dir={"pointgroup_ops": "functions"},
ext_modules=[
CUDAExtension(
name="pointgroup_ops_cuda",
sources=["src/bfs_cluster.cpp", "src/bfs_cluster_kernel.cu"],
extra_compile_args={"cxx": ["-g"], "nvcc": ["-O2"]},
)
],
include_dirs=[*include_dirs],
cmdclass={"build_ext": BuildExtension},
)
|