1"""Import basic exposure of libzmq C API as a backend"""
2
3# Copyright (C) PyZMQ Developers
4# Distributed under the terms of the Modified BSD License.
5
6public_api = [
7    'Context',
8    'Socket',
9    'Frame',
10    'Message',
11    'Stopwatch',
12    'device',
13    'proxy',
14    'zmq_poll',
15    'strerror',
16    'zmq_errno',
17    'has',
18    'curve_keypair',
19    'constants',
20    'zmq_version_info',
21    'IPC_PATH_MAX_LEN',
22]
23
24def select_backend(name):
25    """Select the pyzmq backend"""
26    try:
27        mod = __import__(name, fromlist=public_api)
28    except ImportError:
29        raise
30    except Exception as e:
31        import sys
32        from zmq.utils.sixcerpt import reraise
33        exc_info = sys.exc_info()
34        reraise(ImportError, ImportError("Importing %s failed with %s" % (name, e)), exc_info[2])
35
36    ns = {}
37    for key in public_api:
38        ns[key] = getattr(mod, key)
39    return ns
40