Fast-DDS-python icon indicating copy to clipboard operation
Fast-DDS-python copied to clipboard

FastDDS Python generates .dylib files instead of .so files on MacOS

Open KeaneWong opened this issue 10 months ago • 2 comments

Summary: Installing FastDDS-python using the instructions in the README works fine (just installing with brew instead of apt) except that the generated library file comes in the form of .dylib instead of .so, which python does not recognize.

Reproducing:

  1. Follow README instructions using brew to install dependencies
  2. Export fastdds_python_ws/install/fastdds_python/lib/python3.12/site-packages to PYTHONPATH
  3. Attempt to import fastdds in any python process

Expected Behavior: The library works like it does on Ubuntu distributions

Actual Behavior Importing causes the following issue:

ImportError: cannot import name '_fastdds_python' from partially initialized module 'fastdds' (most likely due to a circular import)

Changing the .dylib file to a .so file causes it to work properly. From what I understand, this would normally be fixed by passing sudo colcon build --cmake-args " -DCMAKE_SHARED_LIBRARY_SUFFIX=.so"

But this does not work. Instead, the only thing that works is by setting the suffix variable inside fastdds_python_ws/src/fastdds_python/fastdds_python/CMakeLists.txt

I did this by addingset(CMAKE_SHARED_LIBRARY_SUFFIX .so) on line 28, right after project(fastdds_python VERSION 2.2.0).

For some reason, the cache variable is being overwritten by something around project(fastdds_python VERSION 2.2.0).

Proposal Would it be possible to add the line set(CMAKE_SHARED_LIBRARY_SUFFIX .so) to the fastdds_python CMakeLists? Or otherwise see what is causing the variable to overwrite? In my own investigating I can't seem to pin down the reason.

KeaneWong avatar Feb 19 '25 22:02 KeaneWong

Hi @KeaneWong, if modifying the CMakeLists file works, please feel free to open a PR and we will review it.

Carlosespicur avatar Feb 20 '25 09:02 Carlosespicur

Hi @KeaneWong, if modifying the CMakeLists file works, please feel free to open a PR and we will review it.

Will do. Will say thatt this fix feels a little patch-y, I'll make the change but by all means if there's a better approach I can take let me know. Thank you

KeaneWong avatar Feb 20 '25 19:02 KeaneWong