`pkg create --build-type ament_python` should warn about hyphens in pkg-name
See original GitHub issueBug 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:
- Created a year ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 namedhello-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
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:
When it should be :
Where the difference is a underscore vs the hyphen. (Should be
script_dir
vs the autogeneratedscript-dir
)I hope this is helpful and related to resolving your issue.