Exemple #1
0
    def run(self):
        self.create_tempdir()
        settings = copy.copy(COMPILER_SETTINGS)
        if doing_bdist and not sys.platform.startswith('win'):
            # rpath slightly differently here, because libzmq not in .. but ../zmq:
            settings['library_dirs'] = ['zmq']
            if sys.platform == 'darwin':
                pass
                # unused rpath args for OSX:
                # settings['extra_link_args'] = ['-Wl,-rpath','-Wl,$ORIGIN/../zmq']
            else:
                settings['runtime_library_dirs'] = ['$ORIGIN/../zmq']
        try:
            print ("*"*42)
            print ("Configure: Autodetecting ZMQ settings...")
            print ("    Custom ZMQ dir:       %s" % (ZMQ,))
            config = detect_zmq(self.tempdir, **settings)
        except Exception:
            fatal("""
    Failed to compile ZMQ test program.  Please check to make sure:

    * You have a C compiler installed
    * A development version of Python is installed (including header files)
    * A development version of ZeroMQ >= 2.1.0 is installed (including header files)
    * If ZMQ is not in a default location, supply the argument --zmq=<path>""")
            
        else:
            savepickle('configure.pickle', config)
            print ("    ZMQ version detected: %s" % v_str(config['vers']))
        finally:
            print ("*"*42)
            self.erase_tempdir()
        self.config = config
Exemple #2
0
    def run(self):
        """Run the test suite, with nose, or unittest if nose is unavailable"""
        # crude check for inplace build:
        try:
            import zmq
        except ImportError:
            print_exc()
            fatal(
                "\n       ".join(
                    [
                        "Could not import zmq!",
                        "You must build pyzmq with 'python setup.py build_ext --inplace' for 'python setup.py test' to work.",
                        "If you did build pyzmq in-place, then this is a real error.",
                    ]
                )
            )
            sys.exit(1)

        info("Testing pyzmq-%s with libzmq-%s" % (zmq.pyzmq_version(), zmq.zmq_version()))

        if nose is None:
            warn("nose unavailable, falling back on unittest. Skipped tests will appear as ERRORs.")
            return self.run_unittest()
        else:
            return self.run_nose()
Exemple #3
0
    def run(self):
        """Run the test suite, with nose, or unittest if nose is unavailable"""
        # crude check for inplace build:
        try:
            import zmq
        except ImportError:
            print_exc()
            fatal('\n       '.join([
                "Could not import zmq!",
                "You must build pyzmq with 'python setup.py build_ext --inplace' for 'python setup.py test' to work.",
                "If you did build pyzmq in-place, then this is a real error."
            ]))
            sys.exit(1)

        info("Testing pyzmq-%s with libzmq-%s" %
             (zmq.pyzmq_version(), zmq.zmq_version()))

        try:
            import nose
        except ImportError:
            warn(
                "nose unavailable, falling back on unittest. Skipped tests will appear as ERRORs."
            )
            return self.run_unittest()
        else:
            return self.run_nose()
Exemple #4
0
    def bundle_libzmq_extension(self):
        bundledir = "bundled"
        if "PyPy" in sys.version:
            fatal("Can't bundle libzmq as an Extension in PyPy (yet!)")
        ext_modules = self.distribution.ext_modules
        if ext_modules and ext_modules[0].name == "zmq.libzmq":
            # I've already been run
            return

        line()
        print("Using bundled libzmq")

        # fetch sources for libzmq extension:
        if not os.path.exists(bundledir):
            os.makedirs(bundledir)

        fetch_libzmq(bundledir)

        stage_platform_hpp(pjoin(bundledir, "zeromq"))

        # construct the Extension:

        ext = Extension(
            "zmq.libzmq",
            sources=[pjoin("buildutils", "initlibzmq.c")] + glob(pjoin(bundledir, "zeromq", "src", "*.cpp")),
            include_dirs=[pjoin(bundledir, "zeromq", "include")],
        )

        if sys.platform.startswith("win"):
            # include defines from zeromq msvc project:
            ext.define_macros.append(("FD_SETSIZE", 1024))
            ext.define_macros.append(("DLL_EXPORT", 1))

            # When compiling the C++ code inside of libzmq itself, we want to
            # avoid "warning C4530: C++ exception handler used, but unwind
            # semantics are not enabled. Specify /EHsc".
            if self.compiler_type == "msvc":
                ext.extra_compile_args.append("/EHsc")
            elif self.compiler_type == "mingw32":
                ext.define_macros.append(("ZMQ_HAVE_MINGW32", 1))

            # And things like sockets come from libraries that must be named.

            ext.libraries.extend(["rpcrt4", "ws2_32", "advapi32"])
        elif not sys.platform.startswith(("darwin", "freebsd")):
            ext.include_dirs.append(bundledir)

            # check if we need to link against Realtime Extensions library
            cc = new_compiler(compiler=self.compiler_type)
            if not cc.has_function("timer_create"):
                ext.libraries.append("rt")

        # insert the extension:
        self.distribution.ext_modules.insert(0, ext)

        # update other extensions, with bundled settings
        self.config["libzmq_extension"] = True
        self.init_settings_from_config()
        self.save_config("config", self.config)
Exemple #5
0
 def check_cython_extensions(self, extensions):
     for ext in extensions:
       for src in ext.sources:
         if not os.path.exists(src):
             fatal("""Cython-generated file '%s' not found.
             Cython is required to compile pyzmq from a development branch.
             Please install Cython or download a release package of pyzmq.
             """%src)
Exemple #6
0
 def check_cython_extensions(self, extensions):
     for ext in extensions:
         for src in ext.sources:
             if not os.path.exists(src):
                 fatal("""Cython-generated file '%s' not found.
             Cython >= %s is required to compile pyzmq from a development branch.
             Please install Cython or download a release package of pyzmq.
             """ % (src, min_cython_version))
Exemple #7
0
    def bundle_libzmq_extension(self):
        bundledir = "bundled"
        if "PyPy" in sys.version:
            fatal("Can't bundle libzmq as an Extension in PyPy (yet!)")
        ext_modules = self.distribution.ext_modules
        if ext_modules and ext_modules[0].name == 'zmq.libzmq':
            # I've already been run
            return
        
        line()
        print ("Using bundled libzmq")
        
        # fetch sources for libzmq extension:
        if not os.path.exists(bundledir):
            os.makedirs(bundledir)
        
        fetch_libzmq(bundledir)
        
        stage_platform_hpp(pjoin(bundledir, 'zeromq'))
        
        # construct the Extension:
        
        ext = Extension(
            'zmq.libzmq',
            sources = [pjoin('buildutils', 'initlibzmq.c')] + 
                        glob(pjoin(bundledir, 'zeromq', 'src', '*.cpp')),
            include_dirs = [
                pjoin(bundledir, 'zeromq', 'include'),
            ],
        )
        
        if sys.platform.startswith('win'):
            # include defines from zeromq msvc project:
            ext.define_macros.append(('FD_SETSIZE', 1024))
            
            # When compiling the C++ code inside of libzmq itself, we want to
            # avoid "warning C4530: C++ exception handler used, but unwind
            # semantics are not enabled. Specify /EHsc".
            if self.compiler_type == 'msvc':
                ext.extra_compile_args.append('/EHsc')
            elif self.compiler_type == 'mingw32':
                ext.define_macros.append(('ZMQ_HAVE_MINGW32', 1))

            # And things like sockets come from libraries that must be named.

            ext.libraries.extend(['rpcrt4', 'ws2_32', 'advapi32'])
        elif not sys.platform.startswith(('darwin', 'freebsd')):
            ext.include_dirs.append(bundledir)

            ext.libraries.append('rt')
        
        # insert the extension:
        self.distribution.ext_modules.insert(0, ext)
        
        # update other extensions, with bundled settings
        self.config['libzmq_extension'] = True
        self.init_settings_from_config()
        self.save_config('config', self.config)
Exemple #8
0
    def check_zmq_version(self):
        """check the zmq version"""
        cfg = self.config
        # build test program
        zmq_prefix = cfg['zmq_prefix']
        detected = self.test_build(zmq_prefix, self.compiler_settings)
        # now check the libzmq version

        vers = tuple(detected['vers'])
        vs = v_str(vers)
        if cfg['allow_legacy_libzmq']:
            min_zmq = min_legacy_zmq
        else:
            min_zmq = min_good_zmq
        if vers < min_zmq:
            msg = [
                "Detected ZMQ version: %s, but require ZMQ >= %s" %
                (vs, v_str(min_zmq)),
            ]
            if zmq_prefix:
                msg.append("    ZMQ_PREFIX=%s" % zmq_prefix)
            if vers >= min_legacy_zmq:

                msg.append(
                    "    Explicitly allow legacy zmq by specifying `--zmq=/zmq/prefix`"
                )

            raise LibZMQVersionError('\n'.join(msg))
        if vers < min_good_zmq:
            msg = [
                "Detected legacy ZMQ version: %s. It is STRONGLY recommended to use ZMQ >= %s"
                % (vs, v_str(min_good_zmq)),
            ]
            if zmq_prefix:
                msg.append("    ZMQ_PREFIX=%s" % zmq_prefix)
            warn('\n'.join(msg))
        elif vers < target_zmq:
            warn("Detected ZMQ version: %s, but pyzmq targets ZMQ %s." %
                 (vs, v_str(target_zmq)))
            warn(
                "libzmq features and fixes introduced after %s will be unavailable."
                % vs)
            line()
        elif vers >= dev_zmq:
            warn(
                "Detected ZMQ version: %s. Some new features in libzmq may not be exposed by pyzmq."
                % vs)
            line()

        if sys.platform.startswith('win'):
            # fetch libzmq.dll into local dir
            local_dll = localpath('zmq', libzmq_name + '.dll')
            if not zmq_prefix and not os.path.exists(local_dll):
                fatal(
                    "ZMQ directory must be specified on Windows via setup.cfg or 'python setup.py configure --zmq=/path/to/libzmq'"
                )
Exemple #9
0
    def check_zmq_version(self):
        """check the zmq version"""
        cfg = self.config
        # build test program
        zmq_prefix = cfg["zmq_prefix"]
        detected = self.test_build(zmq_prefix, self.compiler_settings)
        # now check the libzmq version

        vers = tuple(detected["vers"])
        vs = v_str(vers)
        if cfg["allow_legacy_libzmq"]:
            min_zmq = min_legacy_zmq
        else:
            min_zmq = min_good_zmq
        if vers < min_zmq:
            msg = ["Detected ZMQ version: %s, but require ZMQ >= %s" % (vs, v_str(min_zmq))]
            if zmq_prefix:
                msg.append("    ZMQ_PREFIX=%s" % zmq_prefix)
            if vers >= min_legacy_zmq:

                msg.append("    Explicitly allow legacy zmq by specifying `--zmq=/zmq/prefix`")

            raise LibZMQVersionError("\n".join(msg))
        if vers < min_good_zmq:
            msg = [
                "Detected legacy ZMQ version: %s. It is STRONGLY recommended to use ZMQ >= %s"
                % (vs, v_str(min_good_zmq))
            ]
            if zmq_prefix:
                msg.append("    ZMQ_PREFIX=%s" % zmq_prefix)
            warn("\n".join(msg))
        elif vers < target_zmq:
            warn("Detected ZMQ version: %s, but pyzmq targets ZMQ %s." % (vs, v_str(target_zmq)))
            warn("libzmq features and fixes introduced after %s will be unavailable." % vs)
            line()
        elif vers >= dev_zmq:
            warn("Detected ZMQ version: %s. Some new features in libzmq may not be exposed by pyzmq." % vs)
            line()

        if sys.platform.startswith("win"):
            # fetch libzmq.dll into local dir
            local_dll = localpath("zmq", "libzmq.dll")
            if not zmq_prefix and not os.path.exists(local_dll):
                fatal(
                    "ZMQ directory must be specified on Windows via setup.cfg or 'python setup.py configure --zmq=/path/to/zeromq2'"
                )
            try:
                shutil.copy(pjoin(zmq_prefix, "lib", "libzmq.dll"), local_dll)
            except Exception:
                if not os.path.exists(local_dll):
                    warn(
                        "Could not copy libzmq into zmq/, which is usually necessary on Windows."
                        "Please specify zmq prefix via configure --zmq=/path/to/zmq or copy "
                        "libzmq into zmq/ manually."
                    )
Exemple #10
0
 def bundle_libsodium_extension(self, libzmq):
     bundledir = "bundled"
     if "PyPy" in sys.version:
         fatal("Can't bundle libsodium as an Extension in PyPy (yet!)")
     ext_modules = self.distribution.ext_modules
     if ext_modules and any(m.name == 'zmq.libsodium' for m in ext_modules):
         # I've already been run
         return
     
     if not os.path.exists(bundledir):
         os.makedirs(bundledir)
     
     line()
     info("Using bundled libsodium")
     
     # fetch sources for libsodium
     fetch_libsodium(bundledir)
     
     # stage headers
     stage_libsodium_headers(pjoin(bundledir, 'libsodium'))
     
     # construct the Extension
     libsodium_src = pjoin(bundledir, 'libsodium', 'src', 'libsodium')
     exclude = pjoin(libsodium_src, 'crypto_stream', 'salsa20', 'amd64_xmm6') # or ref?
     exclude = pjoin(libsodium_src, 'crypto_scalarmult', 'curve25519', 'donna_c64') # or ref?
     
     libsodium_sources = [pjoin('buildutils', 'initlibsodium.c')]
     
     for dir,subdirs,files in os.walk(libsodium_src):
         if dir.startswith(exclude):
             continue
         for f in files:
             if f.endswith('.c'):
                 libsodium_sources.append(pjoin(dir, f))
     
     libsodium = Extension(
         'zmq.libsodium',
         sources = libsodium_sources,
         include_dirs = [
             pjoin(libsodium_src, 'include'),
             pjoin(libsodium_src, 'include', 'sodium'),
         ],
     )
     # register the Extension
     self.distribution.ext_modules.insert(0, libsodium)
     
     if sys.byteorder == 'little':
         libsodium.define_macros.append(("NATIVE_LITTLE_ENDIAN", 1))
     else:
         libsodium.define_macros.append(("NATIVE_BIG_ENDIAN", 1))
     
     # tell libzmq about libsodium
     libzmq.define_macros.append(("HAVE_LIBSODIUM", 1))
     libzmq.include_dirs.extend(libsodium.include_dirs)
Exemple #11
0
    def run(self):
        """Run the test suite with py.test"""
        # crude check for inplace build:
        try:
            import zmq
        except ImportError:
            print_exc()
            fatal('\n       '.join(["Could not import zmq!",
            "You must build pyzmq with 'python setup.py build_ext --inplace' for 'python setup.py test' to work.",
            "If you did build pyzmq in-place, then this is a real error."]))
            sys.exit(1)

        info("Testing pyzmq-%s with libzmq-%s" % (zmq.pyzmq_version(), zmq.zmq_version()))
        p = Popen([sys.executable, '-m', 'pytest', '-v', os.path.join('zmq', 'tests')])
        p.wait()
        sys.exit(p.returncode)
Exemple #12
0
 def create_tempdir(self):
     self.erase_tempdir()
     os.mkdir(self.tempdir)
     if sys.platform.startswith('win'):
         # fetch libzmq.dll into local dir
         local_dll = pjoin(self.tempdir, 'libzmq.dll')
         if ZMQ is None and not os.path.exists(local_dll):
             fatal("ZMQ directory must be specified on Windows via setup.cfg or 'python setup.py configure --zmq=/path/to/zeromq2'")
         
         try:
             shutil.copy(pjoin(ZMQ, 'lib', 'libzmq.dll'), local_dll)
         except Exception:
             if not os.path.exists(local_dll):
                 warn("Could not copy libzmq into zmq/, which is usually necessary on Windows."
                 "Please specify zmq prefix via configure --zmq=/path/to/zmq or copy "
                 "libzmq into zmq/ manually.")
Exemple #13
0
 def create_tempdir(self):
     self.erase_tempdir()
     os.mkdir(self.tempdir)
     if sys.platform.startswith('win'):
         # fetch libzmq.dll into local dir
         local_dll = pjoin(self.tempdir, 'libzmq.dll')
         if ZMQ is None and not os.path.exists(local_dll):
             fatal("ZMQ directory must be specified on Windows via setup.cfg or 'python setup.py configure --zmq=/path/to/zeromq2'")
         
         try:
             shutil.copy(pjoin(ZMQ, 'lib', 'libzmq.dll'), local_dll)
         except Exception:
             if not os.path.exists(local_dll):
                 warn("Could not copy libzmq into zmq/, which is usually necessary on Windows."
                 "Please specify zmq prefix via configure --zmq=/path/to/zmq or copy "
                 "libzmq into zmq/ manually.")
Exemple #14
0
 def run(self):
     """Run the test suite with py.test"""
     # crude check for inplace build:
     try:
         import zmq
     except ImportError:
         print_exc()
         fatal('\n       '.join(["Could not import zmq!",
         "You must build pyzmq with 'python setup.py build_ext --inplace' for 'python setup.py test' to work.",
         "If you did build pyzmq in-place, then this is a real error."]))
         sys.exit(1)
     
     info("Testing pyzmq-%s with libzmq-%s" % (zmq.pyzmq_version(), zmq.zmq_version()))
     p = Popen([sys.executable, '-m', 'pytest', '-v', os.path.join('zmq', 'tests')])
     p.wait()
     sys.exit(p.returncode)
Exemple #15
0
    def run(self):
        self.create_tempdir()
        settings = copy.copy(COMPILER_SETTINGS)
        if doing_bdist and not sys.platform.startswith('win'):
            # rpath slightly differently here, because libzmq not in .. but ../zmq:
            settings['library_dirs'] = ['zmq']
            if sys.platform == 'darwin':
                pass
                # unused rpath args for OSX:
                # settings['extra_link_args'] = ['-Wl,-rpath','-Wl,$ORIGIN/../zmq']
            else:
                settings['runtime_library_dirs'] = ['$ORIGIN/../zmq']
        try:
            print("*" * 42)
            print("Configure: Autodetecting ZMQ settings...")
            print("    Custom ZMQ dir:       %s" % (ZMQ, ))
            config = detect_zmq(self.tempdir, **settings)
        except Exception:
            etype, evalue, tb = sys.exc_info()
            # print the error as distutils would if we let it raise:
            print("error: %s" % evalue)
            if etype is CompileError:
                action = 'compile'
            elif etype is LinkError:
                action = 'link'
            else:
                action = 'build or run'
            fatal("""
    Failed to %s ZMQ test program.  Please check to make sure:

    * You have a C compiler installed
    * A development version of Python is installed (including header files)
    * A development version of ZMQ >= %s is installed (including header files)
    * If ZMQ is not in a default location, supply the argument --zmq=<path>
    * If you did recently install ZMQ to a default location, 
      try rebuilding the ld cache with `sudo ldconfig`
      or specify zmq's location with `--zmq=/usr/local`
    """ % (action, v_str(min_zmq)))

        else:
            savepickle('configure.pickle', config)
            print("    ZMQ version detected: %s" % v_str(config['vers']))
        finally:
            print("*" * 42)
            self.erase_tempdir()
        self.config = config
Exemple #16
0
    def check_zmq_version(self):
        """check the zmq version"""
        cfg = self.config

        # build test program
        zmq_prefix = self.config['zmq_prefix']
        detected = self.test_build(zmq_prefix, self.compiler_settings)
        # now check the libzmq version

        vers = tuple(detected['vers'])
        vs = v_str(vers)
        if vers < min_zmq:
            fatal("Detected ZMQ version: %s, but depend on zmq >= %s" %
                  (vs, v_str(min_zmq)) + '\n       Using ZMQ=%s' %
                  (zmq_prefix or 'unspecified'))

        if vers < target_zmq:
            warn("Detected ZMQ version: %s, but pyzmq targets ZMQ %s." %
                 (vs, v_str(target_zmq)))
            warn(
                "libzmq features and fixes introduced after %s will be unavailable."
                % vs)
            line()
        elif vers >= dev_zmq:
            warn(
                "Detected ZMQ version: %s. pyzmq's support for libzmq-dev is experimental."
                % vs)
            line()

        if sys.platform.startswith('win'):
            # fetch libzmq.dll into local dir
            local_dll = localpath('zmq', 'libzmq.dll')
            if not zmq_prefix and not os.path.exists(local_dll):
                fatal(
                    "ZMQ directory must be specified on Windows via setup.cfg or 'python setup.py configure --zmq=/path/to/zeromq2'"
                )
            try:
                shutil.copy(pjoin(zmq_prefix, 'lib', 'libzmq.dll'), local_dll)
            except Exception:
                if not os.path.exists(local_dll):
                    warn(
                        "Could not copy libzmq into zmq/, which is usually necessary on Windows."
                        "Please specify zmq prefix via configure --zmq=/path/to/zmq or copy "
                        "libzmq into zmq/ manually.")
Exemple #17
0
    def run(self):
        self.create_tempdir()
        settings = copy.copy(COMPILER_SETTINGS)
        if doing_bdist and not sys.platform.startswith('win'):
            # rpath slightly differently here, because libzmq not in .. but ../zmq:
            settings['library_dirs'] = ['zmq']
            if sys.platform == 'darwin':
                pass
                # unused rpath args for OSX:
                # settings['extra_link_args'] = ['-Wl,-rpath','-Wl,$ORIGIN/../zmq']
            else:
                settings['runtime_library_dirs'] = ['$ORIGIN/../zmq']
        try:
            print ("*"*42)
            print ("Configure: Autodetecting ZMQ settings...")
            print ("    Custom ZMQ dir:       %s" % (ZMQ,))
            config = detect_zmq(self.tempdir, **settings)
        except Exception:
            etype = sys.exc_info()[0]
            if etype is CompileError:
                action = 'compile'
            elif etype is LinkError:
                action = 'link'
            else:
                action = 'run'
            fatal("""
    Failed to %s ZMQ test program.  Please check to make sure:

    * You have a C compiler installed
    * A development version of Python is installed (including header files)
    * A development version of ZMQ >= %s is installed (including header files)
    * If ZMQ is not in a default location, supply the argument --zmq=<path>
    * If you did recently install ZMQ to a default location, 
      try rebuilding the ld cache with `sudo ldconfig`
      or specify zmq's location with `--zmq=/usr/local`
    """%(action, v_str(min_zmq)))
            
        else:
            savepickle('configure.pickle', config)
            print ("    ZMQ version detected: %s" % v_str(config['vers']))
        finally:
            print ("*"*42)
            self.erase_tempdir()
        self.config = config
Exemple #18
0
    def check_zmq_version(self):
        """check the zmq version"""
        cfg = self.config

        # build test program
        zmq_prefix = self.config["zmq_prefix"]
        detected = self.test_build(zmq_prefix, self.compiler_settings)
        # now check the libzmq version

        vers = tuple(detected["vers"])
        vs = v_str(vers)
        if vers < min_zmq:
            fatal(
                "Detected ZMQ version: %s, but depend on zmq >= %s" % (vs, v_str(min_zmq))
                + "\n       Using ZMQ=%s" % (zmq_prefix or "unspecified")
            )

        if vers < target_zmq:
            warn("Detected ZMQ version: %s, but pyzmq targets ZMQ %s." % (vs, v_str(target_zmq)))
            warn("libzmq features and fixes introduced after %s will be unavailable." % vs)
            line()
        elif vers >= dev_zmq:
            warn("Detected ZMQ version: %s. pyzmq's support for libzmq-dev is experimental." % vs)
            line()

        if sys.platform.startswith("win"):
            # fetch libzmq.dll into local dir
            local_dll = localpath("zmq", "libzmq.dll")
            if not zmq_prefix and not os.path.exists(local_dll):
                fatal(
                    "ZMQ directory must be specified on Windows via setup.cfg or 'python setup.py configure --zmq=/path/to/zeromq2'"
                )
            try:
                shutil.copy(pjoin(zmq_prefix, "lib", "libzmq.dll"), local_dll)
            except Exception:
                if not os.path.exists(local_dll):
                    warn(
                        "Could not copy libzmq into zmq/, which is usually necessary on Windows."
                        "Please specify zmq prefix via configure --zmq=/path/to/zmq or copy "
                        "libzmq into zmq/ manually."
                    )
Exemple #19
0
    def check_zmq_version(self):
        zmq = self.zmq
        if zmq is not None and zmq is not "bundled" and not os.path.isdir(zmq):
            fatal("Custom zmq directory \"%s\" does not exist" % zmq)

        config = self.getcached()
        if not config or config.get('settings') != self.settings:
            self.run()
            config = self.config
        else:
            self.config = config
            line()

        if self.zmq == "bundled":
            return

        vers = config['vers']
        vs = v_str(vers)
        if vers < min_zmq:
            fatal("Detected ZMQ version: %s, but depend on zmq >= %s" %
                  (vs, v_str(min_zmq)) + '\n       Using ZMQ=%s' %
                  (zmq or 'unspecified'))
        pyzmq_version = extract_version().strip('abcdefghijklmnopqrstuvwxyz')

        if vs < pyzmq_version:
            warn("Detected ZMQ version: %s, but pyzmq targets zmq %s." %
                 (vs, pyzmq_version))
            warn(
                "libzmq features and fixes introduced after %s will be unavailable."
                % vs)
            line()
        elif vs >= '3.0':
            warn(
                "Detected ZMQ version: %s. pyzmq's support for libzmq-dev is experimental."
                % vs)
            line()

        if sys.platform.startswith('win'):
            # fetch libzmq.dll into local dir
            local_dll = localpath('zmq', 'libzmq.dll')
            if zmq is None and not os.path.exists(local_dll):
                fatal(
                    "ZMQ directory must be specified on Windows via setup.cfg or 'python setup.py configure --zmq=/path/to/zeromq2'"
                )
            try:
                shutil.copy(pjoin(zmq, 'lib', 'libzmq.dll'), local_dll)
            except Exception:
                if not os.path.exists(local_dll):
                    warn(
                        "Could not copy libzmq into zmq/, which is usually necessary on Windows."
                        "Please specify zmq prefix via configure --zmq=/path/to/zmq or copy "
                        "libzmq into zmq/ manually.")
Exemple #20
0
    def check_zmq_version(self):
        
        zmq = CONFIG['zmq_prefix']
        if zmq and not os.path.exists(zmq) and \
            not CONFIG['libzmq_extension']:
            fatal("Custom zmq directory \"%s\" does not exist" % zmq)

        config = self.getcached()
        if not config or config.get('settings') != self.settings:
            self.run()
            config = self.config
        else:
            if CONFIG['libzmq_extension']:
                config = self.bundle_libzmq_extension()
            self.config = config
            
            line()
        
        if CONFIG['libzmq_extension'] or CONFIG['skip_check_zmq'] or CROSSCOMPILE:
            return
        
        # now check the libzmq version
        
        vers = tuple(config['vers'])
        vs = v_str(vers)
        if vers < min_zmq:
            fatal("Detected ZMQ version: %s, but depend on zmq >= %s"%(
                    vs, v_str(min_zmq))
                    +'\n       Using ZMQ=%s'%(zmq or 'unspecified'))
        
        if vers < target_zmq:
            warn("Detected ZMQ version: %s, but pyzmq targets ZMQ %s." % (
                    vs, v_str(target_zmq))
            )
            warn("libzmq features and fixes introduced after %s will be unavailable." % vs)
            line()
        elif vers >= dev_zmq:
            warn("Detected ZMQ version: %s. pyzmq's support for libzmq-dev is experimental." % vs)
            line()

        if sys.platform.startswith('win'):
            # fetch libzmq.dll into local dir
            local_dll = localpath('zmq','libzmq.dll')
            if not zmq and not os.path.exists(local_dll):
                fatal("ZMQ directory must be specified on Windows via setup.cfg or 'python setup.py configure --zmq=/path/to/zeromq2'")
            try:
                shutil.copy(pjoin(zmq, 'lib', 'libzmq.dll'), local_dll)
            except Exception:
                if not os.path.exists(local_dll):
                    warn("Could not copy libzmq into zmq/, which is usually necessary on Windows."
                    "Please specify zmq prefix via configure --zmq=/path/to/zmq or copy "
                    "libzmq into zmq/ manually.")
Exemple #21
0
    def check_zmq_version(self):
        zmq = self.zmq
        if zmq is not None and zmq is not "bundled" and not os.path.isdir(zmq):
            fatal("Custom zmq directory \"%s\" does not exist" % zmq)

        config = self.getcached()
        if not config or config.get('settings') != self.settings:
            self.run()
            config = self.config
        else:
            self.config = config
            line()

        if self.zmq == "bundled":
            return
        
        vers = tuple(config['vers'])
        vs = v_str(vers)
        if vers < min_zmq:
            fatal("Detected ZMQ version: %s, but depend on zmq >= %s"%(
                    vs, v_str(min_zmq))
                    +'\n       Using ZMQ=%s'%(zmq or 'unspecified'))
        pyzmq_vs = extract_version()
        pyzmq_version = tuple(int(d) for d in re.findall(r'\d+', pyzmq_vs))

        if vers < pyzmq_version[:len(vers)]:
            warn("Detected ZMQ version: %s, but pyzmq targets zmq %s."%(
                    vs, pyzmq_version))
            warn("libzmq features and fixes introduced after %s will be unavailable."%vs)
            line()
        elif vers >= (3,0,0):
            warn("Detected ZMQ version: %s. pyzmq's support for libzmq-dev is experimental."%vs)
            line()

        if sys.platform.startswith('win'):
            # fetch libzmq.dll into local dir
            local_dll = localpath('zmq','libzmq.dll')
            if zmq is None and not os.path.exists(local_dll):
                fatal("ZMQ directory must be specified on Windows via setup.cfg or 'python setup.py configure --zmq=/path/to/zeromq2'")
            try:
                shutil.copy(pjoin(zmq, 'lib', 'libzmq.dll'), local_dll)
            except Exception:
                if not os.path.exists(local_dll):
                    warn("Could not copy libzmq into zmq/, which is usually necessary on Windows."
                    "Please specify zmq prefix via configure --zmq=/path/to/zmq or copy "
                    "libzmq into zmq/ manually.")
Exemple #22
0
    def check_zmq_version(self):
        zmq = ZMQ
        if zmq is not None and not os.path.isdir(zmq):
            fatal('Custom zmq directory "%s" does not exist' % zmq)

        config = self.getcached()
        if config is None or config["options"] != COMPILER_SETTINGS:
            self.run()
            config = self.config
        else:
            self.config = config

        vers = config["vers"]
        vs = v_str(vers)
        if vers < min_zmq:
            fatal(
                "Detected ZMQ version: %s, but depend on zmq >= %s" % (vs, v_str(min_zmq))
                + "\n       Using ZMQ=%s" % (zmq or "unspecified")
            )
        pyzmq_version = extract_version().strip("abcdefghijklmnopqrstuvwxyz")

        if vs < pyzmq_version:
            warn("Detected ZMQ version: %s, but pyzmq targets zmq %s." % (vs, pyzmq_version))
            warn("libzmq features and fixes introduced after %s will be unavailable." % vs)
            print("*" * 42)
        elif vs > "3.0":
            warn("Detected ZMQ version: %s. pyzmq's 3.0 support is experimental." % vs)
            print("*" * 42)

        if sys.platform.startswith("win"):
            # fetch libzmq.dll into local dir
            local_dll = localpath("zmq", "libzmq.dll")
            if zmq is None and not os.path.exists(local_dll):
                fatal(
                    "ZMQ directory must be specified on Windows via setup.cfg or 'python setup.py configure --zmq=/path/to/zeromq2'"
                )
            try:
                shutil.copy(pjoin(zmq, "lib", "libzmq.dll"), local_dll)
            except Exception:
                if not os.path.exists(local_dll):
                    warn(
                        "Could not copy libzmq into zmq/, which is usually necessary on Windows."
                        "Please specify zmq prefix via configure --zmq=/path/to/zmq or copy "
                        "libzmq into zmq/ manually."
                    )
Exemple #23
0
    def check_zmq_version(self):
        zmq = self.zmq
        if zmq is not None and not os.path.isdir(zmq):
            fatal("Custom zmq directory \"%s\" does not exist" % zmq)

        config = self.getcached()
        if config is None or config['options'] != self.settings:
            self.run()
            config = self.config
        else:
            self.config = config

        vers = config['vers']
        vs = v_str(vers)
        if vers < min_zmq:
            fatal("Detected ZMQ version: %s, but depend on zmq >= %s"%(
                    vs, v_str(min_zmq))
                    +'\n       Using ZMQ=%s'%(zmq or 'unspecified'))
        pyzmq_version = extract_version().strip('abcdefghijklmnopqrstuvwxyz')

        if vs < pyzmq_version:
            warn("Detected ZMQ version: %s, but pyzmq targets zmq %s."%(
                    vs, pyzmq_version))
            warn("libzmq features and fixes introduced after %s will be unavailable."%vs)
            print('*'*42)
        elif vs >= '3.0':
            warn("Detected ZMQ version: %s. pyzmq's support for libzmq-dev is experimental."%vs)
            print('*'*42)

        if sys.platform.startswith('win'):
            # fetch libzmq.dll into local dir
            local_dll = localpath('zmq','libzmq.dll')
            if zmq is None and not os.path.exists(local_dll):
                fatal("ZMQ directory must be specified on Windows via setup.cfg or 'python setup.py configure --zmq=/path/to/zeromq2'")
            try:
                shutil.copy(pjoin(zmq, 'lib', 'libzmq.dll'), local_dll)
            except Exception:
                if not os.path.exists(local_dll):
                    warn("Could not copy libzmq into zmq/, which is usually necessary on Windows."
                    "Please specify zmq prefix via configure --zmq=/path/to/zmq or copy "
                    "libzmq into zmq/ manually.")
Exemple #24
0
    def check_zmq_version(self):
        zmq = ZMQ
        if zmq is not None and not os.path.isdir(zmq):
            fatal("Custom zmq directory \"%s\" does not exist" % zmq)

        config = self.getcached()
        if config is None or config['options'] != COMPILER_SETTINGS:
            self.run()
            config = self.config

        vers = config['vers']
        vs = v_str(vers)
        if vers < min_zmq:
            fatal("Detected ZMQ version: %s, but depend on zmq >= %s" %
                  (vs, v_str(min_zmq)) + '\n       Using ZMQ=%s' %
                  (zmq or 'unspecified'))
        pyzmq_version = extract_version().strip('abcdefghijklmnopqrstuvwxyz')

        if vs < pyzmq_version:
            warn("Detected ZMQ version: %s, but pyzmq is based on zmq %s." %
                 (vs, pyzmq_version))
            warn("Some features may be missing or broken.")
            print('*' * 42)

        if sys.platform.startswith('win'):
            # fetch libzmq.dll into local dir
            local_dll = localpath('zmq', 'libzmq.dll')
            if zmq is None and not os.path.exists(local_dll):
                fatal(
                    "ZMQ directory must be specified on Windows via setup.cfg or 'python setup.py configure --zmq=/path/to/zeromq2'"
                )
            try:
                shutil.copy(pjoin(zmq, 'lib', 'libzmq.dll'), local_dll)
            except Exception:
                if not os.path.exists(local_dll):
                    warn(
                        "Could not copy libzmq into zmq/, which is usually necessary on Windows."
                        "Please specify zmq prefix via configure --zmq=/path/to/zmq or copy "
                        "libzmq into zmq/ manually.")
Exemple #25
0
    def check_zmq_version(self):
        zmq = ZMQ
        if zmq is not None and not os.path.isdir(zmq):
            fatal("Custom zmq directory \"%s\" does not exist" % zmq)

        config = self.getcached()
        if config is None or config['options'] != COMPILER_SETTINGS:
            self.run()
            config = self.config

        vers = config['vers']
        vs = v_str(vers)
        if vers < min_zmq:
            fatal("Detected ZMQ version: %s, but depend on zmq >= %s"%(
                    vs, v_str(min_zmq))
                    +'\n       Using ZMQ=%s'%(zmq or 'unspecified'))
        pyzmq_version = extract_version().strip('abcdefghijklmnopqrstuvwxyz')

        if vs < pyzmq_version:
            warn("Detected ZMQ version: %s, but pyzmq is based on zmq %s."%(
                    vs, pyzmq_version))
            warn("Some features may be missing or broken.")
            print('*'*42)

        if sys.platform.startswith('win'):
            # fetch libzmq.dll into local dir
            local_dll = localpath('zmq','libzmq.dll')
            if zmq is None and not os.path.exists(local_dll):
                fatal("ZMQ directory must be specified on Windows via setup.cfg or 'python setup.py configure --zmq=/path/to/zeromq2'")
            try:
                shutil.copy(pjoin(zmq, 'lib', 'libzmq.dll'), local_dll)
            except Exception:
                if not os.path.exists(local_dll):
                    warn("Could not copy libzmq into zmq/, which is usually necessary on Windows."
                    "Please specify zmq prefix via configure --zmq=/path/to/zmq or copy "
                    "libzmq into zmq/ manually.")
Exemple #26
0
    def bundle_libzmq_extension(self):
        bundledir = "bundled"
        if "PyPy" in sys.version:
            fatal("Can't bundle libzmq as an Extension in PyPy (yet!)")
        ext_modules = self.distribution.ext_modules
        if ext_modules and ext_modules[0].name == 'zmq.libzmq':
            # I've already been run
            return

        line()
        info("Using bundled libzmq")

        # fetch sources for libzmq extension:
        if not os.path.exists(bundledir):
            os.makedirs(bundledir)

        fetch_libzmq(bundledir)

        stage_platform_hpp(pjoin(bundledir, 'zeromq'))

        # construct the Extension:

        ext = Extension(
            'zmq.libzmq',
            sources=[pjoin('buildutils', 'initlibzmq.c')] +
            glob(pjoin(bundledir, 'zeromq', 'src', '*.cpp')),
            include_dirs=[
                pjoin(bundledir, 'zeromq', 'include'),
            ],
        )

        if sys.platform.startswith('win'):
            # include defines from zeromq msvc project:
            ext.define_macros.append(('FD_SETSIZE', 1024))
            ext.define_macros.append(('DLL_EXPORT', 1))

            # When compiling the C++ code inside of libzmq itself, we want to
            # avoid "warning C4530: C++ exception handler used, but unwind
            # semantics are not enabled. Specify /EHsc".
            if self.compiler_type == 'msvc':
                ext.extra_compile_args.append('/EHsc')
            elif self.compiler_type == 'mingw32':
                ext.define_macros.append(('ZMQ_HAVE_MINGW32', 1))

            # And things like sockets come from libraries that must be named.

            ext.libraries.extend(['rpcrt4', 'ws2_32', 'advapi32'])
        else:
            ext.include_dirs.append(bundledir)

            # check if we need to link against Realtime Extensions library
            cc = new_compiler(compiler=self.compiler_type)
            cc.output_dir = self.build_temp
            if not sys.platform.startswith(('darwin', 'freebsd')) \
                and not cc.has_function('timer_create'):
                ext.libraries.append('rt')

            # check if we *can* link libsodium
            if cc.has_function('crypto_box_keypair',
                               libraries=ext.libraries + ['sodium']):
                ext.libraries.append('sodium')
                ext.define_macros.append(("HAVE_LIBSODIUM", 1))
            else:
                warn(
                    "libsodium not found, zmq.CURVE security will be unavailable"
                )

        # insert the extension:
        self.distribution.ext_modules.insert(0, ext)

        # update other extensions, with bundled settings
        self.config['libzmq_extension'] = True
        self.init_settings_from_config()
        self.save_config('config', self.config)
Exemple #27
0
    def bundle_libzmq_extension(self):
        bundledir = "bundled"
        if "PyPy" in sys.version:
            fatal("Can't bundle libzmq as an Extension in PyPy (yet!)")
        ext_modules = self.distribution.ext_modules
        if ext_modules and ext_modules[0].name == 'zmq.libzmq':
            # I've already been run
            return
        
        line()
        info("Using bundled libzmq")
        
        # fetch sources for libzmq extension:
        if not os.path.exists(bundledir):
            os.makedirs(bundledir)
        
        fetch_libzmq(bundledir)
        
        stage_platform_hpp(pjoin(bundledir, 'zeromq'))
        
        # construct the Extension:
        
        ext = Extension(
            'zmq.libzmq',
            sources = [pjoin('buildutils', 'initlibzmq.c')] + 
                        glob(pjoin(bundledir, 'zeromq', 'src', '*.cpp')),
            include_dirs = [
                pjoin(bundledir, 'zeromq', 'include'),
            ],
        )
        
        if sys.platform.startswith('win'):
            # include defines from zeromq msvc project:
            ext.define_macros.append(('FD_SETSIZE', 1024))
            ext.define_macros.append(('DLL_EXPORT', 1))
            
            # When compiling the C++ code inside of libzmq itself, we want to
            # avoid "warning C4530: C++ exception handler used, but unwind
            # semantics are not enabled. Specify /EHsc".
            if self.compiler_type == 'msvc':
                ext.extra_compile_args.append('/EHsc')
            elif self.compiler_type == 'mingw32':
                ext.define_macros.append(('ZMQ_HAVE_MINGW32', 1))

            # And things like sockets come from libraries that must be named.

            ext.libraries.extend(['rpcrt4', 'ws2_32', 'advapi32'])
        else:
            ext.include_dirs.append(bundledir)
            
            # check if we need to link against Realtime Extensions library
            cc = new_compiler(compiler=self.compiler_type)
            cc.output_dir = self.build_temp
            if not sys.platform.startswith(('darwin', 'freebsd')) \
                and not cc.has_function('timer_create'):
                    ext.libraries.append('rt')
            
            # check if we *can* link libsodium
            if cc.has_function('crypto_box_keypair', libraries=ext.libraries + ['sodium']):
                ext.libraries.append('sodium')
                ext.define_macros.append(("HAVE_LIBSODIUM", 1))
            else:
                warn("libsodium not found, zmq.CURVE security will be unavailable")
        
        # insert the extension:
        self.distribution.ext_modules.insert(0, ext)
        
        # update other extensions, with bundled settings
        self.config['libzmq_extension'] = True
        self.init_settings_from_config()
        self.save_config('config', self.config)
 def run(self):
     cfg = self.config
     if 'PyPy' in sys.version:
         info("PyPy: Nothing to configure")
         return
     
     if cfg['libzmq_extension']:
         self.bundle_libzmq_extension()
         self.finish_run()
         return
     
     # When cross-compiling and zmq is given explicitly, we can't testbuild
     # (as we can't testrun the binary), we assume things are alright.
     if cfg['skip_check_zmq'] or self.cross_compiling:
         warn("Skipping zmq version check")
         self.finish_run()
         return
     
     zmq_prefix = cfg['zmq_prefix']
     # There is no available default on Windows, so start with fallback unless
     # zmq was given explicitly, or libzmq extension was explicitly prohibited.
     if sys.platform.startswith("win") and \
             not cfg['no_libzmq_extension'] and \
             not zmq_prefix:
         self.fallback_on_bundled()
         self.finish_run()
         return
     
     if zmq_prefix and self.bundle_libzmq_dylib and not sys.platform.startswith('win'):
         copy_and_patch_libzmq(zmq_prefix, 'libzmq'+lib_ext)
     
     # first try with given config or defaults
     try:
         self.check_zmq_version()
     except Exception:
         etype, evalue, tb = sys.exc_info()
         # print the error as distutils would if we let it raise:
         info("\nerror: %s\n" % evalue)
     else:
         self.finish_run()
         return
     
     # try fallback on /usr/local on *ix if no prefix is given
     if not zmq_prefix and not sys.platform.startswith('win'):
         info("Failed with default libzmq, trying again with /usr/local")
         time.sleep(1)
         zmq_prefix = cfg['zmq_prefix'] = '/usr/local'
         self.init_settings_from_config()
         try:
             self.check_zmq_version()
         except Exception:
             etype, evalue, tb = sys.exc_info()
             # print the error as distutils would if we let it raise:
             info("\nerror: %s\n" % evalue)
         else:
             # if we get here the second run succeeded, so we need to update compiler
             # settings for the extensions with /usr/local prefix
             self.finish_run()
             return
     
     # finally, fallback on bundled
     
     if cfg['no_libzmq_extension']:
         fatal("Falling back on bundled libzmq,"
         " but setup.cfg has explicitly prohibited building the libzmq extension."
         )
     
     self.fallback_on_bundled()
     
     self.finish_run()
Exemple #29
0
    def run(self):
        self.create_tempdir()
        settings = self.settings
        if bundle_libzmq and not sys.platform.startswith('win'):
            # rpath slightly differently here, because libzmq not in .. but ../zmq:
            settings['library_dirs'] = ['zmq']
            if sys.platform == 'darwin':
                pass
                # unused rpath args for OSX:
                # settings['extra_link_args'] = ['-Wl,-rpath','-Wl,$ORIGIN/../zmq']
            else:
                settings['runtime_library_dirs'] = ['$ORIGIN/../zmq']
        try:
            print ("*"*42)
            print ("Configure: Autodetecting ZMQ settings...")
            print ("    Custom ZMQ dir:       %s" % (self.zmq,))
            config = detect_zmq(self.tempdir, **settings)
        except Exception:
            # if zmq unspecified on *ix, try again with explicit /usr/local
            if self.zmq is None and not sys.platform.startswith('win'):
                self.erase_tempdir()
                print ("Failed with default libzmq, trying again with /usr/local")
                self.zmq = '/usr/local'
                self.settings = settings_from_prefix(self.zmq)
                
                self.run()
                # if we get here the second run succeeded, so we need to update compiler
                # settings for the extensions with /usr/local prefix
                for ext in self.distribution.ext_modules:
                    for key,value in self.settings.iteritems():
                        setattr(ext, key, value)
                return
            
            etype, evalue, tb = sys.exc_info()
            # print the error as distutils would if we let it raise:
            print ("error: %s" % evalue)
            if etype is CompileError:
                action = 'compile'
            elif etype is LinkError:
                action = 'link'
            else:
                action = 'build or run'
            
            fatal("""
    Failed to %s ZMQ test program.  Please check to make sure:

    * You have a C compiler installed
    * A development version of Python is installed (including header files)
    * A development version of ZMQ >= %s is installed (including header files)
    * If ZMQ is not in a default location, supply the argument --zmq=<path>
    * If you did recently install ZMQ to a default location, 
      try rebuilding the ld cache with `sudo ldconfig`
      or specify zmq's location with `--zmq=/usr/local`
    """%(action, v_str(min_zmq)))
            
        else:
            savepickle('configure.pickle', config)
            print ("    ZMQ version detected: %s" % v_str(config['vers']))
        finally:
            print ("*"*42)
            self.erase_tempdir()
        self.config = config
Exemple #30
0
    def run(self):
        cfg = self.config

        if cfg['libzmq_extension']:
            self.bundle_libzmq_extension()
            self.finish_run()
            return

        # When cross-compiling and zmq is given explicitly, we can't testbuild
        # (as we can't testrun the binary), we assume things are alright.
        if cfg['skip_check_zmq'] or self.cross_compiling:
            warn("Skipping zmq version check")
            self.finish_run()
            return

        zmq_prefix = cfg['zmq_prefix']
        # There is no available default on Windows, so start with fallback unless
        # zmq was given explicitly, or libzmq extension was explicitly prohibited.
        if (sys.platform.startswith("win") and not cfg['no_libzmq_extension']
                and not zmq_prefix):
            self.fallback_on_bundled()
            self.finish_run()
            return

        if (zmq_prefix and self.bundle_libzmq_dylib
                and not sys.platform.startswith('win')):
            copy_and_patch_libzmq(zmq_prefix, libzmq_name + lib_ext)

        # first try with given config or defaults
        try:
            self.check_zmq_version()
        except LibZMQVersionError as e:
            info("\nBad libzmq version: %s\n" % e)
        except Exception as e:
            # print the error as distutils would if we let it raise:
            info("\nerror: %s\n" % e)
        else:
            self.finish_run()
            return

        # try fallback on /usr/local on *ix if no prefix is given
        if not zmq_prefix and not sys.platform.startswith('win'):
            info("Failed with default libzmq, trying again with /usr/local")
            time.sleep(1)
            zmq_prefix = cfg['zmq_prefix'] = '/usr/local'
            self.init_settings_from_config()
            try:
                self.check_zmq_version()
            except LibZMQVersionError as e:
                info("\nBad libzmq version: %s\n" % e)
            except Exception as e:
                # print the error as distutils would if we let it raise:
                info("\nerror: %s\n" % e)
            else:
                # if we get here the second run succeeded, so we need to update compiler
                # settings for the extensions with /usr/local prefix
                self.finish_run()
                return

        # finally, fallback on bundled

        if cfg['no_libzmq_extension']:
            fatal(
                "Falling back on bundled libzmq,"
                " but config has explicitly prohibited building the libzmq extension."
            )

        self.fallback_on_bundled()

        self.finish_run()
Exemple #31
0
 def run(self):
     if CONFIG['libzmq_extension']:
         self.config = self.bundle_libzmq_extension()
         save_config('configure', self.config)
         line()
         return
     
     # When cross-compiling and zmq is given explicitly, we can't testbuild
     # (as we can't testrun the binary), we assume things are alright.
     if CONFIG['skip_check_zmq'] or CROSSCOMPILE:
         warn("Skipping zmq version check")
         return
     
     config = None
     zmq_prefix = CONFIG['zmq_prefix']
     # There is no available default on Windows, so start with fallback unless
     # zmq was given explicitly, or libzmq extension was explicitly prohibited.
     if sys.platform.startswith("win") and \
         not CONFIG['no_libzmq_extension'] and \
         not zmq_prefix:
         config = self.fallback_on_bundled()
     
     if config is None:
         # first try with given config or defaults
         try:
             config = self.test_build(zmq_prefix, self.settings)
         except Exception:
             etype, evalue, tb = sys.exc_info()
             # print the error as distutils would if we let it raise:
             print ("\nerror: %s\n" % evalue)
     
     # try fallback on /usr/local on *ix
     if config is None and not zmq_prefix and not sys.platform.startswith('win'):
         print ("Failed with default libzmq, trying again with /usr/local")
         time.sleep(1)
         zmq_prefix = CONFIG['zmq_prefix'] = '/usr/local'
         settings = init_settings(CONFIG)
         try:
             config = self.test_build(zmq_prefix, settings)
         except Exception:
             etype, evalue, tb = sys.exc_info()
             # print the error as distutils would if we let it raise:
             print ("\nerror: %s\n" % evalue)
         else:
             # if we get here the second run succeeded, so we need to update compiler
             # settings for the extensions with /usr/local prefix
             save_config('buildconf', CONFIG)
             for ext in self.distribution.ext_modules:
                 for attr,value in settings.items():
                     setattr(ext, attr, value)
     
     # finally, fallback on bundled
     if config is None and CONFIG['no_libzmq_extension']:
         fatal("Falling back on bundled libzmq,"
         " but setup.cfg has explicitly prohibited building the libzmq extension."
         )
     
     if config is None:
         config = self.fallback_on_bundled()
     
     save_config('configure', config)
     self.config = config
     line()