Skip to content

add ament_cmake_python build type to ros2 pkg create#1233

Closed
darshmenon wants to merge 1 commit into
ros2:rollingfrom
darshmenon:add-ament-cmake-python-build-type
Closed

add ament_cmake_python build type to ros2 pkg create#1233
darshmenon wants to merge 1 commit into
ros2:rollingfrom
darshmenon:add-ament-cmake-python-build-type

Conversation

@darshmenon
Copy link
Copy Markdown

Closes #739

Adds ament_cmake_python as a valid --build-type option for ros2 pkg create, enabling users to scaffold a hybrid C++/Python package without having to manually write boilerplate.

What changes

verb/create.py

  • Added ament_cmake_python to the --build-type choices
  • Sets buildtool_depends to ['ament_cmake', 'ament_cmake_python']
  • Reuses ament_cmake test dependencies (lint tooling)
  • Exports build_type as ament_cmake in package.xml (correct — colcon treats it as a CMake package)
  • Calls populate_ament_cmake_python and creates a scripts/ node when --node-name is given

api/create.py

  • Added populate_ament_cmake_python — generates CMakeLists.txt and seeds the Python package directory with __init__.py and py.typed
  • Extended create_package_environment to create the Python package source folder for ament_cmake_python

resource/ament_cmake_python/CMakeLists.txt.em

  • New template: calls find_package(ament_cmake_python), ament_python_install_package(${PROJECT_NAME}), and optionally installs a node script

Usage

ros2 pkg create my_pkg --build-type ament_cmake_python --node-name my_node --dependencies rclpy

Generates a package with:

  • CMakeLists.txt using ament_cmake_python
  • my_pkg/__init__.py Python package
  • scripts/my_node executable node
  • Correct package.xml with both ament_cmake and ament_cmake_python buildtool deps

Copy link
Copy Markdown
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

@darshmenon

can you use our PR template to fill in? did you use any AI tools like Claude/Copilot, that needs to be disclosed, it looks like pretty much AI generated report is pated in the PR header.

and DCO is missing.

btw this replaces #1080?

@christophebedard
Copy link
Copy Markdown
Member

There's a PR for this already: #1080

@darshmenon darshmenon closed this by deleting the head repository May 16, 2026
@christophebedard
Copy link
Copy Markdown
Member

There's a PR for this already: #1080

In this case, reviews of that PR are certainly welcome. Anyone can review a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for ament_cmake_python in ros2 pkg create

3 participants