Repository Summary
Description | An extension for colcon-core that adds support for Poetry in ROS projects |
Checkout URI | https://github.com/urbanmachine/colcon-poetry-ros.git |
VCS Type | git |
VCS Version | main |
Last Updated | 2024-11-12 |
Dev Status | UNKNOWN |
Released | UNRELEASED |
Tags | python poetry ros2 colcon |
Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Packages
Name | Version |
---|---|
my_package | 1.0.0 |
README
colcon-poetry-ros
An extension for colcon-core that adds support for Python
packages that use Poetry within ROS. This extension is a replacement
for Colcon’s built-in setup.cfg
based Python support and the Python-related
bits in colcon-ros.
We use this extension with Humble, but other versions should work as well. Please create an issue if you see problems!
Getting Started
-
[Install Poetry][installing poetry] and the [Poetry Bundle plugin][installing poetry bundle], if you haven’t already.
-
Install this extension with Pip:
pip3 install colcon-poetry-ros
- Add a
pyproject.toml
in the root of your package’s directory. Each package should have its ownpyproject.toml
file. It should look something like this:
[tool.poetry]
name = "my_package"
version = "0.1.0"
description = "Does something cool"
authors = ["John Smith <johnny@urbanmachine.build>"]
license = "BSD-3-Clause"
[tool.poetry.dependencies]
python = "^3.8"
[tool.poetry.scripts]
node_a = "my_package.node_a:main"
node_b = "my_package.node_b:main"
[tool.colcon-poetry-ros.data-files]
"share/ament_index/resource_index/packages" = ["resource/my_package"]
"share/my_package" = ["package.xml"]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
- Install your packages’ Python dependencies using a script included with this plugin:
python3 -m colcon_poetry_ros.dependencies.install --base-paths <path to your nodes>
- Finally, run your build like normal:
colcon build
Testing
This extension currently supports projects based on PyTest. Run the following command to start tests:
colcon test
Node Entrypoints
If you want to be able to run your nodes using ros2 run
, add your node’s
entrypoint to the tool.poetry.scripts
table. See
Poetry’s documentation for details.
[tool.poetry.scripts]
node_a = "my_package.node_a:main"
node_b = "my_package.node_b:main"
Data Files
Poetry has only limited support for including data files in an installation,
and the current implementation is not flexible enough to be used with ROS.
Instead, this extension consults a custom section in your pyproject.toml
,
called tool.colcon-poetry-ros.data-files
.
The format is intended to be mostly identical to the data_files
field used
by [setuptools][setuptools-data-files]. The main differences are that copying
entire directories is supported, and globbing is not yet implemented.
File truncated at 100 lines see the full file