broker icon indicating copy to clipboard operation
broker copied to clipboard

Python bindings broken on Windows

Open timwoj opened this issue 3 years ago • 5 comments

This may be something specific to Visual Studio 2019 and above, or it may not be. As part of https://github.com/zeek/broker/pull/214, we discovered that the python bindings aren't getting loaded correctly on Windows. It appears that the DLL isn't being autoloaded when import _broker is called from the __init__.py file for the broker module:

Traceback (most recent call last):
  File "C:\broker\build\python\broker\__init__.py", line 3, in <module>
    from . import _broker
ImportError: cannot import name '_broker' from partially initialized module 'broker' (most likely due to a circular import) (C:\broker\bui
ld\python\broker\__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\broker\tests\python\communication.py", line 8, in <module>
    import broker
  File "C:\broker\build\python\broker\__init__.py", line 5, in <module>
    import _broker
ModuleNotFoundError: No module named '_broker'

This works correctly on macOS and Linux where it loads a shared object. There were some changes around DLL loading in Python 3.8, but I tested it on both 3.6 and 3.10 and it doesn't work on either of them.

timwoj avatar Mar 08 '22 15:03 timwoj

Note that building python on Windows is currently disabled for CI builds and should be re-enabled once this is fixed.

timwoj avatar Mar 08 '22 16:03 timwoj

@timwoj I've seen that you've pushed some changes to the Broker bindings. Is this fixed?

Neverlord avatar Apr 16 '22 12:04 Neverlord

I don't believe so, but I can revert https://github.com/zeek/broker/commit/e7d969226ce263d094c709c78f8886d2a4831d4f and check.

timwoj avatar Apr 18 '22 20:04 timwoj

No, still broken here: https://cirrus-ci.com/task/5149945408782336

timwoj avatar Apr 18 '22 20:04 timwoj

After 5.0, we've wanted to revisit the need for Python bindings with WebSockets available (see #212). If we do end up deprecating (and later removing) the bindings, there's probably no point in fixing this.

Neverlord avatar May 26 '22 07:05 Neverlord