-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
67 lines (60 loc) · 1.86 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
from setuptools import setup, Command
from torch.utils import cpp_extension
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
import versioneer
import os
if hasattr(cpp_extension, "get_compiler_abi_compatibility_and_version"):
# - New function since torch 1.12
if cpp_extension.get_compiler_abi_compatibility_and_version("g++")[0]:
os.environ["CC"] = "g++"
os.environ["CXX"] = "g++"
else:
os.environ["CC"] = "c++"
os.environ["CXX"] = "c++"
else:
# - This works up to torch 1.11
if cpp_extension.check_compiler_abi_compatibility("g++"):
os.environ["CC"] = "g++"
os.environ["CXX"] = "g++"
else:
os.environ["CC"] = "c++"
os.environ["CXX"] = "c++"
# Class for clean command
class Cleaner(Command):
"""Clean command to tidy up after building"""
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system("rm -vrf ./build ./dist ./*pyc ./*egg-info")
# Update cmdclass
cmdclass = versioneer.get_cmdclass()
cmdclass.update({"build_ext": BuildExtension.with_options(no_python_abi_suffix=True)})
cmdclass.update({"clean": Cleaner})
# Handle versions
version = versioneer.get_version()
# Install
setup(
name='sinabs-exodus',
version=version,
packages=['sinabs.exodus', 'sinabs.exodus.layers'],
ext_modules=[
CUDAExtension(
name='exodus_cuda',
sources=[
'cuda/bindings.cu',
# 'cuda/leaky_bindings.cu',
# 'cuda/experimental_bindings.cu',
],
depends=[
'cuda/lif_kernels.h'
'cuda/leaky_kernels.h'
# 'cuda/experimental_kernels.h'
],
)
],
cmdclass=cmdclass,
install_requires=["torch", f"sinabs >= 1.2.9"],
)