python_setup.py
Go to the documentation of this file.
1 import os
2 
3 from ros_introspection.cmake import Command, SectionStyle
4 from ros_introspection.setup_py import SetupPy
5 
6 from .cmake import CATKIN_INSTALL_PYTHON_PRENAME
7 from .util import roscompile
8 
9 
10 def has_python(package):
11  return len(package.source_code.get_source_by_language('python')) > 0
12 
13 
14 def has_python_library(package):
15  key = 'src/%s' % package.name
16  for source in package.source_code.get_source_by_language('python'):
17  if key in source.rel_fn:
18  return True
19  return False
20 
21 
22 @roscompile
23 def check_setup_py(package):
24  if not has_python(package):
25  return
26  if package.setup_py is None:
27  if not has_python_library(package):
28  # No library, and no existing setup_py means nothing to write
29  return
30  package.setup_py = SetupPy(package.name, os.path.join(package.root, 'setup.py'))
31 
32  if 'catkin_python_setup' not in package.cmake.content_map:
33  package.cmake.add_command(Command('catkin_python_setup'))
34 
35 
36 @roscompile
38  execs = [source.rel_fn for source in package.source_code.get_source_by_language('python') if source.is_executable()]
39  if len(execs) == 0:
40  return
41  cmd = 'catkin_install_python'
42  if cmd not in package.cmake.content_map:
43  cmake_cmd = Command(cmd)
44  cmake_cmd.add_section('PROGRAMS', execs)
45  cmake_cmd.add_section('DESTINATION', ['${CATKIN_PACKAGE_BIN_DESTINATION}'],
46  SectionStyle(CATKIN_INSTALL_PYTHON_PRENAME))
47  package.cmake.add_command(cmake_cmd)
48  else:
49  package.cmake.section_check(execs, cmd, 'PROGRAMS')
def update_python_installs(package)
Definition: python_setup.py:37
def has_python(package)
Definition: python_setup.py:10
def check_setup_py(package)
Definition: python_setup.py:23
def has_python_library(package)
Definition: python_setup.py:14


roscompile
Author(s):
autogenerated on Wed Mar 3 2021 03:56:01