Go to the documentation of this file.00001 import os
00002 from ros_introspection.cmake import Command
00003 from ros_introspection.setup_py import SetupPy
00004 from util import roscompile
00005
00006
00007 def has_python(package):
00008 return len(package.source_code.get_source_by_language('python')) > 0
00009
00010
00011 def has_python_library(package):
00012 key = 'src/%s' % package.name
00013 for source in package.source_code.get_source_by_language('python'):
00014 if key in source.rel_fn:
00015 return True
00016 return False
00017
00018
00019 @roscompile
00020 def check_setup_py(package):
00021 if not has_python(package):
00022 return
00023 if package.setup_py is None:
00024 if not has_python_library(package):
00025
00026 return
00027 package.setup_py = SetupPy(package.name, os.path.join(package.root, 'setup.py'))
00028
00029 if 'catkin_python_setup' not in package.cmake.content_map:
00030 package.cmake.add_command(Command('catkin_python_setup'))
00031
00032
00033 @roscompile
00034 def update_python_installs(package):
00035 execs = [source.rel_fn for source in package.source_code.get_source_by_language('python') if source.is_executable()]
00036 if len(execs) == 0:
00037 return
00038 cmd = 'catkin_install_python'
00039 if cmd not in package.cmake.content_map:
00040 cmake_cmd = Command(cmd)
00041 cmake_cmd.add_section('PROGRAMS', execs)
00042 cmake_cmd.add_section('DESTINATION', ['${CATKIN_PACKAGE_BIN_DESTINATION}'])
00043 package.cmake.add_command(cmake_cmd)
00044 else:
00045 package.cmake.section_check(execs, cmd, 'PROGRAMS')