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
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) ]
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')
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) ]
59 self.
library_dirs += [os.path.dirname(l)
for l
in "@CYTHON_BINDINGS_TARGET_FILES@".split(
';')
if len(l) ]
74 cxx_standard = max(map(cxx_standard,
"0;@CYTHON_BINDINGS_CXX_STANDARD@".split(
';')), key = cxx_standard_cmp)
76 config.compile_args.append(
'-std=c++{}'.format(cxx_standard))
79 config.compile_args.append(
"-DWIN32")
80 if "$<CONFIGURATION>".lower() ==
"debug":
81 config.compile_args += [
"-Zi",
"/Od"]
82 config.link_args += [
"-debug"]
85 pyx_src = name.replace(
'.',
'/')
86 pyx_src = pyx_src +
'.pyx' 88 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)
90 extensions = [
GenExtension(x)
for x
in '@CYTHON_BINDINGS_MODULES@'.split(
';') ]
92 extensions = cythonize(extensions)
94 packages = [ p.split(
'.')[0]
for p
in '@CYTHON_BINDINGS_MODULES@'.split(
';') ]
95 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 }
98 name =
'@CYTHON_BINDINGS_PACKAGE_NAME@',
99 version=
'@CYTHON_BINDINGS_VERSION@-{}'.format(version_hash),
100 ext_modules = extensions,
102 package_data = package_data
def cxx_standard_cmp(lhs)