models/example-robot-data/cmake/cython/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 import sys
18 
19 try:
20  from numpy import get_include as numpy_get_include
21 except ImportError:
22  def numpy_get_include():
23  return ""
24 
25 win32_build = os.name == 'nt'
26 linux_build = sys.platform.startswith('linux')
27 
28 sha512 = hashlib.sha512()
29 src_files = filter(len, '@CYTHON_BINDINGS_SOURCES@;@CYTHON_BINDINGS_GENERATE_SOURCES@'.split(';'))
30 def absolute(src):
31  if os.path.isabs(src):
32  return src
33  else:
34  return '{}/{}'.format('@CMAKE_CURRENT_SOURCE_DIR@', src)
35 src_files = map(absolute, src_files)
36 for f in src_files:
37  chunk = 2**12
38  with open(f, 'r') as fd:
39  while True:
40  data = fd.read(chunk)
41  if data:
42  sha512.update(data.encode('ascii'))
43  else:
44  break
45 version_hash = sha512.hexdigest()[:7]
46 
47 def get_lib_name(path):
48  ret = os.path.basename(path)
49  dot_idx = ret.find('.')
50  if dot_idx == -1:
51  return ret
52  return ret[0:dot_idx]
53 
54 class pkg_config(object):
55  def __init__(self):
56  compile_args = "@CYTHON_BINDINGS_COMPILE_DEFINITIONS@"
57  self.compile_args = [ "-D" + x for x in compile_args.split(';') if len(x) ]
58  self.compile_args = list(set(self.compile_args))
59  include_dirs = "@CYTHON_BINDINGS_INCLUDE_DIRECTORIES@"
60  include_dirs += ';{}'.format(numpy_get_include())
61  self.include_dirs = [ x for x in include_dirs.split(';') if len(x) ]
62  self.include_dirs.append('@CMAKE_CURRENT_SOURCE_DIR@/include')
63  self.include_dirs = list(set(self.include_dirs))
64  library_dirs = "@CYTHON_BINDINGS_LINK_FLAGS@"
65  self.library_dirs = [ x for x in library_dirs.split(';') if len(x) ]
66  self.libraries = [ re.sub("^lib", "", get_lib_name(l)) for l in "@CYTHON_BINDINGS_LIBRARIES@".split(";") if len(l) ]
67  self.libraries = list(set(self.libraries))
68  self.library_dirs += [os.path.dirname(l) for l in "@CYTHON_BINDINGS_TARGET_FILES@".split(';') if len(l) ]
69  self.library_dirs = list(set(self.library_dirs))
70  self.link_args = []
71  if linux_build:
72  for l in self.libraries:
73  self.link_args += ['-Wl,--no-as-needed', '-l{}'.format(l)]
74  self.libraries = []
75  if not win32_build:
76  self.extra_objects = [l for l in '@CYTHON_BINDINGS_STATIC_LIBRARIES@'.split(';') if len(l)]
77  else:
78  self.extra_objects = []
79 
80 config = pkg_config()
81 
82 def cxx_standard(value):
83  try:
84  return int(value)
85  except:
86  return 0
87 def cxx_standard_cmp(lhs):
88  if lhs == 98:
89  return 1
90  return lhs
91 cxx_standard = max(map(cxx_standard, "0;@CYTHON_BINDINGS_CXX_STANDARD@".split(';')), key = cxx_standard_cmp)
92 if cxx_standard != 0:
93  if not win32_build:
94  config.compile_args.append('-std=c++{}'.format(cxx_standard))
95  # In C++17 the register keyword is unused and reserved, GCC still accepts it with a warning but clang errors by default
96  # It is used in Python 2.7 header file and so we need this flag
97  if cxx_standard >= 17:
98  config.compile_args.append('-Wno-register')
99  else:
100  if cxx_standard > 17:
101  config.compile_args.append('/std:c++latest')
102  elif cxx_standard == 17:
103  config.compile_args.append('/std:c++17')
104 
105 if win32_build:
106  config.compile_args.append("-DWIN32")
107  if "$<CONFIGURATION>".lower() == "debug":
108  config.compile_args += ["-Zi", "/Od"]
109  config.link_args += ["-debug"]
110 
111 def GenExtension(name):
112  pyx_src = name.replace('.', '/')
113  pyx_src = pyx_src + '.pyx'
114  ext_src = pyx_src
115  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, extra_objects = config.extra_objects)
116 
117 extensions = [ GenExtension(x) for x in '@CYTHON_BINDINGS_MODULES@'.split(';') ]
118 
119 extensions = cythonize(extensions)
120 
121 packages = [ p.split('.')[0] for p in '@CYTHON_BINDINGS_MODULES@'.split(';') ]
122 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 }
123 
124 setup(
125  name = '@CYTHON_BINDINGS_PACKAGE_NAME@',
126  version='@CYTHON_BINDINGS_VERSION@-{}'.format(version_hash),
127  ext_modules = extensions,
128  packages = packages,
129  package_data = package_data
130 )
void set(bool ownStorage, Vec3f *points_, unsigned int num_points_)
result_of::push_front< V const, T >::type append(T const &t, V const &v)
Append the element T at the front of boost fusion vector V.
Definition: fusion.hpp:24
def cxx_standard_cmp(lhs)
AD< Scalar > max(const AD< Scalar > &x, const AD< Scalar > &y)
def numpy_get_include()
def GenExtension(name)
def absolute(src)
def get_lib_name(path)


pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:32