Installing a build-time generated Python module

asked 2020-07-28 14:03:03 -0500

rgov gravatar image

updated 2020-07-28 14:12:00 -0500

Related to my previous question about dynamically generated .msg files, this time I have a dynamically generated Python module. It is the output of lcm-gen or you could think of it as a module generated by protobuf or whatever else.

I invoke lcm-gen to create the Python module:

    COMMAND lcm-gen --python
            --ppath "${GENERATED_LCM_PY_DIR}"

This creates a directory structure inside my build directory somewhere, like:


Now I want to set this generated module to be installed into the PYTHONPATH by Catkin.

I've tried using catkin_python_setup and providing a file that does something like this:

setup_args = generate_distutils_setup(

This creates a dummy module generated_moduleA inside dist-packages/, but I cannot import the objects I expect to find in it.

I believe there may be a bug because my package_dir in the Python code is an absolute path, not relative to the source directory. If I patch the dummy generated_moduleA/ file's __extended_path to use the correct path, it does seem to work better.

edit retag flag offensive close merge delete