This project is a tiny python library made for ROS2 modules to simplify the packaging process.
Instead of having two files -setup.py
and package.xml
- with the same duplicated information, this module makes it easy dynamically import the information from the package.xml
into the python setup file.
This way, only the package.xml file has to be edited, to prevent having the two files with conflicting information.
Either install with pip install ros2setup
, or copy ros2setup.py next to your setup.py so that it is accessible from there.
In the setup.py file of your ROS2 package, change the hardcoded information to a call to Ros2Setup to pull the data from the XML file.
from setuptools import setup
from ros2setup import Ros2Setup
package_name = Ros2Setup.tag('name')
setup(
name=package_name,
version=Ros2Setup.tag('version'),
packages=[package_name],
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
],
install_requires=['setuptools'],
zip_safe=True,
maintainer=Ros2Setup.tag('maintainer'),
maintainer_email=Ros2Setup.attrib('maintainer', 'email'),
description=Ros2Setup.tag('description'),
license=Ros2Setup.tag('license'),
tests_require=['pytest'],
entry_points={
'console_scripts': [
'streamer = mypackage.submodule:main',
],
},
)