setup.in.py
Go to the documentation of this file.
1 #
2 # This file was generated by jrl-cmakemodules, do not modify
3 #
4 
5 try:
6  from setuptools import setup
7  from setuptools import Extension
8 except ImportError:
9  from distutils.core import setup
10  from distutils.extension import Extension
11 
12 from Cython.Build import cythonize
13 
14 import hashlib
15 import os
16 import re
17 
18 try:
19  from numpy import get_include as numpy_get_include
20 except ImportError:
21  def numpy_get_include():
22  return ""
23 
24 win32_build = os.name == 'nt'
25 
26 sha512 = hashlib.sha512()
27 src_files = filter(len, '@CYTHON_BINDINGS_SOURCES@;@CYTHON_BINDINGS_GENERATE_SOURCES@'.split(';'))
28 def absolute(src):
29  if os.path.isabs(src):
30  return src
31  else:
32  return '{}/{}'.format('@CMAKE_CURRENT_SOURCE_DIR@', src)
33 src_files = map(absolute, src_files)
34 for f in src_files:
35  chunk = 2**12
36  with open(f, 'r') as fd:
37  while True:
38  data = fd.read(chunk)
39  if data:
40  sha512.update(data.encode('ascii'))
41  else:
42  break
43 version_hash = sha512.hexdigest()[:7]
44 
45 class pkg_config(object):
46  def __init__(self):
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@"
51  include_dirs += ';{}'.format(numpy_get_include())
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))
61  self.link_args = []
62 
63 config = pkg_config()
64 
65 def cxx_standard(value):
66  try:
67  return int(value)
68  except:
69  return 0
71  if lhs == 98:
72  return 1
73  return lhs
74 cxx_standard = max(map(cxx_standard, "0;@CYTHON_BINDINGS_CXX_STANDARD@".split(';')), key = cxx_standard_cmp)
75 if cxx_standard != 0:
76  if not win32_build:
77  config.compile_args.append('-std=c++{}'.format(cxx_standard))
78  # In C++17 the register keyword is unused and reserved, GCC still accepts it with a warning but clang errors by default
79  # It is used in Python 2.7 header file and so we need this flag
80  if cxx_standard >= 17:
81  config.compile_args.append('-Wno-register')
82  else:
83  if cxx_standard > 17:
84  config.compile_args.append('/std:c++latest')
85  elif cxx_standard == 17:
86  config.compile_args.append('/std:c++17')
87 
88 if win32_build:
89  config.compile_args.append("-DWIN32")
90  if "$<CONFIGURATION>".lower() == "debug":
91  config.compile_args += ["-Zi", "/Od"]
92  config.link_args += ["-debug"]
93 
94 def GenExtension(name):
95  pyx_src = name.replace('.', '/')
96  pyx_src = pyx_src + '.pyx'
97  ext_src = pyx_src
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)
99 
100 extensions = [ GenExtension(x) for x in '@CYTHON_BINDINGS_MODULES@'.split(';') ]
101 
102 extensions = cythonize(extensions)
103 
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 }
106 
107 setup(
108  name = '@CYTHON_BINDINGS_PACKAGE_NAME@',
109  version='@CYTHON_BINDINGS_VERSION@-{}'.format(version_hash),
110  ext_modules = extensions,
111  packages = packages,
112  package_data = package_data
113 )
setup
setup::GenExtension
def GenExtension(name)
setup::absolute
def absolute(src)
set
void set(bool ownStorage, Vec3f *points_, unsigned int num_points_)
setup::cxx_standard_cmp
def cxx_standard_cmp(lhs)
setup::cxx_standard
cxx_standard
setup::numpy_get_include
def numpy_get_include()
Definition: setup.in.py:21
setup::pkg_config
Definition: setup.in.py:45


sot-dynamic-pinocchio
Author(s): Olivier Stasse
autogenerated on Fri Jul 28 2023 02:10:01