Skip to content

Python bindings of dependency modules are not compiled

When using ./waf configure --enable-modules=<some_module>,visualizer the Python bindings of the visualizer module dependencies are not compiled which causes the visualizer to crash with the following error: ModuleNotFoundError: No module named 'ns.core'

The issue comes from the fact that the ns3_python_bindings function in the file src/wscript skips the generation of the bindings for the modules that are not in env.NS3_ENABLED_MODULES. However, the env.NS3_ENABLED_MODULES is updated with the module dependencies only after waf has recursed over the /src directory in the build() function in the root wscript file (lines 902 to 943).

This also causes the generated python bindings to link against incomplete dependencies as can be seen from the line 263 of the file src/wscript.

To reproduce the issue, run the following waf commands:

./waf clean
./waf configure --enable-modules=applications,visualizer --enable-examples
./waf --run=main-simple --vis

The following error will be displayed:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/ns-3-allinone/ns-3-dev/src/visualizer/visualizer/__init__.py", line 2, in <module>
    from .core import start, register_plugin, set_bounds, add_initialization_hook
  File "/tmp/ns-3-allinone/ns-3-dev/src/visualizer/visualizer/core.py", line 24, in <module>
    import ns.core
ModuleNotFoundError: No module named 'ns.core'

The issue could be solved by canceling the binding compilation task with a patch similar to this one: 0001-Correct-issue-with-python-bindings-compilation.patch

Edited by Ouassim Karrakchou