6 Building and Installing PyZMQ
Min RK edited this page 2021-08-10 09:01:53 +02:00

pip

We build wheels with cibuildwheel, which means the following platform/Python combinations currently get wheels:

OS architecture Python
macOS x86_64 3.6-3.10 , pypy-3.7
macOS universal2 (arm + intel) 3.9-3.10
Windows x86/amd64 3.6-3.10
Windows amd64 pypy-3.7
manylinux1 (CentOS 5) 32/64b x86 3.6, 3.7
manylinux2010 (CentOS 6) 32/64b x86 3.8-3.10, pypy-3.7
manylinux2014 (CentOS 7) arm64 (aarch64) 3.6-3.10

We have binary installers for various Pythons on macOS and Windows, so you should be able to just pip install pyzmq in most situations. These wheels include matching libzmq, so they should be the only thing you need to start using pyzmq.

If a binary installer fails for you, please tell us about your system and the failure, so that we can try to fix it in later releases, and fall back on building from source.

Building PyZMQ from source

pyzmq will try to build libzmq as a Python extension if it cannot find a libzmq to link against. This is thanks to work done in pyzmq_static.

To install pyzmq ignoring wheels, you can do:

pip install --no-binary pyzmq pyzmq

Linking against system libzmq is the preferred mechanism, so pyzmq will try pretty hard to find it, including using tools such as pkg-config if available.

Note that recent versions of pip (as of 2021) do not support --install-option command-line arguments (pip accepts them, but does not pass them along to setup.py), so environment variables must be used to configure compilation

You can skip the searching by specifying environment variables ZMQ_PREFIX:

ZMQ_PREFIX=/opt/my/zmq-prefix pip install --no-binary pyzmq

or tell it to build libzmq as an Extension:

ZMQ_PREFIX=bundled pip install --no-binary pyzmq pyzmq

If you want pyzmq to expose zmq DRAFT APIs (experimental and not fully supported), add ZMQ_DRAFT_API=1.

Cython is not required to build pyzmq from a release package, but it is required if you want to develop pyzmq, or build directly from our repository on GitHub.

Windows

On Windows, libzmq.dll will be copied into the zmq directory, and installed along with pyzmq, so you shouldn't need to edit your PATH.

It is best to compile both ØMQ and PyØMQ with Microsoft Visual Studio 2008 (2010 for Python ≥ 3.3). You should not need to use mingw. If you build libzmq with VS that does not match the one used to build Python, then there may be issues in error handling, because there will be a mismatch between error numbers.

Development

To develop PyZMQ, you will need to install Cython, version 0.29 or greater. After installing Cython, do:

$ pip install -e .

This will build the C extension inplace and then put this directory on your sys.path. With this configuration you only have to run:

$ python setup.py build_ext --inplace

each time you change the .pyx files. To clean the sources, you can do:

$ python setup.py clean

Testing

To run the test suite after building pyzmq in-place, install the test requirements:

$ pip install -r test-requirements

and run:

$ pytest

after an install or any changes you want to test