What is the correct layout of Python code when using --symlink-install in ROS 2?
Hi all,
I'm trying to write a Python node in ROS 2. Here is my package directory layout (assume pkgname
is my ROS package's name):
pkgroot/
+-- scripts/
+-- node.py
+-- src/
+-- pkgname/
+-- src.py
+-- setup.py
+-- setup.cfg
+-- package.xml
This directory is put under workspace/src/
.
My setup.py
is as follows:
from setuptools import setup, find_packages
package_name = "pkgname"
setup(
name=package_name,
version="0.0.1",
packages=find_packages("src"),
package_dir={"": "src"},
scripts=["scripts/node.py"],
zip_safe=True
)
colcon build
works normally as usual. But when I'm trying to use the --symlink-install
option, colcon tells me:
error: error in 'egg_base' option: 'src' does not exist or is not a directory
After inspecting the build
directory, I found that colcon created a symlink to workspace/src/pkgroot/pkgname
instead of workspace/src/pkgroot/src/pkgname
.
Since I want to separate scripts
and src
directory, I don't want to put the actual Python module code (pkgroot/src/pkgname
) directly under my package root (pkgroot/pkgname
).
Any suggestions? Thanks!
There should be no need to change the package layout in order to work with
--symlink-install
. The option should work transparently. Since your layout is not the default for Python packages we might not have encountered that case yet hence the problem.Please share are ready-to-build package and I am happy to take a closer look why it fails and how
colcon-python-setup-py
needs to be patches to support this use case.Hello, here is the link to the package source: https://github.com/mutongx/ros2-python-symlink-install-test
Thanks for your help!
Hi @Dirk Thomas,
I stumbled upon a similar problem. Trying out a bare minimum ros2-python package provided by @Mut Ze in the link https://github.com/mutongx/ros2-python-symlink-install-test a new issue pops up.
Seems like the
scripts
option ofsetup.py
is not supported bycolcon-core
. Will all the options available withsetup.py
be supported or are there restrictions to the supported options, as I'm unable to find any documentation in this regard.Thanks,
Arpit
@ar13pit Please create a new question instead. Also I don't think the statement "the scripts option of setup.py is not supported by colcon-core" is true.