diff --git a/PyInstaller/hooks/hook-zmq.py b/PyInstaller/hooks/hook-zmq.py index bbe0259acb..87280b2341 100644 --- a/PyInstaller/hooks/hook-zmq.py +++ b/PyInstaller/hooks/hook-zmq.py @@ -12,34 +12,27 @@ Hook for PyZMQ. Cython based Python bindings for messaging library ZeroMQ. http://www.zeromq.org/ """ - - import glob import os -import sys - - -hiddenimports = [ - 'zmq.core.pysocket', - 'zmq.utils.jsonapi', - 'zmq.utils.strtypes', -] +from PyInstaller.hooks.hookutils import collect_submodules +hiddenimports = ['zmq.utils.garbage'] +hiddenimports.extend(collect_submodules('zmq.backend')) def hook(mod): - # If PyZMQ provides its own copy of libzmq, add it to the + # If PyZMQ provides its own copy of libzmq or libsodium, add it to the # extension-modules TOC so zmq/__init__.py can load it at runtime. - # For predictable behavior, the libzmq search here must be identical + # For predictable behavior, the libzmq search here must be equivalent # to the search in zmq/__init__.py. zmq_directory = os.path.dirname(mod.__file__) - for ext in ('pyd', 'so', 'dll', 'dylib'): - bundled = glob.glob(os.path.join(zmq_directory, 'libzmq*.%s*' % ext)) + for libname in ('libzmq', 'libsodium'): + bundled = glob.glob(os.path.join(zmq_directory, + libname + '*.{pyd,so,dll,dylib}*')) if bundled: # zmq/__init__.py will look in os.join(sys._MEIPASS, 'zmq'), # so libzmq has to land there. name = os.path.join('zmq', os.path.basename(bundled[0])) # TODO fix this hook to use attribute 'binaries'. mod.pyinstaller_binaries.append((name, bundled[0], 'BINARY')) - break return mod