logInspector/setup.py
Go to the documentation of this file.
1 from setuptools import setup, Extension
2 from setuptools.command.build_ext import build_ext
3 import sys
4 import setuptools
5 
6 __version__ = '0.0.1'
7 # os.environ["CC"] = "g++-4.7" os.environ["CXX"] = "g++-4.7"
8 
9 class get_pybind_include(object):
10  """Helper class to determine the pybind11 include path
11 
12  The purpose of this class is to postpone importing pybind11
13  until it is actually installed, so that the ``get_include()``
14  method can be invoked. """
15 
16  def __init__(self, user=False):
17  self.user = user
18 
19  def __str__(self):
20  import pybind11
21  return pybind11.get_include(self.user)
22 
23 
24 ext_modules = [
25  Extension(
26  'log_reader',
27  ['src/log_reader.cpp',
28  '../../src/cltool.cpp',
29  '../../src/cltool_main.cpp',
30  '../../src/convert_ins.cpp',
31  '../../src/com_manager.c',
32  '../../src/data_sets.c',
33  '../../src/DataChunk.cpp',
34  '../../src/DataChunkSorted.cpp',
35  '../../src/DataCSV.cpp',
36  '../../src/DataJSON.cpp',
37  '../../src/DataKML.cpp',
38  '../../src/DeviceLog.cpp',
39  '../../src/DeviceLogCSV.cpp',
40  '../../src/DeviceLogJSON.cpp',
41  '../../src/DeviceLogKML.cpp',
42  '../../src/DeviceLogSerial.cpp',
43  '../../src/DeviceLogSorted.cpp',
44  '../../src/InertialSense.cpp',
45  '../../src/inertialSenseBootLoader.c',
46  '../../src/ISComm.c',
47  '../../src/ISDataMappings.cpp',
48  '../../src/ISDisplay.cpp',
49  '../../src/ISEarth.c',
50  '../../src/ISFileManager.cpp',
51  '../../src/ISLogFile.cpp',
52  '../../src/ISLogger.cpp',
53  '../../src/ISMatrix.c',
54  '../../src/ISPose.c',
55  '../../src/ISSerialPort.cpp',
56  '../../src/ISStream.cpp',
57  '../../src/ISTcpClient.cpp',
58  '../../src/ISTcpServer.cpp',
59  '../../src/ISUtilities.cpp',
60  '../../src/linked_list.c',
61  '../../src/serialPort.c',
62  '../../src/serialPortPlatform.c',
63  '../../src/time_conversion.c',
64  '../../src/tinystr.cpp',
65  '../../src/tinyxml.cpp',
66  '../../src/tinyxmlerror.cpp',
67  '../../src/tinyxmlparser.cpp'],
68  include_dirs=[
69  # Path to pybind11 headers
70  'include',
71  '../src',
72  '../../src',
74  get_pybind_include(user=True)
75  ],
76  language='c++'
77  ),
78 ]
79 
80 
81 # As of Python 3.6, CCompiler has a `has_flag` method.
82 # cf http://bugs.python.org/issue26689
83 def has_flag(compiler, flagname):
84  """Return a boolean indicating whether a flag name is supported on
85  the specified compiler.
86  """
87  import tempfile
88  with tempfile.NamedTemporaryFile('w', suffix='.cpp') as f:
89  f.write('int main (int argc, char **argv) { return 0; }')
90  try:
91  compiler.compile([f.name], extra_postargs=[flagname])
92  except setuptools.distutils.errors.CompileError:
93  return False
94  return True
95 
96 
97 def cpp_flag(compiler):
98  """Return the -std=c++[11/14] compiler flag.
99 
100  The c++14 is prefered over c++11 (when it is available).
101  """
102  if has_flag(compiler, '-std=c++14'):
103  return '-std=c++14'
104  elif has_flag(compiler, '-std=c++11'):
105  return '-std=c++11'
106  else:
107  raise RuntimeError('Unsupported compiler -- at least C++11 support '
108  'is needed!')
109 
110 
111 class BuildExt(build_ext):
112  """A custom build extension for adding compiler-specific options."""
113  c_opts = {
114  'msvc': ['/EHsc'],
115  'unix': ['-O3'],
116  }
117 
118  if sys.platform == 'darwin':
119  c_opts['unix'] += ['-stdlib=libc++', '-mmacosx-version-min=10.7']
120 
121  def build_extensions(self):
122  ct = self.compiler.compiler_type
123  opts = self.c_opts.get(ct, [])
124  if ct == 'unix':
125  opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
126  opts.append(cpp_flag(self.compiler))
127 # if has_flag(self.compiler, '-fvisibility=hidden'):
128 # opts.append('-fvisibility=hidden ')
129  elif ct == 'msvc':
130  opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
131  for ext in self.extensions:
132  ext.extra_compile_args = opts
133  build_ext.build_extensions(self)
134 
135 setup(
136  name='log_reader',
137  version=__version__,
138  author='James Jackson',
139  author_email='superjax08@gmail.com',
140  description='pybind interface to reading InertialSense Log files',
141  long_description='',
142  ext_modules=ext_modules,
143  install_requires=['pybind11>=2.2',
144  'pyqt5',
145  'numpy',
146  'matplotlib',
147  'pyyaml',
148  'pyserial',
149  'scipy',
150  'tqdm',
151  'simplekml'],
152  cmdclass={'build_ext': BuildExt},
153  zip_safe=False,
154 )
def has_flag(compiler, flagname)


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:58