Skip to content
This repository has been archived by the owner on Feb 4, 2020. It is now read-only.

Add list_dependencies verb #133

Merged
merged 15 commits into from
Mar 20, 2017
Merged

Add list_dependencies verb #133

merged 15 commits into from
Mar 20, 2017

Conversation

rolling-robot
Copy link
Contributor

Hello,
This commit is intended to fix #113, however I have found another bug related to command line options. See osrf/osrf_pycommon#33

@mikaelarguedas
Copy link
Contributor

mikaelarguedas commented Feb 24, 2017

Hi @rolling-robot,
Thanks for taking on this task!

I tried this code and it just works 🎉 👍

Few comments on this PR:

  • setup.py will need to know how to install your verb in the ament.verb list. This will allow users when sourcing an installed workspace to type ament list_dependencies from anywhere on their system
  • It would be awesome if the default behavior was to display all dependencies
    • Right now if I run ament list_dependencies PACKAGE_NAME (without specifying any of the options) it returns nothing. I would naively conclude that PACKAGE_NAME doesn't have any dependency.
  • auto completing the package names in the commandline would also be a great addition, pointer here
  • the help message says that this code outputs the relative paths of the dependencies, I think it's a copy paste artifact

Minor style nipticks (We can fix them for you once this PR has been approved, it's more to let you know the few style gotchas that are not enforced by our linters):

  • We usually wrap lines right after parenthesis (like you did for argparse arguments declaration), doing the same here
    • Rationale: The resulting block indent is independant of the line where the parenthesis is open, so changing anything on the first line don't force you to reindent every line of the block.
    • The linters don't check it and it's explained only in the C++ section of the developer guide so you couldn't know. I'll update the Developer Guide to make the guideline apply to all languages
  • We list verbs alphabetically where we can, in this case moving this before list_packages
  • Copyright for new code should use the current year

@mikaelarguedas
Copy link
Contributor

Thanks for the quick iteration!

I just noticed that the list is not filtered before being printed. Do you think you could remove the duplicates before displaying the dependency list ?

Nitpick: It looks like the travis job failed for a style thing (missing space after a # here)

type=argparse_existing_dir,
default=os.curdir,
help='Base paths to recursively crawl for packages',
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having an optional positional argument changes the semantic of the first passed argument based on if a second argument is passed or not. I think that is counter intuitive and I would suggest using a non-positional argument for the base path instead.

deps = []
packages = find_packages(options.basepath)
# show all dependencies if no options are given
if(not (options.build_deps or options.test_deps or options.exec_deps)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the unnecessary outer parenthesis.

package.buildtool_export_depends +
package.build_depends +
package.buildtool_depends +
package.doc_depends
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't consider doc_depends a build dependency. Maybe it would be best to add a separate option to list doc dependencies and remove them from this set.

for line in sorted(set(map(lambda dep: dep.name, deps))):
print(line)
return
print('No package with name {!r} found'.format(options.package))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error messages should go to stderr.

COMPREPLY=($(compgen -W "$(ament list_packages --names-only)" -- ${cur}))
else
COMPREPLY=($(compgen -W "--build-deps --exec-deps --test-deps $(ament list_packages --names-only)" -- ${cur}))
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The completion doesn't consider the passed basepath atm.

deps = []
packages = find_packages(options.basepath)
# show all dependencies if no options are given
if not (options.build_deps or options.doc_depends or options.exec_deps or options.test_deps):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be doc_deps to match the argument defined in the parser, same thing line 63

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, silly typo.

for line in sorted(set(map(lambda dep: dep.name, deps))):
print(line)
return
print('No package with name {!r} found'.format(options.package), sys.stderr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this still prints to standard output, I think you want file=sys.stderr here

@mikaelarguedas
Copy link
Contributor

Hi @rolling-robot, Sorry for letting this slide. Except one or two comments it looks good to me! Thanks for iterating on this

@dirk-thomas any more comments on this ?

if options.build_deps:
deps.extend(
package.build_export_depends +
package.buildtool_export_depends +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two build export dependencies are not necessary for building but are made available to downstream packages. Therefore I would recommend to move them into the exec_deps block.

(Sorry I didn't notice this is the first round of review.)

)
if options.doc_deps:
deps.extend(package.doc_depends)
if options.exec_deps:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the comment above I would recommend to change this option to run_deps (which will include the exec depends as well as both build export depends).

Copy link
Contributor

@dirk-thomas dirk-thomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for iterating on it.

@mikaelarguedas
Copy link
Contributor

thank you both for iterating on this. I'll go ahead and merge this.

@mikaelarguedas mikaelarguedas merged commit dbee8dc into ament:master Mar 20, 2017
@rolling-robot
Copy link
Contributor Author

Thanks everyone!

@rolling-robot rolling-robot deleted the list-deps branch March 20, 2017 19:15
@dirk-thomas
Copy link
Contributor

@rolling-robot Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability for ament to list the dependencies of a given package
3 participants