Skip to content

Commit

Permalink
Merge branch 'issue-110-zmq-hook' into develop.
Browse files Browse the repository at this point in the history
This fixes pyinstaller#110: zmq hook to handle latest pyzmq version 14.0+
  • Loading branch information
htgoebel committed Jan 7, 2015
2 parents 6cf2d0f + 2eac426 commit b485d77
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions PyInstaller/hooks/hook-zmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b485d77

Please sign in to comment.