def augment_package( # noqa: D102 self, desc, *, additional_argument_names=None): if desc.type != 'python': return setup_py = desc.path / 'setup.py' if not setup_py.is_file(): return setup_cfg = desc.path / 'setup.cfg' if not setup_cfg.is_file(): return if not is_reading_cfg_sufficient(setup_py): return config = get_configuration(setup_cfg) version = config.get('metadata', {}).get('version') desc.metadata['version'] = version options = config.get('options', {}) dependencies = extract_dependencies(options) for k, v in dependencies.items(): desc.dependencies[k] |= v def getter(env): nonlocal options return options desc.metadata['get_python_setup_options'] = getter
def augment_package( # noqa: D102 self, desc, *, additional_argument_names=None ): if desc.type != 'ros.ament_python': return if 'get_python_setup_options' in desc.metadata: return setup_py = desc.path / 'setup.py' if not setup_py.is_file(): return setup_cfg = desc.path / 'setup.cfg' for _ in (1, ): # try to get information from setup.cfg file if setup_cfg.is_file(): if is_reading_cfg_sufficient(setup_py): config = get_configuration(setup_cfg) name = config.get('metadata', {}).get('name') if name: options = config.get('options', {}) def getter(env): nonlocal options return options break else: # use information from setup.py file def getter(env): # noqa: F811 nonlocal desc return get_setup_information( desc.path / 'setup.py', env=env) desc.metadata['get_python_setup_options'] = getter
def identify(self, desc): # noqa: D102 # ignore packages which have been identified with a different type if desc.type is not None and desc.type != 'ros': return # skip paths with an ignore marker file if (desc.path / 'CATKIN_IGNORE').exists(): raise IgnoreLocationException() if (desc.path / 'AMENT_IGNORE').exists(): raise IgnoreLocationException() # parse package manifest and get build type pkg, build_type = get_package_with_build_type(str(desc.path)) if not pkg or not build_type: # if it is not a wet ROS package check for a dry ROS package if (desc.path / 'manifest.xml').exists(): # ignore location to avoid being identified as a CMake package raise IgnoreLocationException() return # for Python build types ensure that a setup.py file exists if build_type == 'ament_python': setup_py = desc.path / 'setup.py' if not setup_py.is_file(): logger.error( "ROS package '{desc.path}' with build type '{build_type}' " "has no 'setup.py' file".format_map(locals())) raise IgnoreLocationException() desc.type = 'ros.{build_type}'.format_map(locals()) # use package name from manifest if not already set # e.g. from external configuration if desc.name is None: desc.name = pkg.name desc.metadata['version'] = pkg.version # get dependencies for d in pkg.build_depends + pkg.buildtool_depends: assert d.evaluated_condition is not None if d.evaluated_condition: desc.dependencies['build'].add( DependencyDescriptor(d.name, metadata=_create_metadata(d))) for d in (pkg.build_export_depends + pkg.buildtool_export_depends + pkg.exec_depends): assert d.evaluated_condition is not None if d.evaluated_condition: desc.dependencies['run'].add( DependencyDescriptor(d.name, metadata=_create_metadata(d))) for d in pkg.test_depends: assert d.evaluated_condition is not None if d.evaluated_condition: desc.dependencies['test'].add( DependencyDescriptor(d.name, metadata=_create_metadata(d))) # for Python build types ensure that a setup.py file exists if build_type == 'ament_python': setup_cfg = desc.path / 'setup.cfg' for _ in (1, ): # try to get information from setup.cfg file if setup_cfg.is_file(): if is_reading_cfg_sufficient(setup_py): config = get_configuration(setup_cfg) name = config.get('metadata', {}).get('name') if name: options = config.get('options', {}) def getter(env): nonlocal options return options break else: # use information from setup.py file def getter(env): # noqa: F811 nonlocal desc return get_setup_information(desc.path / 'setup.py', env=env) desc.metadata['get_python_setup_options'] = getter