def generate_extension(ext_def):
    'Generate extension constructors.'
    assert ('name' in ext_def), 'invalid extension name'
    ext_path = (ext_def['name'].replace('.', os.path.sep) + '.pyx')
    ext_root = os.path.dirname(ext_path)
    ext_def['sources'] = [ext_path]
    if ('extra_objects' in ext_def):
        if (not sys.platform.startswith('linux')):
            static_libs = [os.path.split(lib) for lib in ext_def['extra_objects']]
            (lib_dirs, lib_names) = zip(*static_libs)
            lib_names = [os.path.splitext(name)[0] for name in lib_names]
            ext_def.setdefault('libraries', []).extend(lib_names)
            ext_def.setdefault('library_dirs', []).extend(list(set(lib_dirs)))
            del ext_def['extra_objects']
    arguments = ('include_dirs', 'library_dirs', 'runtime_library_dirs', 'extra_objects')
    for argument in arguments:
        try:
            ext_def[argument] = [os.path.join(ext_root, path) for path in ext_def[argument]]
        except KeyError:
            pass
    return Extension(**ext_def)
Generate extension constructors.
def generate_extension(ext_def):
    
    assert ('name' in ext_def), 'invalid extension name'
    ext_path = (ext_def['name'].replace('.', os.path.sep) + '.pyx')
    ext_root = os.path.dirname(ext_path)
    ext_def['sources'] = [ext_path]
    if ('extra_objects' in ext_def):
        if (not sys.platform.startswith('linux')):
            static_libs = [os.path.split(lib) for lib in ext_def['extra_objects']]
            (lib_dirs, lib_names) = zip(*static_libs)
            lib_names = [os.path.splitext(name)[0] for name in lib_names]
            ext_def.setdefault('libraries', []).extend(lib_names)
            ext_def.setdefault('library_dirs', []).extend(list(set(lib_dirs)))
            del ext_def['extra_objects']
    arguments = ('include_dirs', 'library_dirs', 'runtime_library_dirs', 'extra_objects')
    for argument in arguments:
        try:
            ext_def[argument] = [os.path.join(ext_root, path) for path in ext_def[argument]]
        except KeyError:
            pass
    return Extension(**ext_def)