broker
broker copied to clipboard
Python bindings broken on Windows
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.
Note that building python on Windows is currently disabled for CI builds and should be re-enabled once this is fixed.
@timwoj I've seen that you've pushed some changes to the Broker bindings. Is this fixed?
I don't believe so, but I can revert https://github.com/zeek/broker/commit/e7d969226ce263d094c709c78f8886d2a4831d4f and check.
No, still broken here: https://cirrus-ci.com/task/5149945408782336
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.