Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove optional dependencies if --required-only is set. #16

Merged
merged 1 commit into from
Apr 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions internal-distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from __future__ import print_function
from collections import namedtuple
import argparse
import sys
import os
import sys
import vcstools
import yaml
import rospkg
from catkin_pkg.package import parse_package

DEPENDENCY_TYPES = [
DEPENDENCY_TYPES = [
'build_depends',
'build_export_depends',
'buildtool_depends',
Expand Down Expand Up @@ -76,6 +76,7 @@ def main():
parser.add_argument('distribution_file', type=str)
parser.add_argument('--package', type=str, action='append', dest='target_packages', default=[])
parser.add_argument('--repository', type=str, action='append', dest='target_repositories', default=[])
parser.add_argument('--required-only', action='store_true', dest='required_dependencies_only')
args = parser.parse_args()

if not os.path.exists(args.workspace):
Expand All @@ -94,7 +95,8 @@ def main():

repositories = {
name: Repository(name, options)
for name, options in packages_raw.iteritems() }
for name, options in packages_raw.iteritems()
}

# Build a map from package name to the repository that contains it, based
# soley on the information in the distribution file.
Expand Down Expand Up @@ -210,6 +212,20 @@ def main():
for dependency in getattr(package_manifest, dependency_type):
all_depends.add(dependency.name)

# Remove optional dependencies
if args.required_dependencies_only:
for export in package_manifest.exports:
if export.tagname != 'optional':
continue

dependency_name = export.content
if dependency_name not in all_depends:
raise ValueError(
'Optional dependency "{:s}" not found in package "{:s}".'.format(
dependency_name, package.name))

all_depends.remove(dependency_name)

# Only keep the dependencies that we know about.
def annotate_package_name(package_name):
if package_name in done_packages:
Expand Down