7676from cython .cimports .libc .stdio import stderr as cstderr
7777from cython .cimports .libc .stdlib import free , malloc
7878from cython .cimports .libc .string import memcpy
79+ from cython .cimports .zmq .backend .cython import libzmq
7980from cython .cimports .zmq .backend .cython ._externs import (
8081 get_ipc_path_max_len ,
8182 getpid ,
163164
164165IPC_PATH_MAX_LEN : int = get_ipc_path_max_len ()
165166
167+ PYZMQ_DRAFT_API : bool = bool (libzmq .PYZMQ_DRAFT_API )
168+
166169
167170@cfunc
168171@inline
@@ -929,8 +932,10 @@ def get(self, option: C.int):
929932 _check_version (
930933 (4 , 3 , 2 ), "draft socket FD support via zmq_poller_fd"
931934 )
932- if not zmq .has ('draft' ):
933- raise RuntimeError ("libzmq must be built with draft support" )
935+ if not zmq .DRAFT_API :
936+ raise RuntimeError (
937+ "libzmq and pyzmq must be built with draft support"
938+ )
934939 warnings .warn (zmq .error .DraftFDWarning (), stacklevel = 2 )
935940
936941 # create a poller and retrieve its fd
@@ -1120,8 +1125,8 @@ def join(self, group: str | bytes):
11201125 .. versionadded:: 17
11211126 """
11221127 _check_version ((4 , 2 ), "RADIO-DISH" )
1123- if not zmq .has ( 'draft' ) :
1124- raise RuntimeError ("libzmq must be built with draft support" )
1128+ if not zmq .DRAFT_API :
1129+ raise RuntimeError ("libzmq and pyzmq must be built with draft support" )
11251130 if isinstance (group , str ):
11261131 group = group .encode ('utf8' )
11271132 c_group : bytes = group
@@ -1139,8 +1144,8 @@ def leave(self, group):
11391144 .. versionadded:: 17
11401145 """
11411146 _check_version ((4 , 2 ), "RADIO-DISH" )
1142- if not zmq .has ( 'draft' ) :
1143- raise RuntimeError ("libzmq must be built with draft support" )
1147+ if not zmq .DRAFT_API :
1148+ raise RuntimeError ("libzmq and pyzmq must be built with draft support" )
11441149 rc : C .int = zmq_leave (self .handle , group )
11451150 _check_rc (rc )
11461151
@@ -2027,6 +2032,7 @@ def monitored_queue(
20272032
20282033__all__ = [
20292034 'IPC_PATH_MAX_LEN' ,
2035+ 'PYZMQ_DRAFT_API' ,
20302036 'Context' ,
20312037 'Socket' ,
20322038 'Frame' ,
0 commit comments