Ejemplo n.º 1
0
def test_cython(language_level, request, tmpdir):
    import pyximport

    assert 'zmq.tests.cython_ext' not in sys.modules

    importers = pyximport.install(
        setup_args=dict(include_dirs=zmq.get_includes()),
        language_level=language_level,
        build_dir=str(tmpdir),
    )

    cython_ext = None

    def unimport():
        pyximport.uninstall(*importers)
        sys.modules.pop('zmq.tests.cython_ext', None)

    request.addfinalizer(unimport)

    # this import tests the compilation
    from . import cython_ext

    assert hasattr(cython_ext, 'send_recv_test')

    # call the compiled function
    # this shouldn't do much
    msg = b'my msg'
    received = cython_ext.send_recv_test(msg)
    assert received == msg
Ejemplo n.º 2
0
def get_ext_modules():
    import zmq
    return [
        Extension(
            'gevent_zeromq._zmq',
            ['gevent_zeromq/_zmq.py'],
            include_dirs = zmq.get_includes(),
        ),
    ]
Ejemplo n.º 3
0
 def test_get_includes(self):
     from os.path import dirname, basename
     includes = zmq.get_includes()
     self.assertTrue(isinstance(includes, list))
     self.assertTrue(len(includes) >= 2)
     parent = includes[0]
     self.assertTrue(isinstance(parent, str))
     utilsdir = includes[1]
     self.assertTrue(isinstance(utilsdir, str))
     utils = basename(utilsdir)
     self.assertEqual(utils, "utils")
Ejemplo n.º 4
0
 def test_get_includes(self):
     from os.path import dirname, basename
     includes = zmq.get_includes()
     self.assertTrue(isinstance(includes, list))
     self.assertTrue(len(includes) >= 2)
     parent = includes[0]
     self.assertTrue(isinstance(parent, str))
     utilsdir = includes[1]
     self.assertTrue(isinstance(utilsdir, str))
     utils = basename(utilsdir)
     self.assertEqual(utils, "utils")
Ejemplo n.º 5
0
    def run(self):

        # Import numpy here, only when headers are needed
        import numpy
        import zmq

        # Add numpy/zmq headers to include_dirs
        self.include_dirs.append(numpy.get_include())
        self.include_dirs.extend(zmq.get_includes())

        if zmq_lib_path is not None and zmq_lib_path != "":
            self.library_dirs.append(zmq_lib_path)

        # Call original build_ext command
        build_ext.run(self)
Ejemplo n.º 6
0
def log_sysinfo(app: Flask, config: Config):
    app.logger.info("ZMQ:")
    app.logger.info("  zmq version: %s", zmq.zmq_version())
    app.logger.info("  pyzmq version: %s", zmq.pyzmq_version())
    app.logger.info("  zmq includes: %s", zmq.get_includes())
    app.logger.info("  zmq library dirs: %s", zmq.get_library_dirs())
    app.logger.info("  has: %s", [c for c in ZMQ_CAPABILITIES if zmq.has(c)])
    app.logger.info("socket:")
    app.logger.info("  fqdn: %s", socket.getfqdn())
    app.logger.info("  has_ipv6: %s", socket.has_ipv6)
    app.logger.info("  hostname: %s", socket.gethostname())
    app.logger.info("  interfaces: %s", [i[1] for i in socket.if_nameindex()])
    app.logger.info("os:")
    app.logger.info("  ctermid: %s", os.ctermid())
    app.logger.info("  cwd: %s", os.getcwd())
    app.logger.info("  groups: %s", os.getgroups())
    app.logger.info("  pgid: %d", os.getpgid(0))
    app.logger.info("  pgrp: %d", os.getpgrp())
    app.logger.info("  pid: %d", os.getpid())
    app.logger.info("  ppid: %d", os.getppid())
    app.logger.info("  priority_process: %d",
                    os.getpriority(os.PRIO_PROCESS, 0))
    app.logger.info("  priority_pgrp: %d", os.getpriority(os.PRIO_PGRP, 0))
    app.logger.info("  priority_user: %d", os.getpriority(os.PRIO_USER, 0))
    app.logger.info("  resuid: ruid=%d, euid=%d, suid=%d", *os.getresuid())
    app.logger.info("  resgid: rgid=%d, egid=%d, sgid=%d", *os.getresgid())
    app.logger.info("  sid: %d", os.getsid(0))
    app.logger.info("  supports_bytes_environ: %s", os.supports_bytes_environ)
    app.logger.info("  uname: %s", os.uname())
    app.logger.info("  cpu_count: %d", os.cpu_count())
    app.logger.info("platform:")
    app.logger.info("  %s", platform.platform())
    app.logger.info("  python_build: %s", platform.python_build())
    app.logger.info("  python_compiler: %s", platform.python_compiler())
    app.logger.info("  python_branch: %s", platform.python_branch())
    app.logger.info("  python_implementation: %s",
                    platform.python_implementation())
    app.logger.info("  python_revision: %s", platform.python_revision())
    app.logger.info("  python_version: %s", platform.python_version())
    app.logger.info("getpass:"******"  user: %s", getpass.getuser())
Ejemplo n.º 7
0
# -----------------------------------------------------------------------------
# Suppress Common warnings
# -----------------------------------------------------------------------------

extra_flags = []
if ignore_common_warnings:
    for warning in ("unused-function", "strict-aliasing"):
        extra_flags.append("-Wno-" + warning)

# -----------------------------------------------------------------------------
# Extensions
# -----------------------------------------------------------------------------

cmdclass = {"test": TestCommand, "clean": CleanCommand}

includes = [inc for inc in get_includes() if "utils" in inc]


def pxd(subdir, name):
    return os.path.abspath(pjoin("checkbuffers", subdir, name + ".pxd"))


def pyx(subdir, name):
    return os.path.abspath(pjoin("checkbuffers", subdir, name + ".pyx"))


def dotc(subdir, name):
    return os.path.abspath(pjoin("checkbuffers", subdir, name + ".c"))


try:
Ejemplo n.º 8
0
def get_ext_modules():
    if not cython_available:
        return []

    try:
        import gevent
    except ImportError, e:
        print 'WARNING: gevent must be installed to build cython version of gevent-zeromq (%s).' % e
        return []
    try:
        import zmq
    except ImportError, e:
        print 'WARNING: pyzmq(>=2.1.0) must be installed to build cython version of gevent-zeromq (%s).' % e
        return []

    return [Extension('gevent_zeromq.core', ['gevent_zeromq/core.pyx'], include_dirs=zmq.get_includes())]

class TestCommand(Command):
    """Custom distutils command to run the test suite."""

    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

    def run(self):
        # crude check for inplace build:
        try:
Ejemplo n.º 9
0
    if not cython_available:
        print 'WARNING: cython not available, proceeding with pure python implementation.'
        return []

    try:
        import gevent
    except ImportError, e:
        print 'WARNING: gevent must be installed to build cython version of gevent-zeromq (%s).' % e
        return []
    try:
        import zmq
    except ImportError, e:
        print 'WARNING: pyzmq(>=2.1.0) must be installed to build cython version of gevent-zeromq (%s).' % e
        return []

    includes = zmq.get_includes()
    pattern = Extension('*', ['gevent_zeromq/*.pyx'], include_dirs=includes)
    return cythonize(pattern)


class TestCommand(Command):
    """Custom distutils command to run the test suite."""

    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass
Ejemplo n.º 10
0
def get_ext_modules():
    if not cython_available:
        print "WARNING: cython not available, proceeding with pure python implementation."
        return []
    try:
        import gevent
    except ImportError, e:
        print "WARNING: gevent must be installed to build cython version of gevent-zeromq (%s)." % e
        return []
    try:
        import zmq
    except ImportError, e:
        print "WARNING: pyzmq or pyzmq-static (>=2.1.0) must be installed to build cython version of gevent-zeromq (%s).", e
        return []

    return [Extension("gevent_zeromq.core", ["gevent_zeromq/core.pyx"], include_dirs=zmq.get_includes())]


class TestCommand(Command):
    """Custom distutils command to run the test suite."""

    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

    def run(self):
        # crude check for inplace build:
Ejemplo n.º 11
0
    if not cython_available:
        print 'WARNING: cython not available, proceeding with pure python implementation.'
        return []

    try:
        import gevent
    except ImportError, e:
        print 'WARNING: gevent must be installed to build cython version of gevent-zeromq (%s).' % e
        return []
    try:
        import zmq
    except ImportError, e:
        print 'WARNING: pyzmq(>=2.1.0) must be installed to build cython version of gevent-zeromq (%s).' % e
        return []

    includes = zmq.get_includes()
    pattern = Extension('*', ['gevent_zeromq/*.pyx'], include_dirs=includes)
    return cythonize(pattern)


class TestCommand(Command):
    """Custom distutils command to run the test suite."""

    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass
Ejemplo n.º 12
0
    try:
        import gevent
    except ImportError, e:
        print 'WARNING: gevent must be installed to build cython version of gevent-zeromq (%s).', e
        return []
    try:
        import zmq
    except ImportError, e:
        print 'WARNING: pyzmq(>=2.1.0) must be installed to build cython version of gevent-zeromq (%s).', e
        return []
    return [
        Extension(
            'gevent_zeromq.core',
            ['gevent_zeromq/core.pyx'],
            include_dirs = zmq.get_includes() + [os.path.dirname(os.path.dirname(zmq.__file__))]
        ),
    ]


class TestCommand(Command):
    """Custom distutils command to run the test suite."""

    user_options = [ ]

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass
Ejemplo n.º 13
0
    try:
        import gevent
    except ImportError, e:
        print 'WARNING: gevent must be installed to build cython version of gevent-zeromq (%s).', e
        return []
    try:
        import zmq
    except ImportError, e:
        print 'WARNING: pyzmq(>=2.1.0) must be installed to build cython version of gevent-zeromq (%s).', e
        return []

    return [Extension(
        'gevent_zeromq.core',
        ['gevent_zeromq/core.pyx'],
        include_dirs = zmq.get_includes()
    )]


class DevelopCommand(Command):
    """Fake develop command just to tell the user how to use the lib in
    develop mode"""

    user_options = [ ]

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass
Ejemplo n.º 14
0
def get_ext_modules():
    if not cython_available:
        print 'WARNING: cython not available, proceeding with pure python implementation.'
        return []
    try:
        import meinheld
    except ImportError, e:
        print 'WARNING: meinheld must be installed to build cython version of meinheld-zeromq (%s).' % e
        return []
    try:
        import zmq
    except ImportError, e:
        print 'WARNING: pyzmq(==2.2.0) must be installed to build cython version of meinheld-zeromq (%s).' % e
        return []

    return [Extension('meinheld_zeromq.core', ['meinheld_zeromq/core.pyx'], include_dirs=zmq.get_includes())]

__version__ = (0, 0, 1)

setup(
    name = 'meinheld_zeromq',
    version = '.'.join([str(x) for x in __version__]),
    packages = ['meinheld_zeromq'],
    ext_modules = get_ext_modules(),
    author = 'INADA Naoki',
    author_email = '*****@*****.**',
    url = 'http://github.com/methane/meinheld-zeromq',
    description = 'meinheld compatibility layer for pyzmq',
    long_description=open('README.rst').read(),
    install_requires = ['pyzmq==2.2.0', 'meinheld'],
    license = 'New BSD',
Ejemplo n.º 15
0
def get_ext_modules():

    try:
        import gevent
    except ImportError, e:
        print 'WARNING: gevent must be installed to build cython version of gevent-zeromq (%s).', e
        return []
    try:
        import zmq
    except ImportError, e:
        print 'WARNING: pyzmq(>=2.1.0) must be installed to build cython version of gevent-zeromq (%s).', e
        return []
    return [
        Extension('gevent_zeromq.core', ['gevent_zeromq/core.pyx'],
                  include_dirs=zmq.get_includes() +
                  [os.path.dirname(os.path.dirname(zmq.__file__))]),
    ]


class TestCommand(Command):
    """Custom distutils command to run the test suite."""

    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass
Ejemplo n.º 16
0
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize

import numpy
import zmq

extensions = [
    Extension("cyzmq_example", ["cyzmq.pyx"],
              include_dirs=zmq.get_includes() + [numpy.get_include()])
]
setup(name="cython-zmq-example", ext_modules=cythonize(extensions))
Ejemplo n.º 17
0
    Cython.Compiler.Options.convert_range = True
    Cython.Compiler.Options.cache_builtins = True
    Cython.Compiler.Options.gcc_branch_hints = True
    Cython.Compiler.Options.embed = False
    EXTENSIONS = cythonize(EXTENSIONS)

setup(
    name='raspi-rtl',
    version='3.0.0.dev1',
    description='Raspi Transport Layer 3',
    author='Kelcey Jamison-Damage',
    author_email='',
    url='https://github.com/kelceydamage/rtl.git',
    download_url='https://github.com/kelceydamage/rtl.git',
    license='http://www.apache.org/licenses/LICENSE-2.0',
    install_requires=[
        "zmq", "pyzmq", "lmdb", "cbor", "numpy", "cython", "sklearn", "bokeh"
        # "cupy" for systems with nvcc and CUDA
    ],
    py_modules=[
        'rtl.main', 'rtl.transport.cache', 'rtl.transport.registry',
        'rtl.transport.conf.configuration', 'rtl.common.logger',
        'rtl.tasks.null'
    ],
    packages=[],
    ext_modules=EXTENSIONS,
    include_dirs=[numpy.get_include(), zmq.get_includes()],
    scripts=[
        'rtl/transport/bin/raspi-rtl',
    ])
Ejemplo n.º 18
0
def get_ext_modules():
    if not cython_available:
        return []

    try:
        import gevent
    except ImportError, e:
        print 'WARNING: gevent must be installed to build cython version of gevent-zeromq (%s).', e
        return []
    try:
        import zmq
    except ImportError, e:
        print 'WARNING: pyzmq(>=2.1.0) must be installed to build cython version of gevent-zeromq (%s).', e
        return []

    return [Extension('gevent_zeromq.core', ['gevent_zeromq/core.pyx'], include_dirs=zmq.get_includes())]

class TestCommand(Command):
    """Custom distutils command to run the test suite."""

    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

    def run(self):
        # crude check for inplace build:
        try:
Ejemplo n.º 19
0
        zmq_lib_dir = os.path.abspath(os.path.expanduser(arg[10:]))
        sys.argv.remove(arg)

# Determine if pyzmq contains a bundled libzmq
if sys.platform.startswith("win"):
    zmq_lib_name = "libzmq"
    zmq_lib_ext = ".dll"
else:
    zmq_lib_name = "zmq"
    zmq_lib_ext = ".dylib" if sys.platform == "darwin" else ".so"

try:
    import zmq

    include_dirs.extend(zmq.get_includes())
    pyzmq_dir = os.path.dirname(zmq.__file__)
    zmq_lib_path_bundled = os.path.join(pyzmq_dir, "libzmq" + zmq_lib_ext)

    if os.path.exists(zmq_lib_path_bundled):
        # Warn the user in case libzmq dir is explicitly specified but it is not
        # the same as the bundled libzmq
        if zmq_lib_dir is not None and zmq_lib_dir != pyzmq_dir:
            print("Warning: pyzmq is using bundled libzmq, but splice.io will be\n"
                  "         linked against instance in directory: %s" % zmq_lib_dir)
        else:
            zmq_lib_dir = pyzmq_dir
except ImportError:
    zmq = None
    print("Warning: pyzmq not found - setup won't use bundled libzmq")