setup.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- Python -*-
00003 # -*- coding: utf-8 -*-
00004 
00005 '''rtctree
00006 
00007 Copyright (C) 2009-2014
00008     Geoffrey Biggs
00009     RT-Synthesis Research Group
00010     Intelligent Systems Research Institute,
00011     National Institute of Advanced Industrial Science and Technology (AIST),
00012     Japan
00013     All rights reserved.
00014 Licensed under the Eclipse Public License -v 1.0 (EPL)
00015 http://www.opensource.org/licenses/eclipse-1.0.txt
00016 
00017 rtctree install script.
00018 
00019 '''
00020 
00021 
00022 from distutils import errors
00023 from distutils import log
00024 from distutils import util
00025 from distutils.cmd import Command
00026 from distutils.core import setup
00027 from distutils.command import build
00028 import os
00029 import os.path
00030 import subprocess
00031 import sys
00032 
00033 
00034 def gen_idl_name(dir, name):
00035     '''Generate IDL file name from directory prefix and IDL module name.'''
00036     return os.path.join(dir, name + '.idl')
00037 
00038 
00039 class BuildIDL(Command):
00040     '''Implemented the build IDL subcommand.'''
00041 
00042     description = 'Generate Python stubs from IDL files'
00043 
00044     user_options = [('omniidl=', 'i', 'omniidl program used to build stubs'),
00045                     ('idldir=',  'd', 'directory where IDL files reside')
00046                     ]
00047 
00048     def initialize_options(self):
00049         self.idl_dir  = None
00050         self.omniidl = None
00051         self.omniidl_params = ['-bpython']
00052         self.idl_files = ['BasicDataType', 'ComponentObserver',
00053                 'ExtendedDataTypes', 'InterfaceDataTypes', 'DataPort',
00054                 'Logger', 'Manager', 'OpenRTM', 'RTC', 'SDOPackage']
00055 
00056     def finalize_options(self):
00057         if not self.omniidl:
00058             self.omniidl = 'omniidl'
00059         if not self.idl_dir:
00060             self.idl_dir = os.path.join(os.getcwd(), 'rtctree', 'rtmidl')
00061 
00062     def compile_idl(self, cmd, params, files):
00063         log.info('{0} {1} {2}'.format(cmd, ' '.join(params), ' '.join(files)))
00064         process = subprocess.Popen([cmd] + params + files,
00065                 stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
00066                 cwd=self.idl_dir)
00067         stdout, stderr = process.communicate()
00068         log.info(stdout)
00069         if process.returncode != 0:
00070             raise errors.DistutilsExecError('Error compiling IDL \
00071 ({0})'.format(process.returncode))
00072 
00073     def run(self):
00074         util.execute(self.compile_idl,
00075                      (self.omniidl, self.omniidl_params,
00076                          [gen_idl_name(self.idl_dir, idl_file) \
00077                                  for idl_file in self.idl_files]),
00078                      msg='Generating python stubs from IDL files')
00079 
00080 
00081 class CustomBuild(build.build):
00082     def has_pure_modules(self):
00083         return self.distribution.has_pure_modules()
00084 
00085     def has_c_libraries(self):
00086         return self.distribution.has_c_libraries()
00087 
00088     def has_ext_modules(self):
00089         return self.distribution.has_ext_modules()
00090 
00091     def has_scripts(self):
00092         return self.distribution.has_scripts()
00093 
00094     def has_idl_files(self):
00095         return True
00096 
00097     sub_commands = [('build_idl', has_idl_files),
00098                     ('build_py', has_pure_modules),
00099                     ('build_clib', has_c_libraries),
00100                     ('build_ext', has_ext_modules),
00101                     ('build_scripts', has_scripts)
00102                     ]
00103 
00104 
00105 setup(name='rtctree',
00106       version='3.0.0',
00107       description='API for interacting with running RT Components and \
00108 managing RTM-based systems.',
00109       long_description='API for interacting with running RT Components and \
00110 managing RTM-based systems.',
00111       author='Geoffrey Biggs',
00112       author_email='git@killbots.net',
00113       url='http://github.com/gbiggs/rtctree',
00114       license='EPL',
00115       classifiers=[
00116           'Development Status :: 5 - Production/Stable',
00117           'Intended Audience :: Developers',
00118           'License :: OSI Approved :: EPL License',
00119           'Natural Language :: English',
00120           'Operating System :: OS Independent',
00121           'Programming Language :: Python :: 2.6',
00122           'Programming Language :: Python :: 2.7',
00123           'Topic :: Software Development',
00124           ],
00125       packages=['rtctree',
00126                 'rtctree.rtmidl',
00127                 'rtctree.rtmidl.OpenRTM',
00128                 'rtctree.rtmidl.OpenRTM__POA',
00129                 'rtctree.rtmidl.RTC',
00130                 'rtctree.rtmidl.RTC__POA',
00131                 'rtctree.rtmidl.RTM',
00132                 'rtctree.rtmidl.RTM__POA',
00133                 'rtctree.rtmidl.SDOPackage',
00134                 'rtctree.rtmidl.SDOPackage__POA'],
00135       cmdclass={'build':CustomBuild, 'build_idl': BuildIDL}
00136       )
00137 
00138 
00139 # vim: tw=79
00140 


rtctree
Author(s): Geoffrey Biggs
autogenerated on Wed Aug 26 2015 16:13:08