示例#1
0
def create_dependency_descriptor(requirement_string):
    """
    Create a DependencyDescriptor from a PEP440 compliant string.

    See https://www.python.org/dev/peps/pep-0440/#version-specifiers

    :param str requirement_string: a PEP440 compliant requirement string
    :return: A descriptor with version constraints from the requirement string
    :rtype: DependencyDescriptor
    """
    symbol_mapping = {
        '==': 'version_eq',
        '!=': 'version_neq',
        '<=': 'version_lte',
        '>=': 'version_gte',
        '>': 'version_gt',
        '<': 'version_lt',
    }

    requirement = parse_requirement(requirement_string)
    metadata = {}
    for symbol, version in (requirement.constraints or []):
        if symbol in symbol_mapping:
            metadata[symbol_mapping[symbol]] = version
        elif symbol == '~=':
            metadata['version_gte'] = version
            metadata['version_lt'] = _next_incompatible_version(version)
        else:
            logger.warn(
                "Ignoring unknown symbol '{symbol}' in '{requirement}'".format(
                    locals()))
    return DependencyDescriptor(requirement.name, metadata=metadata)
示例#2
0
def _get_package(path: str):
    """Get the ROS package for the given path."""
    from catkin_pkg.package import has_ros_schema_reference
    from catkin_pkg.package import InvalidPackage
    from catkin_pkg.package import package_exists_at
    from catkin_pkg.package import parse_package

    if not package_exists_at(path):
        return None

    try:
        pkg = parse_package(path)
    except (AssertionError, InvalidPackage) as e:  # noqa: F841
        if has_ros_schema_reference(path):
            logger.debug(
                "Found ROS schema reference in package manifest in '{path}'".
                format_map(locals()))
            logger.warn(
                "Failed to parse ROS package manifest in '{path}': {e}".
                format_map(locals()))
        else:
            logger.debug('Failed to parse potential ROS package manifest in'
                         "'{path}': {e}".format_map(locals()))
        return None

    pkg.evaluate_conditions(os.environ)
    return pkg
示例#3
0
def _get_build_type(pkg):
    """Get the build type of the ROS package."""
    from catkin_pkg.package import InvalidPackage
    try:
        return pkg.get_build_type()
    except InvalidPackage:
        logger.warn(
            "ROS package '{pkg.name}' in '{path}' has more than one "
            'build type'.format_map(locals()))
        return None
示例#4
0
def _get_build_type(pkg):
    """Get the build type of the ROS package."""
    from catkin_pkg.package import InvalidPackage
    try:
        build_type = pkg.get_build_type()
    except InvalidPackage:
        logger.warn("ROS package '{pkg.name}' in '{path}' has more than one "
                    'build type'.format_map(locals()))
        return None

    if build_type not in ('ament_cmake', 'ament_python', 'catkin', 'cmake'):
        path = os.path.dirname(pkg.filename)
        logger.debug("ROS package '{pkg.name}' in '{path}' has unknown build "
                     "type '{build_type}'".format_map(locals()))
        return None

    return build_type