Commit 6fd511ad authored by SVN-Git Migration's avatar SVN-Git Migration

Imported Upstream version 14.4.0

parent 22bd36a6
*.pyc
zmq/*/*.c
zmq/*/*/*.c
zmq/backend/cython/*.c
zmq/devices/*.c
zmq/utils/*.json
__pycache__
build
......
Brian E. Granger <ellisonbg@gmail.com> Brian Granger <ellisonbg@gmail.com>
Chris Laws <clawsicus@gmail.com> Chris Laws <claws@localhost>
Daniel Lundin <dln@eintr.org> Daniel Lundin <dln@spotify.com>
Min Ragan-Kelley <benjaminrk@gmail.com> Min RK <benjaminrk@gmail.com>
Min Ragan-Kelley <benjaminrk@gmail.com> MinRK <benjaminrk@gmail.com>
......@@ -6,3 +7,4 @@ Michel Pelletier <pelletier.michel@gmail.com> Michel Pelletier <pelletier.michel
Nicholas Piël <nicholas@nichol.as> nicholas <nicholas@bastet.ss.sitesupport.com>
Felipe Cruz <felipecruz@loogica.net> felipecruz <felipecruz@loogica.net>
Felipe Cruz <felipecruz@loogica.net> Felipe cruz <felipecruz@loogica.net>
Yannick Hold <yannickhold@gmail.com> Yannick Hold <x_godsoul@hotmail.com>
\ No newline at end of file
......@@ -9,12 +9,14 @@ The following people have contributed to the project:
- Alexander Else (alexander DOT else AT team DOT telstra DOT com)
- Alexander Pyhalov (apyhalov AT gmail DOT com)
- Alexandr Emelin (frvzmb AT gmail DOT com)
- Amr Ali (amr AT ledgerx DOT com)
- Andre Caron (andre DOT l DOT caron AT gmail DOT com)
- Andrea Crotti (andrea DOT crotti DOT 0 AT gmail DOT com)
- Andrew Gwozdziewycz (git AT apgwoz DOT com)
- Baptiste Lepilleur (baptiste DOT lepilleur AT gmail DOT com)
- Brandyn A. White (bwhite AT dappervision DOT com)
- Brian E. Granger (ellisonbg AT gmail DOT com)
- Brian Hoffman (hoffman_brian AT bah DOT com)
- Carlos A. Rocha (carlos DOT rocha AT gmail DOT com)
- Chris Laws (clawsicus AT gmail DOT com)
- Christian Wyglendowski (christian AT bu DOT mp)
......@@ -34,11 +36,14 @@ The following people have contributed to the project:
- Felipe Cruz (felipecruz AT loogica DOT net)
- Fernando Perez (Fernando DOT Perez AT berkeley DOT edu)
- Frank Wiles (frank AT revsys DOT com)
- Félix-Antoine Fortin (felix DOT antoine DOT fortin AT gmail DOT com)
- Gavrie Philipson (gavriep AT il DOT ibm DOT com)
- Godefroid Chapelle (gotcha AT bubblenet DOT be)
- Greg Banks (gbanks AT mybasis DOT com)
- Greg Ward (greg AT gerg DOT ca)
- Guido Goldstein (github AT a-nugget DOT de)
- Ian Lee (IanLee1521 AT gmail DOT com)
- Ionuț Arțăriși (ionut AT artarisi DOT eu)
- Ivo Danihelka (ivo AT danihelka DOT net)
- Iyed (iyed DOT bennour AT gmail DOT com)
- Jim Garrison (jim AT garrison DOT cc)
......@@ -70,11 +75,13 @@ The following people have contributed to the project:
- Stefan Friesel (sf AT cloudcontrol DOT de)
- Stefan van der Walt (stefan AT sun DOT ac DOT za)
- Stephen Diehl (stephen DOT m DOT diehl AT gmail DOT com)
- Sylvain Corlay (scorlay AT bloomberg DOT net)
- Thomas Kluyver (takowl AT gmail DOT com)
- Thomas Spura (tomspur AT fedoraproject DOT org)
- Tigger Bear (Tigger AT Tiggers-Mac-mini DOT local)
- Torsten Landschoff (torsten DOT landschoff AT dynamore DOT de)
- Vadim Markovtsev (v DOT markovtsev AT samsung DOT com)
- Yannick Hold (yannickhold AT gmail DOT com)
- Zbigniew Jędrzejewski-Szmek (zbyszek AT in DOT waw DOT pl)
- hugo shi (hugoshi AT bleb2 DOT (none))
- jdgleeson (jdgleeson AT mac DOT com)
......
......@@ -57,7 +57,15 @@ or
but compiling from source with `pip install pyzmq` should work in most environments.
When compiling pyzmq (e.g. installing with pip on Linux),
it is generally recommended that zeromq be installed separately, via homebrew, apt, yum, etc.
it is generally recommended that zeromq be installed separately,
via homebrew, apt, yum, etc:
# Debian-based
sudo apt-get install libzmq3-dev
# RHEL-based
sudo yum install libzmq3-devel
If this is not available, pyzmq will *try* to build libzmq as a Python Extension,
though this is not guaranteed to work.
......
......@@ -8,3 +8,4 @@ from .config import *
from .detect import *
from .bundle import *
from .misc import *
from .patch import *
\ No newline at end of file
......@@ -32,11 +32,11 @@ pjoin = os.path.join
# Constants
#-----------------------------------------------------------------------------
bundled_version = (4,0,4)
bundled_version = (4,0,5)
libzmq = "zeromq-%i.%i.%i.tar.gz" % (bundled_version)
libzmq_url = "http://download.zeromq.org/" + libzmq
libsodium_version = (0,4,5)
libsodium_version = (1,0,0)
libsodium = "libsodium-%i.%i.%i.tar.gz" % (libsodium_version)
libsodium_url = "https://github.com/jedisct1/libsodium/releases/download/%i.%i.%i/" % libsodium_version + libsodium
......
......@@ -26,7 +26,7 @@ sys.path.insert(0, pjoin(root, 'zmq', 'utils'))
from constant_names import all_names, no_prefix
ifndef_t = """#ifndef {0}
#define {0} (-1)
#define {0} (_PYZMQ_UNDEFINED)
#endif
"""
......@@ -43,7 +43,7 @@ def cython_enums():
def ifndefs():
"""generate `#ifndef ZMQ_CONST` block for zmq_constants.h"""
lines = []
lines = ['#define _PYZMQ_UNDEFINED (-9999)']
for name in all_names:
if not no_prefix(name):
name = 'ZMQ_%s' % name
......
......@@ -17,10 +17,10 @@ import os
import logging
import platform
from distutils import ccompiler
from distutils.sysconfig import customize_compiler
from subprocess import Popen, PIPE
from .misc import customize_mingw
from .misc import get_compiler, get_output_error
from .patch import patch_lib_paths
pjoin = os.path.join
......@@ -30,16 +30,7 @@ pjoin = os.path.join
def test_compilation(cfile, compiler=None, **compiler_attrs):
"""Test simple compilation with given settings"""
if compiler is None or isinstance(compiler, str):
cc = ccompiler.new_compiler(compiler=compiler)
customize_compiler(cc)
if cc.compiler_type == 'mingw32':
customize_mingw(cc)
else:
cc = compiler
for name, val in compiler_attrs.items():
setattr(cc, name, val)
cc = get_compiler(compiler, **compiler_attrs)
efile, ext = os.path.splitext(cfile)
......@@ -63,7 +54,7 @@ def test_compilation(cfile, compiler=None, **compiler_attrs):
lpreargs = ['-m64']
extra = compiler_attrs.get('extra_compile_args', None)
objs = cc.compile([cfile],extra_preargs=cpreargs, extra_postargs=extra)
objs = cc.compile([cfile], extra_preargs=cpreargs, extra_postargs=extra)
cc.link_executable(objs, efile, extra_preargs=lpreargs)
return efile
......@@ -73,7 +64,9 @@ def compile_and_run(basedir, src, compiler=None, **compiler_attrs):
cfile = pjoin(basedir, os.path.basename(src))
shutil.copy(src, cfile)
try:
efile = test_compilation(cfile, compiler=compiler, **compiler_attrs)
cc = get_compiler(compiler, **compiler_attrs)
efile = test_compilation(cfile, compiler=cc)
patch_lib_paths(efile, cc.library_dirs)
result = Popen(efile, stdout=PIPE, stderr=PIPE)
so, se = result.communicate()
# for py3k:
......@@ -121,15 +114,13 @@ def detect_zmq(basedir, compiler=None, **compiler_attrs):
cc.output_dir = basedir
if not cc.has_function('timer_create'):
compiler_attrs['libraries'].append('rt')
efile = test_compilation(cfile, compiler=compiler, **compiler_attrs)
result = Popen(efile, stdout=PIPE, stderr=PIPE)
so, se = result.communicate()
# for py3k:
so = so.decode()
se = se.decode()
if result.returncode:
cc = get_compiler(compiler=compiler, **compiler_attrs)
efile = test_compilation(cfile, compiler=cc)
patch_lib_paths(efile, cc.library_dirs)
rc, so, se = get_output_error([efile])
if rc:
msg = "Error running version detection script:\n%s\n%s" % (so,se)
logging.error(msg)
raise IOError(msg)
......
"""misc build utility functions"""
# Copyright (C) PyZMQ Developers
# Copyright (c) PyZMQ Developers
# Distributed under the terms of the Modified BSD License.
import os
import sys
import logging
from distutils import ccompiler
from distutils.sysconfig import customize_compiler
from pipes import quote
from subprocess import Popen, PIPE
pjoin = os.path.join
if sys.version_info[0] >= 3:
u = lambda x: x
else:
u = lambda x: x.decode('utf8', 'replace')
def customize_mingw(cc):
# strip -mno-cygwin from mingw32 (Python Issue #12641)
for cmd in [cc.compiler, cc.compiler_cxx, cc.compiler_so, cc.linker_exe, cc.linker_so]:
......@@ -12,4 +30,36 @@ def customize_mingw(cc):
if 'msvcr90' in cc.dll_libraries:
cc.dll_libraries.remove('msvcr90')
__all__ = ['customize_mingw']
def get_compiler(compiler, **compiler_attrs):
"""get and customize a compiler"""
if compiler is None or isinstance(compiler, str):
cc = ccompiler.new_compiler(compiler=compiler)
customize_compiler(cc)
if cc.compiler_type == 'mingw32':
customize_mingw(cc)
else:
cc = compiler
for name, val in compiler_attrs.items():
setattr(cc, name, val)
return cc
def get_output_error(cmd):
"""Return the exit status, stdout, stderr of a command"""
if not isinstance(cmd, list):
cmd = [cmd]
logging.debug("Running: %s", ' '.join(map(quote, cmd)))
try:
result = Popen(cmd, stdout=PIPE, stderr=PIPE)
except IOError as e:
return -1, u(''), u('Failed to run %r: %r' % (cmd, e))
so, se = result.communicate()
# unicode:
so = so.decode('utf8', 'replace')
se = se.decode('utf8', 'replace')
return result.returncode, so, se
"""logging"""
#-----------------------------------------------------------------------------
# Copyright (C) PyZMQ Developers
#
# This file is part of pyzmq, copied and adapted from h5py.
# h5py source used under the New BSD license
#
# h5py: <http://code.google.com/p/h5py/>
#
# Distributed under the terms of the New BSD License. The full license is in
# the file COPYING.BSD, distributed as part of this software.
#-----------------------------------------------------------------------------
# Copyright (c) PyZMQ Developers.
# Distributed under the terms of the Modified BSD License.
from __future__ import division
import os
import sys
import logging
......@@ -22,7 +15,10 @@ import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
if os.environ.get('DEBUG'):
logger.setLevel(logging.DEBUG)
else:
logger.setLevel(logging.INFO)
logger.addHandler(logging.StreamHandler(sys.stderr))
def debug(msg):
......
"""utils for patching libraries"""
# Copyright (c) PyZMQ Developers.
# Distributed under the terms of the Modified BSD License.
import re
import sys
import os
import logging
from .misc import get_output_error
pjoin = os.path.join
# LIB_PAT from delocate
LIB_PAT = re.compile(r"\s*(.*) \(compatibility version (\d+\.\d+\.\d+), "
r"current version (\d+\.\d+\.\d+)\)")
def _get_libs(fname):
rc, so, se = get_output_error(['otool', '-L', fname])
if rc:
logging.error("otool -L %s failed: %r" % (fname, se))
return
for line in so.splitlines()[1:]:
m = LIB_PAT.match(line)
if m:
yield m.group(1)
def _find_library(lib, path):
"""Find a library"""
for d in path[::-1]:
real_lib = os.path.join(d, lib)
if os.path.exists(real_lib):
return real_lib
def _install_name_change(fname, lib, real_lib):
rc, so, se = get_output_error(['install_name_tool', '-change', lib, real_lib, fname])
if rc:
logging.error("Couldn't update load path: %s", se)
def patch_lib_paths(fname, library_dirs):
"""Load any weakly-defined libraries from their real location
(only on OS X)
- Find libraries with `otool -L`
- Update with `install_name_tool -change`
"""
if sys.platform != 'darwin':
return
libs = _get_libs(fname)
for lib in libs:
if not lib.startswith(('@', '/')):
real_lib = _find_library(lib, library_dirs)
if real_lib:
_install_name_change(fname, lib, real_lib)
__all__ = ['patch_lib_paths']
\ No newline at end of file
......@@ -22,4 +22,5 @@
generated/zmq.utils.jsonapi
generated/zmq.utils.monitor
generated/zmq.utils.z85
zmq.utils.win32
......@@ -131,6 +131,8 @@ Functions
.. autofunction:: zmq.pyzmq_version_info
.. autofunction:: zmq.has
.. autofunction:: zmq.device
.. autofunction:: zmq.proxy
......
utils.win32
===========
Module: :mod:`zmq.utils.win32`
------------------------------
.. automodule:: zmq.utils.win32
.. currentmodule:: zmq.utils.win32
:class:`allow_interrupt`
------------------------
.. autoclass:: allow_interrupt
......@@ -9,6 +9,24 @@ Changes in PyZMQ
This is a coarse summary of changes in pyzmq versions. For a real changelog, consult the
`git log <https://github.com/zeromq/pyzmq/commits>`_
14.4.0
======
New features:
- Experimental support for libzmq-4.1.0 rc (new constants, plus :func:`zmq.has`).
- Update bundled libzmq to 4.0.5
- Update bundled libsodium to 1.0.0
- Fixes for SSH dialogs when using :mod:`zmq.ssh` to create tunnels
- More build/link/load fixes on OS X and Solaris
- Get Frame metadata via dict access (libzmq 4)
- Contexts and Sockets are context managers (term/close on ``__exit__``)
- Add :class:`zmq.utils.win32.allow_interrupt` context manager for catching SIGINT on Windows
Bugs fixed:
- Bundled libzmq should not trigger recompilation after install on PyPy
14.3.1
======
......
......@@ -17,11 +17,11 @@ NOTE: this is a modified version of a script originally shipped with the
PyMVPA project, which we've adapted for NIPY use. PyMVPA is an MIT-licensed
project."""
# Stdlib imports
from __future__ import print_function
import os
import re
# Functions and classes
class ApiDocWriter(object):
''' Class for automatic detection and parsing of API docs
to Sphinx-parsable reST format'''
......@@ -220,7 +220,7 @@ class ApiDocWriter(object):
# get the names of all classes and functions
functions, classes = self._parse_module(uri)
if not len(functions) and not len(classes):
print 'WARNING: Empty -',uri # dbg
print('WARNING: Empty -', uri)
return ''
# Make a shorter version of the uri that omits the package name for
......
"""
========
numpydoc
========
Sphinx extension that handles docstrings in the Numpy standard format. [1]
It will:
- Convert Parameters etc. sections to field lists.
- Convert See Also section to a See also entry.
- Renumber references.
- Extract the signature from the docstring, if it can't be determined otherwise.
.. [1] http://projects.scipy.org/scipy/numpy/wiki/CodingStyleGuidelines#docstring-standard
"""
import os, re, pydoc
from docscrape_sphinx import get_doc_object, SphinxDocString
import inspect
def mangle_docstrings(app, what, name, obj, options, lines,
reference_offset=[0]):
if what == 'module':
# Strip top title
title_re = re.compile(r'^\s*[#*=]{4,}\n[a-z0-9 -]+\n[#*=]{4,}\s*',
re.I|re.S)
lines[:] = title_re.sub('', "\n".join(lines)).split("\n")
else:
doc = get_doc_object(obj, what, "\n".join(lines))
lines[:] = unicode(doc).split("\n")
if app.config.numpydoc_edit_link and hasattr(obj, '__name__') and \
obj.__name__:
if hasattr(obj, '__module__'):
v = dict(full_name="%s.%s" % (obj.__module__, obj.__name__))
else:
v = dict(full_name=obj.__name__)
lines += ['', '.. htmlonly::', '']
lines += [' %s' % x for x in
(app.config.numpydoc_edit_link % v).split("\n")]
# replace reference numbers so that there are no duplicates
references = []
for l in lines:
l = l.strip()
if l.startswith('.. ['):
try:
references.append(int(l[len('.. ['):l.index(']')]))
except ValueError:
print "WARNING: invalid reference in %s docstring" % name
# Start renaming from the biggest number, otherwise we may
# overwrite references.
references.sort()
if references:
for i, line in enumerate(lines):
for r in references:
new_r = reference_offset[0] + r
lines[i] = lines[i].replace('[%d]_' % r,
'[%d]_' % new_r)
lines[i] = lines[i].replace('.. [%d]' % r,
'.. [%d]' % new_r)
reference_offset[0] += len(references)
def mangle_signature(app, what, name, obj, options, sig, retann):
# Do not try to inspect classes that don't define `__init__`
if (inspect.isclass(obj) and
'initializes x; see ' in pydoc.getdoc(obj.__init__)):
return '', ''
if not (callable(obj) or hasattr(obj, '__argspec_is_invalid_')): return
if not hasattr(obj, '__doc__'): return
doc = SphinxDocString(pydoc.getdoc(obj))
if doc['Signature']:
sig = re.sub("^[^(]*", "", doc['Signature'])
return sig, ''
def initialize(app):
try:
app.connect('autodoc-process-signature', mangle_signature)
except:
monkeypatch_sphinx_ext_autodoc()
def setup(app, get_doc_object_=get_doc_object):
global get_doc_object
get_doc_object = get_doc_object_
app.connect('autodoc-process-docstring', mangle_docstrings)
app.connect('builder-inited', initialize)
app.add_config_value('numpydoc_edit_link', None, True)
#------------------------------------------------------------------------------
# Monkeypatch sphinx.ext.autodoc to accept argspecless autodocs (Sphinx < 0.5)
#------------------------------------------------------------------------------
def monkeypatch_sphinx_ext_autodoc():
global _original_format_signature
import sphinx.ext.autodoc
if sphinx.ext.autodoc.format_signature is our_format_signature:
return
print "[numpydoc] Monkeypatching sphinx.ext.autodoc ..."
_original_format_signature = sphinx.ext.autodoc.format_signature
sphinx.ext.autodoc.format_signature = our_format_signature
def our_format_signature(what, obj):
r = mangle_signature(None, what, None, obj, None, None, None)
if r is not None:
return r[0]
else:
return _original_format_signature(what, obj)
......@@ -8,7 +8,9 @@ Authors
-------
* MinRK
"""
from __future__ import print_function
import sys
import time
import numpy
import zmq
......@@ -25,10 +27,9 @@ while True:
time.sleep(numpy.random.random())
for i in range(4):
n+=1
msg = 'ping %i'%n
msg = 'ping %i' % n
tic = time.time()
req.send(msg)
resp = req.recv()
print "%s: %.2f ms" % (msg, 1000*(time.time()-tic))
req.send_string(msg)
resp = req.recv_string()
print("%s: %.2f ms" % (msg, 1000*(time.time()-tic)))
assert msg == resp
......@@ -9,6 +9,7 @@ Authors
-------
* MinRK
"""
from __future__ import print_function
import time
import numpy
......@@ -19,16 +20,15 @@ ctx = zmq.Context()
dev = devices.ThreadDevice(zmq.FORWARDER, zmq.REP, -1)
dev.bind_in('tcp://127.0.0.1:10111')
dev.setsockopt_in(zmq.IDENTITY, "whoda")
dev.setsockopt_in(zmq.IDENTITY, b"whoda")
dev.start()
#wait for connections
time.sleep(1)
A = numpy.random.random((2**11,2**12))
print "starting blocking loop"
print("starting blocking loop")
while True:
tic = time.time()
numpy.dot(A,A.transpose())
print "blocked for %.3f s"%(time.time()-tic)
print("blocked for %.3f s"%(time.time()-tic))
......@@ -10,37 +10,39 @@ from __future__ import print_function
__author__ = 'Guido Goldstein'
import json
import os
import struct
import sys
import threading
import time
import zmq
from zmq.utils.monitor import recv_monitor_message
line = lambda : print('-' * 40)
def logger(monitor):
done = False
while monitor.poll(timeout=5000):
evt = recv_monitor_message(monitor)
print(json.dumps(evt, indent=1))
if evt['event'] == zmq.EVENT_MONITOR_STOPPED:
break
print()
print("Logger done!")
monitor.close()
line = lambda: print('-' * 40)
print("libzmq-%s" % zmq.zmq_version())
if zmq.zmq_version_info() < (4,0):
if zmq.zmq_version_info() < (4, 0):
raise RuntimeError("monitoring in libzmq version < 4.0 is not supported")
EVENT_MAP = {}
print("Event names:")
for name in dir(zmq):
if name.startswith('EVENT_'):
print("%21s : %4i" % (name, getattr(zmq, name)))
value = getattr(zmq, name)
print("%21s : %4i" % (name, value))
EVENT_MAP[value] = name
def event_monitor(monitor):
while monitor.poll():
evt = recv_monitor_message(monitor)
evt.update({'description': EVENT_MAP[evt['event']]})
print("Event: {}".format(evt))
if evt['event'] == zmq.EVENT_MONITOR_STOPPED:
break
monitor.close()
print()
print("event monitor thread done!")
ctx = zmq.Context().instance()
......@@ -49,7 +51,7 @@ req = ctx.socket(zmq.REQ)
monitor = req.get_monitor_socket()
t = threading.Thread(target=logger, args=(monitor,))
t = threading.Thread(target=event_monitor, args=(monitor,))
t.start()
line()
......@@ -78,13 +80,33 @@ rep.close()
time.sleep(1)
line()
print("close req")
req.close()
time.sleep(1)
print("disabling event monitor")
req.disable_monitor()
line()
print("event monitor thread should now terminate")
# Create a new socket to connect to listener, no more
# events should be observed.
rep = ctx.socket(zmq.REP)
line()
print("connect rep")
rep.connect("tcp://127.0.0.1:6667")
time.sleep(0.2)
line()
print("disconnect rep")
rep.disconnect("tcp://127.0.0.1:6667")
time.sleep(0.2)
line()
print("joining")
t.join()
print("close rep")
rep.close()
line()
print("close req")
req.close()
print("END")
ctx.term()
......@@ -80,7 +80,9 @@ def run():
public_keys_dir = os.path.join(base_dir, 'public_keys')
secret_keys_dir = os.path.join(base_dir, 'private_keys')
if not (os.path.exists(keys_dir) and os.path.exists(keys_dir) and os.path.exists(keys_dir)):
if not (os.path.exists(keys_dir) and
os.path.exists(public_keys_dir) and
os.path.exists(secret_keys_dir)):
logging.critical("Certificates are missing - run generate_certificates script first")
sys.exit(1)