question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`pkg create --build-type ament_python` should warn about hyphens in pkg-name

See original GitHub issue

Bug report

Required Info:

  • Operating System:
    • Ubuntu 22.04
  • Installation type:
    • binaries
  • Version or commit hash:
    • humble
  • DDS implementation:
    • /
  • Client library (if applicable):
    • ros2cli

Steps to reproduce issue

cd src
ros2 pkg create --build-type ament_python --license MIT --node-name hello-world  hello-world-python-1   # build breaks
ros2 pkg create --build-type ament_python --license MIT --node-name hello_world  hello-world-python-2   # build breaks
ros2 pkg create --build-type ament_python --license MIT --node-name hello-world  hello_world_python_3   # build breaks
ros2 pkg create --build-type ament_python --license MIT --node-name hello_world  hello_world_python_4   # build works
cd ..
colcon build --packages-select hello-world-python-1 # breaks
colcon build --packages-select hello-world-python-2 # breaks
colcon build --packages-select hello_world_python_3 # breaks
colcon build --packages-select hello_world_python_4 # works

Expected behavior

When running ros2 pkg create with --build-type ament_python warn about hyphens in the name / or abort pkg creation.

Actual behavior

No warning

Additional information

Not really a bug of ros2cli but also not really a feature request. I’d expect a warning, thats why I put it as a bug report.
I assume the check can easily be added here.

If there is agreement on that, I can open a PR with it. Please let me know 😃

For reference: PEP-8: Package and Module Names

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
aprotyascommented, May 24, 2022

For what it is worth, while using underscore is our best practice, I don’t think hyphens should fail. I would prefer we figure out why hyphens are having problems.

I think what’s happening is that when you invoke ros2 pkg create --build-type ament_python --license MIT --node-name hello-world hello-world-python-1, a module named hello-world is created. I don’t know where exactly it fails, but from what I understand modules with hyphens in the name can’t be loaded/imported.

This thread touches on something tangentially related: https://stackoverflow.com/a/54599368

0reactions
808brickcommented, Jun 27, 2022

For what it’s worth, it seems the issue you may be facing is not from the package name, but the setupcfg file that get’s autogenerated.

It seems when the command is run, the setup.cfg file is created like so:

[develop]
script-dir=$base/lib/hello-world-python
[install]
install-scripts=$base/lib/hello-world-python

When it should be :

[develop]
script_dir=$base/lib/hello-world-python
[install]
install_scripts=$base/lib/hello-world-python

Where the difference is a underscore vs the hyphen. (Should be script_dir vs the autogenerated script-dir)

I hope this is helpful and related to resolving your issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · ros2/ros2cli - GitHub
pkg create --build-type ament_python should warn about hyphens in pkg-name help wanted Extra attention is needed. #715 opened on May 20 by krsche....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found