-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
65 lines (56 loc) · 1.82 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
import os
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from Cython.Build import cythonize
include_dirs = []
library_dirs = []
libraries = []
CC = os.environ.get("CC", None)
NVCPP_EXE = CC if CC is not None and CC.endswith("nvc++") else None
if NVCPP_EXE is not None:
NVCPP_HOME = os.path.dirname(os.path.dirname(NVCPP_EXE))
include_dirs += [
os.path.join(NVCPP_HOME, "include-stdpar")
]
library_dirs += [
os.path.join(NVCPP_HOME, "lib")
]
# noinspection PyPep8Naming
class custom_build_ext(build_ext):
def build_extensions(self):
if NVCPP_EXE:
# Override the compiler executables. Importantly, this
# removes the "default" compiler flags that would
# otherwise get passed on to nvc++, i.e.,
# distutils.sysconfig.get_var("CFLAGS"). nvc++
# does not support all of those "default" flags
compile_args = "-fPIC -stdpar -gpu=nordc -std=c++17"
link_args = "-shared -stdpar"
self.compiler.set_executable(
"compiler_so",
NVCPP_EXE + " " + compile_args
)
self.compiler.set_executable("compiler_cxx", NVCPP_EXE)
self.compiler.set_executable(
"linker_so",
NVCPP_EXE + " " + link_args
)
build_ext.build_extensions(self)
ext = cythonize([
Extension(
'*',
sources=['*.pyx'],
libraries=libraries,
include_dirs=include_dirs,
library_dirs=library_dirs,
runtime_library_dirs=library_dirs,
extra_compile_args=["-std=c++17"]
)])
setup(
name='cppsort',
author='Ashwin Srinath',
version='0.1',
ext_modules=ext,
zip_safe=False,
cmdclass={'build_ext': custom_build_ext}
)