Ask Your Question

What is the correct layout of Python code when using --symlink-install in ROS 2?

asked 2018-11-22 01:59:28 -0500

Mut Ze gravatar image

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):

+-- scripts/
+-- src/
    +-- pkgname/
+-- setup.cfg
+-- package.xml

This directory is put under workspace/src/.

My is as follows:

from setuptools import setup, find_packages
package_name = "pkgname"
    package_dir={"": "src"},

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!

edit retag flag offensive close merge delete


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.

Dirk Thomas gravatar image Dirk Thomas  ( 2018-11-22 10:40:28 -0500 )edit

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.

Dirk Thomas gravatar image Dirk Thomas  ( 2018-11-22 10:41:14 -0500 )edit

Hello, here is the link to the package source:

Thanks for your help!

Mut Ze gravatar image Mut Ze  ( 2018-11-22 20:06:55 -0500 )edit

Hi @Dirk Thomas,

I stumbled upon a similar problem. Trying out a bare minimum ros2-python package provided by @Mut Ze in the link a new issue pops up.

Seems like the scripts option of is not supported by colcon-core. Will all the options available with be supported or are there restrictions to the supported options, as I'm unable to find any documentation in this regard.



ar13pit gravatar image ar13pit  ( 2020-01-29 07:32:52 -0500 )edit

@ar13pit Please create a new question instead. Also I don't think the statement "the scripts option of is not supported by colcon-core" is true.

Dirk Thomas gravatar image Dirk Thomas  ( 2020-01-29 11:11:56 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-12-14 16:38:41 -0500

Dirk Thomas gravatar image

The file of the package is using package_dir which older versions of colcondidn't support. Please update colcon-core to at least version 0.3.14. See for more details.

edit flag offensive delete link more


@Mut Ze please consider accepting the answer if it answers your question.

Dirk Thomas gravatar image Dirk Thomas  ( 2019-01-02 13:36:24 -0500 )edit

Oh thanks! Looks like that I missed the previous email... Sorry for the long delay and thanks again for your help.

Mut Ze gravatar image Mut Ze  ( 2019-01-02 20:29:31 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2018-11-22 01:59:28 -0500

Seen: 982 times

Last updated: Jan 29 '20