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.tomlin the root of your package's directory. Each package should have its ownpyproject.tomlfile. 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. The main differences are that copying
entire directories is supported, and globbing is not yet implemented.
All ROS packages must have, at minimum, these entries in the
tool.colcon-poetry-ros.data-files section (with {package_name} replaced
with the name of your package):
[tool.colcon-poetry-ros.data-files]
"share/ament_index/resource_index/packages" = ["resource/{package_name}"]
"share/{package_name}" = ["package.xml"]
These entries take care of adding the package index marker and package.xml
file to the installation.
Python Dependency Details
Poetry dependencies are not installed as part of the build process, so they must be installed using a separate tool that's included in this package.
python3 -m colcon_poetry_ros.dependencies.install --base-paths <path to your nodes>
This command creates a virtual environment within Colcon's base install directory, then installs each package's dependencies in that virtual environment.
If you customize colcon build with the --install-base or --merge-install
flags, make sure to provide those to this tool as well.
We split dependency installation out of colcon build to make development
iterations faster. Third-party dependencies change less frequency than first
party code, so it's often a waste of time to resolve dependencies on every
iteration. This is especially elegant in container-based workflows, an example
of which can be found in the examples/ directory.
Communicating Package Dependencies to Colcon
Colcon can be given information on dependencies between packages, which
affects build order and can be displayed in tools like colcon graph. These
dependencies can be explicitly defined in the pyproject.toml under a custom
section called tool.colcon-poetry-ros.dependencies.
[tool.colcon-poetry-ros.dependencies]
depend = ["foo_package"] # This will add to both `build_depend` and `exec_depend` following `package.xml` standards
build_depend = ["bar_package"]
exec_depend = ["baz_package"]
test_depend = ["qux_package"]
Metadata
Release files for colcon-poetry-ros 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| colcon_poetry_ros-0.9.0.tar.gz | 14.5 kB | Without provenance | Details for colcon_poetry_ros-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| colcon_poetry_ros-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for colcon_poetry_ros-0.9.0-py3-none-any.whl |
Total release size: 30.9 kB
Release files / colcon_poetry_ros-0.9.0.tar.gz
| Download URL | colcon_poetry_ros-0.9.0.tar.gz |
|---|---|
| Size | 14.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8821ff6f17dbf5e349d33210d8603cda515a54b656f7d22ec88a7403f7f79366
|
|
BLAKE2b-256 checksum How to use checksums |
c43941ebb8e0615ec67181cbd404252e64332bb9449f65b79aac9898f18038a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Release files / colcon_poetry_ros-0.9.0-py3-none-any.whl
| Download URL | colcon_poetry_ros-0.9.0-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6dbf51e440f34efb59a90503f6bb67556d0109720a653a0001339e058eb1127
|
|
BLAKE2b-256 checksum How to use checksums |
843437c0e11b0963700fee9527f8836f1fca305196a35af3ff62b99b3c23a1ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Security for colcon-poetry-ros 0.9.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.