Autocomplete in Eclipse with Catkin and Python Packages

asked 2014-10-15 13:29:21 -0500

Peaches491 gravatar image

So, i'm attempting to write a Python Module within a ROS Package (using Catkin)

I have the following directory structure

package_name
    CMakeLists.txt
    setup.py
    - src
        - package_name (again)
            - module_1
                __init__.py (blank)
                SourceFileWithClassesAndWhatnot1.py
            - module_2
                __init__.py (blank)
                SourceFileWithClassesAndWhatnot2.py
            - module_3
                __init__.py (blank)
                SourceFileWithClassesAndWhatnot3.py

In my CMakeLists, I have uncommented the catkin_python_setup() and catkin_package() calls. However, I am not seeing any of these modules come up when I use autocomplete in eclispe. I've edited my eclipse .desktop file with the bash -i -c eclipse command.

Here are the contents of my setup.py

#!/usr/bin/env python

from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup(
    packages=['heres_how_python_utils.conversions', 'heres_how_python_utils.services', 'heres_how_python_utils.json'],
    package_dir={'': 'src'}
)

print(setup(**d))

Any thoughts as to why this might not be working? I have other python modules set up in the same workspace which are autocompleting nicely.

Thanks!

edit retag flag offensive close merge delete

Comments

I've found that the setup.sh command sets up the PYTHONPATH to use the /devel directory. However, in this directory, /package_name only has an __init__ file, which has a bunch of auto-generated import code in it. How can I set the PYTHONPATH to use the src directory instead?

Peaches491 gravatar image Peaches491  ( 2014-10-15 14:47:53 -0500 )edit

It must be set to the devel folder if you have any generated code (like messages or services). Otherwise you can manually set it to the source folder. The __init__.py files in the devel folder will probably mess with any kind of tab completion stuff.

William gravatar image William  ( 2014-10-15 15:23:16 -0500 )edit