ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
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 image Dirk 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 image Dirk 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 image Mut Ze  ( 2018-11-22 20:06:55 -0600 )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 https://github.com/mutongx/ros2-python-symlink-install-test a new issue pops up.

Seems like the scripts option of setup.py is not supported by colcon-core. Will all the options available with setup.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 gravatar image ar13pit  ( 2020-01-29 07:32:52 -0600 )edit

@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.

Dirk Thomas gravatar image Dirk Thomas  ( 2020-01-29 11:11:56 -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 image Dirk 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 image Mut Ze  ( 2019-01-02 20:29:31 -0600 )edit

Question Tools

2 followers

Stats

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

Seen: 2,027 times

Last updated: Jan 29 '20