setup.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- Python -*-
3 # -*- coding: utf-8 -*-
4 
5 '''rtctree
6 
7 Copyright (C) 2009-2014
8  Geoffrey Biggs
9  RT-Synthesis Research Group
10  Intelligent Systems Research Institute,
11  National Institute of Advanced Industrial Science and Technology (AIST),
12  Japan
13  All rights reserved.
14 Licensed under the Eclipse Public License -v 1.0 (EPL)
15 http://www.opensource.org/licenses/eclipse-1.0.txt
16 
17 rtctree install script.
18 
19 '''
20 
21 
22 from distutils import errors
23 from distutils import log
24 from distutils import util
25 from distutils.cmd import Command
26 from distutils.core import setup
27 from distutils.command import build
28 import os
29 import os.path
30 import subprocess
31 import sys
32 
33 
34 def gen_idl_name(dir, name):
35  '''Generate IDL file name from directory prefix and IDL module name.'''
36  return os.path.join(dir, name + '.idl')
37 
38 
39 class BuildIDL(Command):
40  '''Implemented the build IDL subcommand.'''
41 
42  description = 'Generate Python stubs from IDL files'
43 
44  user_options = [('omniidl=', 'i', 'omniidl program used to build stubs'),
45  ('idldir=', 'd', 'directory where IDL files reside')
46  ]
47 
48  def initialize_options(self):
49  self.idl_dir = None
50  self.omniidl = None
51  self.omniidl_params = ['-bpython']
52  self.idl_files = ['BasicDataType', 'ComponentObserver',
53  'ExtendedDataTypes', 'InterfaceDataTypes', 'DataPort',
54  'Logger', 'Manager', 'OpenRTM', 'RTC', 'SDOPackage']
55 
56  def finalize_options(self):
57  if not self.omniidl:
58  self.omniidl = 'omniidl'
59  if not self.idl_dir:
60  self.idl_dir = os.path.join(os.getcwd(), 'rtctree', 'rtmidl')
61 
62  def compile_idl(self, cmd, params, files):
63  log.info('{0} {1} {2}'.format(cmd, ' '.join(params), ' '.join(files)))
64  process = subprocess.Popen([cmd] + params + files,
65  stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
66  cwd=self.idl_dir)
67  stdout, stderr = process.communicate()
68  log.info(stdout)
69  if process.returncode != 0:
70  raise errors.DistutilsExecError('Error compiling IDL \
71 ({0})'.format(process.returncode))
72 
73  def run(self):
74  util.execute(self.compile_idl,
75  (self.omniidl, self.omniidl_params,
76  [gen_idl_name(self.idl_dir, idl_file) \
77  for idl_file in self.idl_files]),
78  msg='Generating python stubs from IDL files')
79 
80 
81 class CustomBuild(build.build):
82  def has_pure_modules(self):
83  return self.distribution.has_pure_modules()
84 
85  def has_c_libraries(self):
86  return self.distribution.has_c_libraries()
87 
88  def has_ext_modules(self):
89  return self.distribution.has_ext_modules()
90 
91  def has_scripts(self):
92  return self.distribution.has_scripts()
93 
94  def has_idl_files(self):
95  return True
96 
97  sub_commands = [('build_idl', has_idl_files),
98  ('build_py', has_pure_modules),
99  ('build_clib', has_c_libraries),
100  ('build_ext', has_ext_modules),
101  ('build_scripts', has_scripts)
102  ]
103 
104 
105 setup(name='rtctree',
106  version='3.0.0',
107  description='API for interacting with running RT Components and \
108 managing RTM-based systems.',
109  long_description='API for interacting with running RT Components and \
110 managing RTM-based systems.',
111  author='Geoffrey Biggs',
112  author_email='git@killbots.net',
113  url='http://github.com/gbiggs/rtctree',
114  license='EPL',
115  classifiers=[
116  'Development Status :: 5 - Production/Stable',
117  'Intended Audience :: Developers',
118  'License :: OSI Approved :: EPL License',
119  'Natural Language :: English',
120  'Operating System :: OS Independent',
121  'Programming Language :: Python :: 2.6',
122  'Programming Language :: Python :: 2.7',
123  'Topic :: Software Development',
124  ],
125  packages=['rtctree',
126  'rtctree.rtmidl',
127  'rtctree.rtmidl.OpenRTM',
128  'rtctree.rtmidl.OpenRTM__POA',
129  'rtctree.rtmidl.RTC',
130  'rtctree.rtmidl.RTC__POA',
131  'rtctree.rtmidl.RTM',
132  'rtctree.rtmidl.RTM__POA',
133  'rtctree.rtmidl.SDOPackage',
134  'rtctree.rtmidl.SDOPackage__POA'],
135  cmdclass={'build':CustomBuild, 'build_idl': BuildIDL}
136  )
137 
138 
139 # vim: tw=79
140 
def has_c_libraries(self)
Definition: setup.py:85
Definition: setup.py:1
def has_ext_modules(self)
Definition: setup.py:88
def has_pure_modules(self)
Definition: setup.py:82
def finalize_options(self)
Definition: setup.py:56
def compile_idl(self, cmd, params, files)
Definition: setup.py:62
def initialize_options(self)
Definition: setup.py:48
def run(self)
Definition: setup.py:73
def has_idl_files(self)
Definition: setup.py:94
def gen_idl_name(dir, name)
Definition: setup.py:34
def has_scripts(self)
Definition: setup.py:91


rtctree
Author(s): Geoffrey Biggs
autogenerated on Fri Jun 7 2019 21:56:24