-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
72 lines (55 loc) · 1.68 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
from Cython.Build import cythonize
from setuptools import setup, find_packages
from setuptools.extension import Extension
import os
cuda_flag = os.getenv("ENABLE_CUDA", None)
nvtx_include = os.getenv("NVTX_INCLUDE", None)
nvtx_flag = False
if nvtx_include is not None:
nvtx_flag = True
os.environ["CC"] = 'nvcc_wrapper'
os.environ["CXX"] = 'nvcc_wrapper'
if cuda_flag is not None:
cuda_flag = True
else:
cuda_flag = False
def scandir(dir, files=[]):
for file in os.listdir(dir):
path = os.path.join(dir, file)
if os.path.isfile(path) and path.endswith(".pyx"):
files.append(path.replace(os.path.sep, ".")[:-4])
elif os.path.isdir(path):
scandir(path, files)
return files
compile_args =["-std=c++11","-ldl", "-fno-stack-protector"]
if nvtx_flag:
include_dirs = [nvtx_include]
compile_args += ["-DNVTX_ENABLE"]
print("BUILDING WITH NVTX SUPPORT")
else:
include_dirs = []
if cuda_flag:
compile_args += ["-DCUDA_ENABLE"]
compile_args += ["--expt-extended-lambda", "-Xcudafe","--diag_suppress=esa_on_defaulted_function_ignored"]
def makeExtension(extName):
extPath = extName.replace(".", os.path.sep)+".pyx"
return Extension(
extName,
[extPath],
language='c++',
include_dirs=include_dirs,
extra_compile_args=compile_args
)
extNames = scandir("sleep")
extensions = [makeExtension(name) for name in extNames]
setup(
setup_requires=['setuptools>=18.0', 'wheel', 'Cython'],
name="sleep",
packages=["sleep"],
ext_modules=cythonize(extensions),
package_data={
'':['*.pxd']
},
zip_safe=False,
include_package_data=True,
)