6 from setuptools
import setup
7 from setuptools
import Extension
9 from distutils.core
import setup
10 from distutils.extension
import Extension
12 from Cython.Build
import cythonize
19 from numpy
import get_include
as numpy_get_include
21 def numpy_get_include():
24 win32_build = os.name ==
'nt'
26 sha512 = hashlib.sha512()
27 src_files = filter(len,
'@CYTHON_BINDINGS_SOURCES@;@CYTHON_BINDINGS_GENERATE_SOURCES@'.split(
';'))
29 if os.path.isabs(src):
32 return '{}/{}'.format(
'@CMAKE_CURRENT_SOURCE_DIR@', src)
33 src_files = map(absolute, src_files)
36 with open(f,
'r')
as fd:
40 sha512.update(data.encode(
'ascii'))
43 version_hash = sha512.hexdigest()[:7]
47 compile_args =
"@CYTHON_BINDINGS_COMPILE_DEFINITIONS@"
48 self.compile_args = [
"-D" + x
for x
in compile_args.split(
';')
if len(x) ]
49 self.compile_args = list(
set(self.compile_args))
50 include_dirs =
"@CYTHON_BINDINGS_INCLUDE_DIRECTORIES@"
52 self.include_dirs = [ x
for x
in include_dirs.split(
';')
if len(x) ]
53 self.include_dirs.append(
'@CMAKE_CURRENT_SOURCE_DIR@/include')
54 self.include_dirs = list(
set(self.include_dirs))
55 library_dirs =
"@CYTHON_BINDINGS_LINK_FLAGS@"
56 self.library_dirs = [ x
for x
in library_dirs.split(
';')
if len(x) ]
57 self.libraries = [ re.sub(
"^lib",
"", os.path.splitext(os.path.basename(l))[0])
for l
in "@CYTHON_BINDINGS_LIBRARIES@".split(
";")
if len(l) ]
58 self.libraries = list(
set(self.libraries))
59 self.library_dirs += [os.path.dirname(l)
for l
in "@CYTHON_BINDINGS_TARGET_FILES@".split(
';')
if len(l) ]
60 self.library_dirs = list(
set(self.library_dirs))
74 cxx_standard = max(map(cxx_standard,
"0;@CYTHON_BINDINGS_CXX_STANDARD@".split(
';')), key = cxx_standard_cmp)
77 config.compile_args.append(
'-std=c++{}'.format(cxx_standard))
80 if cxx_standard >= 17:
81 config.compile_args.append(
'-Wno-register')
84 config.compile_args.append(
'/std:c++latest')
85 elif cxx_standard == 17:
86 config.compile_args.append(
'/std:c++17')
89 config.compile_args.append(
"-DWIN32")
90 if "$<CONFIGURATION>".lower() ==
"debug":
91 config.compile_args += [
"-Zi",
"/Od"]
92 config.link_args += [
"-debug"]
95 pyx_src = name.replace(
'.',
'/')
96 pyx_src = pyx_src +
'.pyx'
98 return Extension(name, [ext_src], extra_compile_args = config.compile_args, include_dirs = config.include_dirs, library_dirs = config.library_dirs, libraries = config.libraries, extra_link_args = config.link_args)
100 extensions = [
GenExtension(x)
for x
in '@CYTHON_BINDINGS_MODULES@'.split(
';') ]
102 extensions = cythonize(extensions)
104 packages = [ p.split(
'.')[0]
for p
in '@CYTHON_BINDINGS_MODULES@'.split(
';') ]
105 package_data = { p : list(map(
lambda x: x.replace(p +
'/',
''), filter(
lambda x: x.startswith(p +
'/'),
'@CYTHON_BINDINGS_EXPORT_SOURCES@'.split(
';'))))
for p
in packages }
108 name =
'@CYTHON_BINDINGS_PACKAGE_NAME@',
109 version=
'@CYTHON_BINDINGS_VERSION@-{}'.format(version_hash),
110 ext_modules = extensions,
112 package_data = package_data