Ask Your Question
0

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

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

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

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!

edit retag flag offensive close merge delete

Comments

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 imageDirk Thomas ( 2018-11-22 10:40:28 -0600 )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 imageDirk Thomas ( 2018-11-22 10:41:14 -0600 )edit

Hello, here is the link to the package source: https://github.com/mutongx/ros2-python-symlink-install-test

Thanks for your help!

Mut Ze gravatar imageMut Ze ( 2018-11-22 20:06:55 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

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

Dirk Thomas gravatar image

The setup.py 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 https://github.com/colcon/colcon-core... for more details.

edit flag offensive delete link more

Comments

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

Dirk Thomas gravatar imageDirk Thomas ( 2019-01-02 13:36:24 -0600 )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 imageMut Ze ( 2019-01-02 20:29:31 -0600 )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

2 followers

Stats

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

Seen: 512 times

Last updated: Dec 14 '18