def build_extension(): # Return the un-cythonized extension. # This can be used to access things like `libraries` and `include_dirs` # and `define_macros` so we DRY. include_dirs = get_include_dirs() include_dirs.append(os.path.abspath(os.path.join('src', 'gevent', 'libev'))) if LIBEV_EMBED: include_dirs.append(dep_abspath('libev')) CORE = Extension(name='gevent.libev.corecext', sources=[ 'src/gevent/libev/corecext.pyx', 'src/gevent/libev/callbacks.c', ], include_dirs=include_dirs, libraries=list(LIBRARIES), define_macros=list(DEFINE_MACROS), depends=glob_many('src/gevent/libev/callbacks.*', 'src/gevent/libev/stathelper.c', 'src/gevent/libev/libev*.h', 'deps/libev/*.[ch]')) if WIN: CORE.define_macros.append(('EV_STANDALONE', '1')) # QQQ libev can also use -lm, however it seems to be added implicitly if LIBEV_EMBED: CORE.define_macros += [ ('LIBEV_EMBED', '1'), # we don't use void* data in the cython implementation; # the CFFI implementation does and removes this line. ('EV_COMMON', ''), # libev watchers that we don't use currently: ('EV_CLEANUP_ENABLE', '0'), ('EV_EMBED_ENABLE', '0'), ("EV_PERIODIC_ENABLE", '0'), # Time keeping. If possible, use the realtime and/or monotonic # clocks. On Linux, this can reduce the number of observable syscalls. # On older linux, such as the version in manylinux2010, this requires # linking to lib rt. We handle this in make-manylinux. Newer versions # generally don't need that. ("EV_USE_REALTIME", "1"), ("EV_USE_MONOTONIC", "1"), # use the builtin floor() function. Every modern platform should # have this, right? ("EV_USE_FLOOR", "1"), ] CORE.configure = configure_libev if os.environ.get('GEVENTSETUP_EV_VERIFY') is not None: CORE.define_macros.append( ('EV_VERIFY', os.environ['GEVENTSETUP_EV_VERIFY'])) # EV_VERIFY is implemented using assert(), which only works if # NDEBUG is *not* defined. distutils likes to define NDEBUG by default, # meaning that we get no verification in embedded mode. Since that's the # most common testing configuration, that's not good. CORE.undef_macros.append('NDEBUG') else: CORE.define_macros += [('LIBEV_EMBED', '0')] CORE.libraries.append('ev') CORE.configure = lambda *args: print("libev not embedded, not configuring") return CORE
def build_extension(): # Return the un-cythonized extension. # This can be used to access things like `libraries` and `include_dirs` # and `define_macros` so we DRY. include_dirs = get_include_dirs() include_dirs.append(os.path.abspath(os.path.join('src', 'gevent', 'libev'))) if LIBEV_EMBED: include_dirs.append(dep_abspath('libev')) CORE = Extension(name='gevent.libev.corecext', sources=[ 'src/gevent/libev/corecext.pyx', 'src/gevent/libev/callbacks.c', ], include_dirs=include_dirs, libraries=list(LIBRARIES), define_macros=list(DEFINE_MACROS), depends=glob_many('src/gevent/libev/callbacks.*', 'src/gevent/libev/stathelper.c', 'src/gevent/libev/libev*.h', 'deps/libev/*.[ch]')) if WIN: CORE.define_macros.append(('EV_STANDALONE', '1')) # QQQ libev can also use -lm, however it seems to be added implicitly if LIBEV_EMBED: CORE.define_macros += [ ('LIBEV_EMBED', '1'), # we don't use void* data in the cython implementation; # the CFFI implementation does and removes this line. ('EV_COMMON', ''), # libev watchers that we don't use currently: ('EV_CLEANUP_ENABLE', '0'), ('EV_EMBED_ENABLE', '0'), ("EV_PERIODIC_ENABLE", '0') ] CORE.configure = configure_libev if os.environ.get('GEVENTSETUP_EV_VERIFY') is not None: CORE.define_macros.append( ('EV_VERIFY', os.environ['GEVENTSETUP_EV_VERIFY'])) # EV_VERIFY is implemented using assert(), which only works if # NDEBUG is *not* defined. distutils likes to define NDEBUG by default, # meaning that we get no verification in embedded mode. Since that's the # most common testing configuration, that's not good. CORE.undef_macros.append('NDEBUG') else: CORE.define_macros += [('LIBEV_EMBED', '0')] CORE.libraries.append('ev') CORE.configure = lambda *args: print( "libev not embedded, not configuring") return CORE
def build_extension(): # Return the un-cythonized extension. # This can be used to access things like `libraries` and `include_dirs` # and `define_macros` so we DRY. CORE = Extension(name='gevent.libev.corecext', sources=[ 'src/gevent/libev/corecext.pyx', 'src/gevent/libev/callbacks.c', ], include_dirs=['src/gevent/libev'] + [dep_abspath('libev')] if LIBEV_EMBED else [], libraries=list(LIBRARIES), define_macros=list(DEFINE_MACROS), depends=glob_many('src/gevent/libev/callbacks.*', 'src/gevent/libev/stathelper.c', 'src/gevent/libev/libev*.h', 'deps/libev/*.[ch]')) if WIN: CORE.define_macros.append(('EV_STANDALONE', '1')) # QQQ libev can also use -lm, however it seems to be added implicitly if LIBEV_EMBED: CORE.define_macros += [ ('LIBEV_EMBED', '1'), # we don't use void* data in the cython implementation; # the CFFI implementation does and removes this line. ('EV_COMMON', ''), # libev watchers that we don't use currently: ('EV_CLEANUP_ENABLE', '0'), ('EV_EMBED_ENABLE', '0'), ("EV_PERIODIC_ENABLE", '0') ] CORE.configure = configure_libev if os.environ.get('GEVENTSETUP_EV_VERIFY') is not None: CORE.define_macros.append( ('EV_VERIFY', os.environ['GEVENTSETUP_EV_VERIFY'])) else: CORE.define_macros += [('LIBEV_EMBED', '0')] CORE.libraries.append('ev') CORE.configure = lambda *args: print( "libev not embedded, not configuring") return CORE
sources=['src/gevent/libev/gevent.corecext.c'], include_dirs=[dep_abspath('libev')] if LIBEV_EMBED else [], libraries=list(LIBRARIES), define_macros=list(DEFINE_MACROS), depends=glob_many('src/gevent/libev/callbacks.*', 'src/gevent/libev/stathelper.c', 'src/gevent/libev/libev*.h', 'deps/libev/*.[ch]')) if WIN: CORE.define_macros.append(('EV_STANDALONE', '1')) # QQQ libev can also use -lm, however it seems to be added implicitly if LIBEV_EMBED: CORE.define_macros += [ ('LIBEV_EMBED', '1'), ('EV_COMMON', ''), # we don't use void* data # libev watchers that we don't use currently: ('EV_CLEANUP_ENABLE', '0'), ('EV_EMBED_ENABLE', '0'), ("EV_PERIODIC_ENABLE", '0') ] CORE.configure = configure_libev if sys.platform == "darwin": os.environ["CPPFLAGS"] = ( "%s %s" % (os.environ.get("CPPFLAGS", ""), "-U__llvm__")).lstrip() if os.environ.get('GEVENTSETUP_EV_VERIFY') is not None: CORE.define_macros.append( ('EV_VERIFY', os.environ['GEVENTSETUP_EV_VERIFY'])) else: CORE.libraries.append('ev')
include_dirs=get_include_dirs( *([dep_abspath('c-ares')] if CARES_EMBED else [])), libraries=list(LIBRARIES), define_macros=list(DEFINE_MACROS), depends=glob_many('src/gevent/resolver/cares_*.[ch]')) ares_required = RUNNING_ON_CI and RUNNING_FROM_CHECKOUT ARES.optional = not ares_required if CARES_EMBED: ARES.sources += glob_many('deps/c-ares/*.c') # Strip the standalone binaries that would otherwise # cause linking issues for bin_c in ('acountry', 'adig', 'ahost'): ARES.sources.remove('deps/c-ares' + os.sep + bin_c + '.c') ARES.configure = configure_ares if WIN: ARES.libraries += ['advapi32'] ARES.define_macros += [('CARES_STATICLIB', '')] else: ARES.define_macros += [('HAVE_CONFIG_H', '')] if sys.platform != 'darwin': ARES.libraries += ['rt'] else: # libresolv dependency introduced in # c-ares 1.16.1. ARES.libraries += ['resolv'] ARES.define_macros += [('CARES_EMBED', '1')] else: ARES.libraries.append('cares') ARES.define_macros += [('HAVE_NETDB_H', '')]
libraries=list(LIBRARIES), define_macros=list(DEFINE_MACROS), depends=glob_many('src/gevent/resolver/dnshelper.c', 'src/gevent/resolver/cares_*.[ch]')) ares_required = RUNNING_ON_CI and RUNNING_FROM_CHECKOUT ARES.optional = not ares_required if CARES_EMBED: ARES.sources += glob_many('deps/c-ares/*.c') # Strip the standalone binaries that would otherwise # cause linking issues for bin_c in ('acountry', 'adig', 'ahost'): ARES.sources.remove('deps/c-ares' + os.sep + bin_c + '.c') ARES.configure = configure_ares if WIN: ARES.libraries += ['advapi32'] ARES.define_macros += [('CARES_STATICLIB', '')] else: ARES.define_macros += [('HAVE_CONFIG_H', '')] if sys.platform != 'darwin': ARES.libraries += ['rt'] ARES.define_macros += [('CARES_EMBED', '1')] else: ARES.libraries.append('cares') ARES.define_macros += [('HAVE_NETDB_H', '')] ARES.configure = lambda bext, ext: print("c-ares not embedded, not configuring", bext, ext) ARES = cythonize1(ARES)
finally: os.chdir(cwd) CORE = Extension(name='gevent.libev.corecext', sources=['src/gevent/libev/gevent.corecext.c'], include_dirs=[dep_abspath('libev')] if LIBEV_EMBED else [], libraries=list(LIBRARIES), define_macros=list(DEFINE_MACROS), depends=glob_many('src/gevent/libev/callbacks.*', 'src/gevent/libev/stathelper.c', 'src/gevent/libev/libev*.h', 'deps/libev/*.[ch]')) if WIN: CORE.define_macros.append(('EV_STANDALONE', '1')) # QQQ libev can also use -lm, however it seems to be added implicitly if LIBEV_EMBED: CORE.define_macros += [('LIBEV_EMBED', '1'), ('EV_COMMON', ''), # we don't use void* data # libev watchers that we don't use currently: ('EV_CLEANUP_ENABLE', '0'), ('EV_EMBED_ENABLE', '0'), ("EV_PERIODIC_ENABLE", '0')] CORE.configure = configure_libev if sys.platform == "darwin": os.environ["CPPFLAGS"] = ("%s %s" % (os.environ.get("CPPFLAGS", ""), "-U__llvm__")).lstrip() if os.environ.get('GEVENTSETUP_EV_VERIFY') is not None: CORE.define_macros.append(('EV_VERIFY', os.environ['GEVENTSETUP_EV_VERIFY'])) else: CORE.libraries.append('ev')
sources=['src/gevent/gevent.ares.c'], include_dirs=[dep_abspath('c-ares')] if CARES_EMBED else [], libraries=list(LIBRARIES), define_macros=list(DEFINE_MACROS), depends=glob_many('src/gevent/dnshelper.c', 'src/gevent/cares_*.[ch]')) ARES.optional = True if CARES_EMBED: ARES.sources += glob_many('deps/c-ares/*.c') # Strip the standalone binaries that would otherwise # cause linking issues for bin_c in ('acountry', 'adig', 'ahost'): try: ARES.sources.remove('deps/c-ares/' + bin_c + '.c') except ValueError: pass ARES.configure = configure_ares if WIN: ARES.libraries += ['advapi32'] ARES.define_macros += [('CARES_STATICLIB', '')] else: ARES.define_macros += [('HAVE_CONFIG_H', '')] if sys.platform != 'darwin': ARES.libraries += ['rt'] ARES.define_macros += [('CARES_EMBED', '1')] else: ARES.libraries.append('cares') ARES.define_macros += [('HAVE_NETDB_H', '')]