ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

In order to export python libraries you need to do two things:

  • Setup a setup.py file describing which Python packages your package has.
  • Call the catkin_python_setup() macro in your CMakeLists.txt

Reference: http://docs.ros.org/api/catkin/html/user_guide/setup_dot_py.html

The setup.py should be in the root of your package and look like this:

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

d = generate_distutils_setup(
    packages=['mypkg'],
    scripts=['bin/myscript'],
    package_dir={'': 'src'}
)

setup(**d)

And in your CMakeLists.txt you need to call before catkin_package(...):

catkin_python_setup()

Also, get rid of these lines:

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

This was someting that rosbuild had you do, but you shouldn't do this in catkin.

In order to export python libraries you need to do two things:

  • Setup a setup.py file describing which Python packages your package has.has
  • Call the catkin_python_setup() macro in your CMakeLists.txt

Reference: http://docs.ros.org/api/catkin/html/user_guide/setup_dot_py.html

The setup.py should be in the root of your package and look like this:

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

d = generate_distutils_setup(
    packages=['mypkg'],
    scripts=['bin/myscript'],
    package_dir={'': 'src'}
)

setup(**d)

Where...

    packages=['mypkg'],

'mypkg' is the name of the python package you want, in your case probably 'hrl_lib', and...

    package_dir={'': 'src'}

'src' is the folder in your package where you keep these packages, so your folder structure would be:

/path/to/my/package
                   /setup.py
                   /src
                       /hrl_lib
                               /__init__.py
                               ...

And in your CMakeLists.txt you need to call before catkin_package(...):

catkin_python_setup()

Also, get rid of these lines:

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

This was someting that rosbuild had you do, but you shouldn't do this in catkin.

In order to export python libraries you need to do two things:

  • Setup a setup.py file describing which Python packages your package has
  • Call the catkin_python_setup() macro in your CMakeLists.txt

Reference: http://docs.ros.org/api/catkin/html/user_guide/setup_dot_py.html

The setup.py should be in the root of your package and look like this:

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

d = generate_distutils_setup(
    packages=['mypkg'],
    package_dir={'': 'src'}
)

setup(**d)

Where...

    packages=['mypkg'],

'mypkg' is the name of the python package you want, in your case probably 'hrl_lib', and...

    package_dir={'': 'src'}

'src' is the folder in your package where you keep these packages, so your folder structure would be:

/path/to/my/package
                   /setup.py
                   /src
                       /hrl_lib
                               /__init__.py
                               ...

And in your CMakeLists.txt you need to call before catkin_package(...):

catkin_python_setup()

Also, get rid of these lines:

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

This was someting that rosbuild had you do, but you shouldn't do this in catkin.

EDIT:

I would expect your setup.py to look like this:

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

d = generate_distutils_setup(
    packages=['hrl_hokuyo', 'hrl_lib'],
    package_dir={'': 'src'}
)

setup(**d)