From 4d238c5bfdfa11d5244699503502bbd8a09e606b Mon Sep 17 00:00:00 2001 From: Fabian Kirschner Date: Wed, 25 May 2022 20:43:29 +0200 Subject: [PATCH] feat (pkg): don't allow hyphen in python pkg name Signed-off-by: Fabian Kirschner --- ros2pkg/ros2pkg/verb/create.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ros2pkg/ros2pkg/verb/create.py b/ros2pkg/ros2pkg/verb/create.py index 35f9d1c8e..4eb35aaa7 100644 --- a/ros2pkg/ros2pkg/verb/create.py +++ b/ros2pkg/ros2pkg/verb/create.py @@ -140,12 +140,20 @@ def main(self, *, args): test_dependencies = ['ament_copyright', 'ament_flake8', 'ament_pep257', 'python3-pytest'] - if args.build_type == 'ament_python' and args.package_name == 'test': - # If the package name is 'test', there will be a conflict between - # the directory the source code for the package goes in and the - # directory the tests for the package go in. - return "Aborted since 'ament_python' packages can't be named 'test'. Please " + \ - 'choose a different package name.' + # Name checks (for python pkgs) + if args.build_type == 'ament_python': + if args.package_name == 'test': + # If the package name is 'test', there will be a conflict between + # the directory the source code for the package goes in and the + # directory the tests for the package go in. + return "Aborted since 'ament_python' packages can't be named 'test'. Please " + \ + 'choose a different package name.' + if '-' in args.package_name: + # Python packages shouldn't include hyphens in their name, refer to PEP-8. + # Running a via script 'ros2 run' with hyphens in the executable or package name + # results in errors. + return "Aborted since 'ament_python' packages can't include hyphens ('-') in " + \ + "their name (refer to PEP-8). Please choose a different package name." package = Package( package_format=args.package_format,