zeromq / pyzmq

PyZMQ: Python bindings for zeromq
http://zguide.zeromq.org/py:all
BSD 3-Clause "New" or "Revised" License
3.65k stars 637 forks source link

BUG: Missing zmq.NOTIFY_CONNECT and zmq.NOTIFY_DISCONNECT constants #1909

Closed Andrey36652 closed 6 months ago

Andrey36652 commented 9 months ago

What pyzmq version?

25.1.1

What libzmq version?

4.3.4 (bundled with pyzmq)

Python version (and how it was installed)

3.11.4

OS

Windows 10

What happened?

Constants zmq.NOTIFY_CONNECT and zmq.NOTIFY_DISCONNECT are missing in pyzmq. I know, option ZMQ_ROUTER_NOTIFY is still marked as Draft in docs https://zeromq.readthedocs.io/en/latest/zmq_setsockopt.html but zmq.DRAFT_API == True and I'm actually able to use zmq.ROUTER_NOTIFY feature, given I provide correct value

socket = ctx.socket(zmq.ROUTER)
socket.setsockopt(zmq.ROUTER_NOTIFY, 1) # ZMQ_NOTIFY_CONNECT = 1

it works as described in documentation.

And question: why zmq.DRAFT_API == True in bundled libzmq though there is directly opposite info here https://pyzmq.readthedocs.io/en/latest/howto/draft.html

Because these APIs are explicitly unstable, pyzmq does not support them by default, and pyzmq binaries (wheels) will not be built with DRAFT API support.

Code to reproduce bug

No response

Traceback, if applicable

No response

More info

No response

minrk commented 9 months ago

How did you install pyzmq with bundled libzmq? Was it from a PyPI wheel, or compiled from source? The PyPI wheels do not have zmq.DRAFT_API==True.

minrk commented 9 months ago

Windows 10

Ah, just noticed that you're on Windows. Windows releases use the official libzmq binaries, which appear to enable drafts by default (this will stop being the case with the next pyzmq release, since libzmq has stopped publishing releases for Windows).

Andrey36652 commented 9 months ago

Will Windows folks need to start building from source?

minrk commented 9 months ago

No, I'll never make a release without wheels for Windows. But since my previous strategy for building Windows wheels won't work anymore, I need to figure out a new one before I can release pyzmq 26.

The simplest solution is to go back to using the bundled libzmq-as-extension, which I used in the past for Windows. And I would probably do this, too, were it not for the fact that libzmq 4.3.5 ripped out tweetnacl, so Windows users would lose CURVE by default, which I don't want to happen, since it's a breaking change with no easy workaround for packages which can currently pretty safely assume that pyzmq is linked to a libzmq with CURVE support.

Currently, my choice appears to be between:

  1. add libsodium to the build-from-source bundle, which adds potentially substantial complications to installation, or
  2. add building/installing libsodium/libzmq to Windows wheels, which I will almost certainly get wrong on my first try, and will still leave any users building libzmq as an Extension (i.e. installing pyzmq from source without libzmq already present on the system - a shrinking but nonzero population) without CURVE, making it harder for any package to rely on pyzmq with CURVE enabled.

I don't like either option and don't have time right now to pursue either one since it takes me forever to debug Windows builds since I don't have access to Windows except via very slow CI, so it will probably be a while before there's another pyzmq release.

Andrey36652 commented 9 months ago

By the way why did libzmq stop publishing releases for Windows?

Andrey36652 commented 9 months ago

since I don't have access to Windows except via very slow CI

Is it possible to install Windows on VM running on Linux?