Commit 7112ac0f authored by SVN-Git Migration's avatar SVN-Git Migration

Imported Upstream version 14.0.1

parent 9b9c15ce
*.pyc
zmq/*/*.c
zmq/*/*/*.c
__pycache__
build
dist
......
......@@ -9,12 +9,21 @@ python:
env:
- ZMQ=
- ZMQ=bundled
- ZMQ=master
before_install:
- sudo apt-get install -qq libzmq3-dev
- if [[ $TRAVIS_PYTHON_VERSION == 'pypy' ]]; then pip install -q --use-mirrors cffi; fi
- if [[ $TRAVIS_PYTHON_VERSION != 'pypy' ]]; then pip install -q --use-mirrors cython; fi
- if [[ $TRAVIS_PYTHON_VERSION == 'pypy' ]]; then sudo add-apt-repository -y ppa:pypy/ppa || true; fi
- if [[ $TRAVIS_PYTHON_VERSION == 'pypy' ]]; then sudo apt-get -y update && sudo apt-get -y install pypy; fi
- if [[ $TRAVIS_PYTHON_VERSION == 'pypy' ]]; then virtualenv -p /usr/bin/pypy pypy && source pypy/bin/activate; fi
- if [[ $TRAVIS_PYTHON_VERSION == 'pypy' ]]; then pip install -q --use-mirrors py cffi; fi
- if [[ $TRAVIS_PYTHON_VERSION != 'pypy' ]]; then pip install -q --use-mirrors cython --install-option='--no-cython-compile'; fi
- if [[ $ZMQ == 'master' ]]; then git clone --depth 1 https://github.com/zeromq/libzmq; fi
- if [[ $ZMQ == 'master' ]]; then sh -c 'cd libzmq; sh autogen.sh; ./configure; make -j; sudo make install; sudo ldconfig'; fi
- pip install -q --use-mirrors nose
install:
- if [[ $ZMQ == 'master' ]]; then export ZMQ=/usr/local; fi
- python setup.py build_ext --inplace --zmq=$ZMQ
matrix:
......@@ -22,6 +31,6 @@ matrix:
- python: pypy
env: ZMQ=bundled
allow_failures:
- python: pypy
- env: ZMQ=master
script: python setup.py test
......@@ -5,36 +5,34 @@ This package contains Python bindings for [ØMQ](http://www.zeromq.org).
ØMQ is a lightweight and fast messaging implementation.
PyZMQ should work with any Python ≥ 2.6 (including Python 3), as well as PyPy.
The Cython backend used by CPython supports libzmq ≥ 2.1.4 (including 3.2.x),
but the CFFI backend used by PyPy only supports libzmq ≥ 3.2.2.
The Cython backend used by CPython supports libzmq ≥ 2.1.4 (including 3.2.x and 4.x),
but the CFFI backend used by PyPy only supports libzmq ≥ 3.2.2 (including 4.x).
## Versioning
Current release of pyzmq is 13.1.0, and targets libzmq-3.2.2. For
libzmq 2.0.x, use pyzmq release 2.0.10.1 or the 2.0.x development
branch. PyZMQ (on CPython via Cython) continues to support libzmq ≥ 2.1.4.
Current release of pyzmq is 14.0.1, and targets libzmq-4.0.3.
For libzmq 2.0.x, use pyzmq release 2.0.10.1 or the 2.0.x maintenance branch.
PyZMQ (on CPython via Cython) continues to support libzmq ≥ 2.1.4.
pyzmq-2.1.11 was the last version of pyzmq to support Python 2.5, and
pyzmq ≥ 2.2.0 requires Python ≥ 2.6.
pyzmq-2.1.11 was the last version of pyzmq to support Python 2.5,
and pyzmq ≥ 2.2.0 requires Python ≥ 2.6.
pyzmq-13.0.0 introduces PyPy support via CFFI, which only supports libzmq-3.2.2 and newer.
PyZMQ releases ≤ 2.2.0 matched libzmq versioning, but this will no
longer be the case. To avoid confusion with the contemporary libzmq-3.2
major version release, PyZMQ is jumping to 13.0 (it will be the
thirteenth release, so why not?). PyZMQ ≥ 13.0 will follow semantic
versioning conventions accounting only for PyZMQ itself.
PyZMQ releases ≤ 2.2.0 matched libzmq versioning, but this is no longer the case,
starting with PyZMQ 13.0.0 (it was the thirteenth release, so why not?).
PyZMQ ≥ 13.0 follows semantic versioning conventions accounting only for PyZMQ itself.
For a summary of changes to pyzmq, see our
[changelog](http://zeromq.github.com/pyzmq/changelog.html).
### ØMQ 3.x
### ØMQ 3.x, 4.x
PyZMQ ≥ 2.2.0 fully supports the 3.x API of libzmq,
PyZMQ ≥ 2.2.0 fully supports the 3.x and 4.x APIs of libzmq,
developed at [zeromq/libzmq](https://github.com/zeromq/libzmq).
No code to change, no flags to pass,
just build pyzmq against libzmq3 and it should work.
just build pyzmq against the latest and it should work.
PyZMQ on PyPy *only* supports the 3.x API of libzmq.
PyZMQ on PyPy *only* supports libzmq >= 3.2.2.
## Documentation
......@@ -58,11 +56,17 @@ version 0.16 or later.
## Building and installation
For more detail on building pyzmq, see [our Wiki](https://github.com/zeromq/pyzmq/wiki).
For more detail on building pyzmq, see [our Wiki](https://github.com/zeromq/pyzmq/wiki/Building-and-Installing-PyZMQ).
We build eggs for OS X and Windows, so we generally recommend that those
platforms use `easy_install pyzmq`, but `pip install pyzmq` should work on
most platforms as well.
We build eggs and wheels for OS X and Windows, so you can get a binary on those platforms with either:
To build pyzmq from the git repo requires Cython.
easy_install pyzmq
or
pip install --use-wheel pyzmq
But compiling from source with `pip install pyzmq` should work in most environments.
To build pyzmq from the git repo (including release tags) requires Cython.
......@@ -37,12 +37,9 @@ pjoin = os.path.join
# Constants
#-----------------------------------------------------------------------------
bundled_version = (3,2,2)
bundled_version = (4,0,3)
libzmq = "zeromq-%i.%i.%i.tar.gz" % (bundled_version)
libzmq_url = "http://download.zeromq.org/" + libzmq
# util no longer used
util = "util-linux-2.21.tar.gz"
util_url = "http://www.kernel.org/pub/linux/utils/util-linux/v2.21/" + util
HERE = os.path.dirname(__file__)
ROOT = os.path.dirname(HERE)
......@@ -126,58 +123,6 @@ def stage_platform_hpp(zmqroot):
shutil.copy(pjoin(platform_dir, 'platform.hpp'), platform_hpp)
# fetch/patch_uuid no longer needed for libzmq >= 3
def fetch_uuid(savedir):
"""download, extract, and patch libuuid sources"""
dest = pjoin(savedir, 'uuid')
if os.path.exists(dest):
info("already have %s" % dest)
return
fname = fetch_archive(savedir, util_url, util)
tf = tarfile.open(fname)
util_name = untgz(util)
uuid_path = util_name+'/libuuid/src'
uuid = filter(
lambda m: m.name.startswith(uuid_path) and not m.name.endswith("nt.c"),
tf.getmembers()
)
# uuid_members = map(tf.getmember, uuid_names)
tf.extractall(savedir, uuid)
if os.path.exists(dest):
shutil.rmtree(dest)
shutil.move(pjoin(savedir, util_name, 'libuuid', 'src'), dest)
shutil.rmtree(pjoin(savedir, util_name))
patch_uuid(dest)
def patch_uuid(uuid_dir):
"""patch uuid.h with a few defines
from pyzmq-static
"""
info("patching gen_uuid.c")
gen_uuid = pjoin(uuid_dir, "gen_uuid.c")
with open(gen_uuid) as f:
lines = f.readlines()
if 'pyzmq-patch' in lines[0]:
info("already patched")
return
else:
lines.insert(0, "// end pyzmq-patch\n")
for h in ('UNISTD', 'STDLIB', 'SYS_FILE'):
lines.insert(0, "#define HAVE_%s_H\n" % h)
lines.insert(0, "// begin pyzmq-patch\n")
with open(gen_uuid, 'w') as f:
f.writelines(lines)
def copy_and_patch_libzmq(ZMQ, libzmq):
"""copy libzmq into source dir, and patch it if necessary.
......
"""
script for generating files that involve repetitive updates for zmq constants.
Run this after updating utils/constant_names
Currently generates the following files from templates:
- constant_enums.pxi
- constants.pxi
- zmq_constants.h
"""
#-----------------------------------------------------------------------------
# Copyright (c) 2013 Brian E. Granger & Min Ragan-Kelley
#
# This file is part of pyzmq
#
# Distributed under the terms of the New BSD License. The full license is in
# the file COPYING.BSD, distributed as part of this software.
#-----------------------------------------------------------------------------
import os
import sys
from . import info
pjoin = os.path.join
root = os.path.abspath(pjoin(os.path.dirname(__file__), os.path.pardir))
sys.path.insert(0, pjoin(root, 'zmq', 'utils'))
from constant_names import all_names, no_prefix
ifndef_t = """#ifndef {0}
#define {0} (-1)
#endif
"""
def cython_enums():
"""generate `enum: ZMQ_CONST` block for constant_enums.pxi"""
lines = []
for name in all_names:
if no_prefix(name):
lines.append('enum: ZMQ_{0} "{0}"'.format(name))
else:
lines.append('enum: ZMQ_{0}'.format(name))
return dict(ZMQ_ENUMS='\n '.join(lines))
def ifndefs():
"""generate `#ifndef ZMQ_CONST` block for zmq_constants.h"""
lines = []
for name in all_names:
if not no_prefix(name):
name = 'ZMQ_%s' % name
lines.append(ifndef_t.format(name))
return dict(ZMQ_IFNDEFS='\n'.join(lines))
def constants_pyx():
"""generate CONST = ZMQ_CONST and __all__ for constants.pxi"""
all_lines = []
assign_lines = []
for name in all_names:
if name == "NULL":
# avoid conflict with NULL in Cython
assign_lines.append("globals()['NULL'] = ZMQ_NULL")
else:
assign_lines.append('{0} = ZMQ_{0}'.format(name))
all_lines.append(' "{0}",'.format(name))
return dict(ASSIGNMENTS='\n'.join(assign_lines), ALL='\n'.join(all_lines))
def generate_file(fname, ns_func, dest_dir="."):
"""generate a constants file from its template"""
with open(pjoin(root, 'buildutils', 'templates', '%s' % fname), 'r') as f:
tpl = f.read()
out = tpl.format(**ns_func())
dest = pjoin(dest_dir, fname)
info("generating %s from template" % dest)
with open(dest, 'w') as f:
f.write(out)
def render_constants():
"""render generated constant files from templates"""
generate_file("constant_enums.pxi", cython_enums, pjoin(root, 'zmq', 'backend', 'cython'))
generate_file("constants.pxi", constants_pyx, pjoin(root, 'zmq', 'backend', 'cython'))
generate_file("zmq_constants.h", ifndefs, pjoin(root, 'zmq', 'utils'))
if __name__ == '__main__':
render_constants()
cdef extern from "zmq.h" nogil:
{ZMQ_ENUMS}
#-----------------------------------------------------------------------------
# Python module level constants
#-----------------------------------------------------------------------------
{ASSIGNMENTS}
#-----------------------------------------------------------------------------
# Symbols to export
#-----------------------------------------------------------------------------
__all__ = [
{ALL}
]
#ifndef _PYZMQ_CONSTANT_DEFS
#define _PYZMQ_CONSTANT_DEFS
{ZMQ_IFNDEFS}
#endif // ifndef _PYZMQ_CONSTANT_DEFS
......@@ -20,9 +20,8 @@ if __name__ == '__main__':
# You must do make clean if you change this!
docwriter.package_skip_patterns += [
r'\.tests$',
r'\.core$',
r'\.cffi_core$',
r'\.eventloop\.platform$',
r'\.backend$',
r'\.eventloop\.minitornado$',
r'\.green\.eventloop$',
r'\.sugar$',
r'\.devices$',
......@@ -33,8 +32,10 @@ if __name__ == '__main__':
r'\.error$',
r'\.green\..+$',
r'\.utils\.initthreads$',
r'\.utils\.constant_names$',
r'\.utils\.garbage$',
r'\.utils\.rebuffer$',
r'\.utils\.rebuffer$',
r'\.utils\.strtypes$',
]
# Now, generate the outputs
......@@ -42,4 +43,5 @@ if __name__ == '__main__':
docwriter.write_index(outdir, 'gen',
relative_to = pjoin('source','api')
)
print '%d files written' % len(docwriter.written_modules)
print('%d files written' % len(docwriter.written_modules))
......@@ -15,8 +15,8 @@
generated/zmq.eventloop.ioloop
generated/zmq.eventloop.zmqstream
generated/zmq.log.handlers
generated/zmq.ssh.forward
generated/zmq.ssh.tunnel
generated/zmq.utils.jsonapi
generated/zmq.utils.strtypes
generated/zmq.utils.monitor
generated/zmq.utils.z85
.. AUTO-GENERATED FILE -- DO NOT EDIT!
devices
=======
Functions
---------
.. autofunction:: zmq.device
.. autofunction:: zmq.proxy
Module: :mod:`zmq.devices`
--------------------------
.. automodule:: zmq.devices
.. currentmodule:: zmq.devices
Base Devices
------------
:class:`ProcessDevice`
**********************
:class:`Device`
***************
.. autoclass:: ProcessDevice
.. autoclass:: Device
:members:
:undoc-members:
:inherited-members:
:exclude-members: context_factory, run, run_device
:class:`ThreadDevice`
*********************
.. autoclass:: ThreadDevice
:members:
:undoc-members:
:inherited-members:
Proxy Devices
-------------
:class:`ProcessDevice`
**********************
.. autoclass:: ProcessDevice
:members:
:class:`ProcessProxy`
*********************
Proxy Devices
-------------
.. autoclass:: ProcessProxy
:members:
:undoc-members:
:inherited-members:
:class:`Proxy`
********************
.. autoclass:: Proxy
:members: bind_mon, connect_mon, setsockopt_mon
:class:`ThreadProxy`
********************
.. autoclass:: ThreadProxy
:members:
:undoc-members:
:inherited-members:
:class:`ProcessProxy`
*********************
.. autoclass:: ProcessProxy
:members:
MonitoredQueue Devices
......@@ -60,24 +65,22 @@ MonitoredQueue Devices
.. autofunction:: zmq.devices.monitored_queue
:class:`MonitoredQueue`
*****************************
:class:`ProcessMonitoredQueue`
******************************
.. autoclass:: ProcessMonitoredQueue
.. autoclass:: MonitoredQueue
:members:
:undoc-members:
:inherited-members:
:class:`ThreadMonitoredQueue`
*****************************
.. autoclass:: ThreadMonitoredQueue
:members:
:undoc-members:
:inherited-members:
:class:`ProcessMonitoredQueue`
******************************
.. autoclass:: ProcessMonitoredQueue
:members:
......@@ -16,6 +16,12 @@ Basic Classes
:members:
:undoc-members:
:inherited-members:
:exclude-members: sockopts, closed
.. attribute:: closed
boolean - whether the context has been terminated.
If True, you can no longer use this Context.
:class:`Socket`
......@@ -26,6 +32,13 @@ Basic Classes
:members:
:undoc-members:
:inherited-members:
:exclude-members: closed, context, getsockopt_unicode, recv_unicode, setsockopt_unicode, send_unicode
.. attribute:: closed
boolean - whether the socket has been closed.
If True, you can no longer use this Socket.
:class:`Frame`
......@@ -34,7 +47,6 @@ Basic Classes
.. autoclass:: Frame
:members:
:undoc-members:
:inherited-members:
......@@ -44,7 +56,6 @@ Basic Classes
.. autoclass:: MessageTracker
:members:
:undoc-members:
:inherited-members:
......@@ -56,7 +67,6 @@ Polling
.. autoclass:: Poller
:members:
:undoc-members:
:inherited-members:
......@@ -71,7 +81,6 @@ Exceptions
.. autoclass:: ZMQError
:members:
:undoc-members:
:inherited-members:
......@@ -101,7 +110,6 @@ Exceptions
.. autoclass:: ZMQBindError
:members:
......@@ -116,4 +124,10 @@ Functions
.. autofunction:: zmq.pyzmq_version_info
.. autofunction:: zmq.device
.. autofunction:: zmq.proxy
.. autofunction:: zmq.curve_keypair
.. autofunction:: zmq.get_includes
\ No newline at end of file
......@@ -9,6 +9,41 @@ 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.0.1
======
Bugfix release
- Update bundled libzmq to current (4.0.3).
- Fix bug in :meth:`.Context.destroy` with no open sockets.
- Threadsafety fixes in the garbage collector.
- Python 3 fixes in :mod:`zmq.ssh`.
14.0.0
======
* Update bundled libzmq to current (4.0.1).
* Backends are now implemented in ``zmq.backend`` instead of ``zmq.core``.
This has no effect on public APIs.
* Various build improvements for Cython and CFFI backends (PyPy compiles at build time).
* Various GIL-related performance improvements - the GIL is no longer touched from a zmq IO thread.
* Adding a constant should now be a bit easier - only zmq/sugar/constant_names should need updating,
all other constant-related files should be automatically updated by ``setup.py constants``.
* add support for latest libzmq-4.0.1
(includes ZMQ_CURVE security and socket event monitoring).
New stuff
---------
- :meth:`.Socket.monitor`
- :meth:`.Socket.get_monitor_socket`
- :func:`zmq.curve_keypair`
- :mod:`zmq.utils.monitor`
- :mod:`zmq.utils.z85`
13.1.0
======
......@@ -65,16 +100,19 @@ New Stuff
* Support for PyPy via CFFI backend (requires py, ctypes-configure, and cffi).
* Add support for new APIs in libzmq-3
- :meth:`socket.disconnect`
- :meth:`socket.unbind`
- :meth:`context.set`
- :meth:`context.get`
- :meth:`Frame.set`
- :meth:`Frame.get`
- :meth:`.Socket.disconnect`
- :meth:`.Socket.unbind`
- :meth:`.Context.set`
- :meth:`.Context.get`
- :meth:`.Frame.set`
- :meth:`.Frame.get`
- :func:`zmq.proxy`
- :class:`zmq.devices.Proxy`
- Exceptions for common zmq errnos: :class:`zmq.Again`, :class:`zmq.ContextTerminated`
(subclass :class:`ZMQError`, so fully backward-compatible).
* Setting and getting :attr:`socket.hwm` sets or gets *both* SNDHWM/RCVHWM for libzmq-3.
* Setting and getting :attr:`.Socket.hwm` sets or gets *both* SNDHWM/RCVHWM for libzmq-3.
* Implementation splits core Cython bindings from pure-Python subclasses
with sugar methods (send/recv_multipart). This should facilitate
non-Cython backends and PyPy support [spoiler: it did!].
......
......@@ -56,21 +56,13 @@ intersphinx_mapping = {'python': ('http://docs.python.org/', None)}
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
def extract_version():
"""extract pyzmq version from version.py, so it's not multiply defined"""
with open(os.path.join('..', '..', 'zmq', 'sugar', 'version.py')) as f:
line = f.readline()
while not line.startswith("__version__"):
line = f.readline()
exec(line)
return __version__
vs = extract_version()
import zmq
# The short X.Y version.
version = vs.rstrip(string.letters)
version = zmq.__version__.split('-')[0]
# The full version, including alpha/beta/rc tags.
release = vs
release = zmq.__version__
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......
......@@ -28,25 +28,20 @@ General questions about ØMQ are better sent to the ØMQ `mailing list`_ or `IRC
Supported LibZMQ
================
PyZMQ aims to support all stable ( ≥2.1.4, ≥ 3.2.2 ) and active development ( ≥3.3.0 )
versions of libzmq. Note that libzmq 3.0-3.1 are not, and will never be supported.
There never was a stable release of either.
Building the same pyzmq against various versions of libzmq is supported,
and should only result in the addition/removal of a few socket types and socket
options, depending on the active libzmq's support.
Binary distributions (eggs or MSIs on `PyPI <http://pypi.python.org/pypi/pyzmq>`__
or `GitHub <https://www.github.com/zeromq/pyzmq/downloads>`__) of PyZMQ ship with
the stable version of libzmq at the time of release, built with default configuration.
PyZMQ aims to support all stable ( ≥2.1.4, ≥ 3.2.2, ≥ 4.0.1 ) and active development ( ≥ 4.1.0 )
versions of libzmq. Building the same pyzmq against various versions of libzmq is supported,
but only the functionality of the linked libzmq will be available.
Notes from developing PyZMQ
===========================
.. note::
.. toctree::
:maxdepth: 2
pyversions.rst
unicode.rst
libzmq 3.0-3.1 are not, and will never be supported.
There never was a stable release of either.
Binary distributions (eggs, MSIs, and wheels on `PyPI <http://pypi.python.org/pypi/pyzmq>`__
or `GitHub <https://www.github.com/zeromq/pyzmq/downloads>`__) of PyZMQ ship with
the stable version of libzmq at the time of release, built with default configuration.
For pyzmq-|release|, this is 4.0.3.
Using PyZMQ
===========
......@@ -54,6 +49,7 @@ Using PyZMQ
.. toctree::
:maxdepth: 2
api/index.rst
morethanbindings.rst
serialization.rst
devices.rst
......@@ -61,7 +57,15 @@ Using PyZMQ
logging.rst
ssh.rst
api/index.rst
Notes from developing PyZMQ
===========================
.. toctree::
:maxdepth: 2
pyversions.rst
unicode.rst
Indices and tables
==================
......
......@@ -43,7 +43,8 @@ approach is not recommended.
.. seealso::
ZeroMQ API `note on threadsafety <http://api.zeromq.org/2-1:zmq>`_
ZeroMQ API note on threadsafety on `2.2 <http://api.zeromq.org/2-2:zmq>`_
or `3.2 <http://api.zeromq.org/3-2:zmq>`_
Socket Options as Attributes
......
# -*- coding: utf-8 -*-
"""Simple example demonstrating the use of the socket monitoring feature."""
# This file is part of pyzmq.
#
# Distributed under the terms of the New BSD License. The full
# license is in the file COPYING.BSD, distributed as part of this
# software.
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):