broker
broker copied to clipboard
Python User Experience (make a PyPI package for bindings)
The easiest way I could figure out to get python bindings up and running (I didn't even figure it out, thanks Justin!) was to install Bro and set my PYTHONPATH to /usr/local/bro/lib/broctl.
Is there a better way to install the bindings that I just failed to realize?
It would be immensely convenient to have something like a pypi package, so that broker bindings could be installed in a virtualenv.
I don't know if it's better for you, but there's a --python-prefix configuration option for broker that could be used to stick the binding on path that's picked up on the default search path. E.g. manually installing within a virtualenv:
$ virtualenv -p python3 /Users/jon/sandbox/broker/venv
$ . /Users/jon/sandbox/broker/venv/bin/activate
$ ./configure --prefix=/Users/jon/sandbox/broker --python-prefix=$(python -c 'import sys; print(sys.exec_prefix)')
$ make install
$ python -c 'import broker; print(broker.__file__)'
/Users/jon/sandbox/broker/venv/lib/python3.7/site-packages/broker/__init__.py
This works for me. Is there a way that I can contribute to the documentation that is posted on readthedocs so that (hopefully) this doesn't come up again? I've seen a couple other people have problems getting python bindings working in irc.
Anyone else reading this should be aware that @jsiwek's solution does work, but you need to have the python headers for the version of python that you are developing for. This might seem obvious, but lots of distributions are still shipping 2.7 as the default python and their python-dev package will leave you without python3's header files.
Yeah a PR for doc improvements is welcome if you want to go ahead and add sections/notes wherever would have helped you. Probably doc/python.rst in the source tree was where you would have expected this kind of info.
I've submitted #25 to address this.
Thanks, I merged the doc improvements. I also like the idea of trying to make a PyPI package or just installing from local source tree via pip, so leaving this open in case that can ever be done.
It looks like pybind has an example for building with pip... I'll take a look and see if I can come up with a PR.