コード例 #1
0
ファイル: setupext.py プロジェクト: melissawm/matplotlib
def get_ccompiler():
    """
    Return a new CCompiler instance.

    CCompiler used to be constructible via `distutils.ccompiler.new_compiler`,
    but this API was removed as part of the distutils deprecation.  Instead,
    we trick setuptools into instantiating it by creating a dummy Distribution
    with a list of extension modules that claims to be truthy, but is actually
    empty, and then running the Distribution's build_ext command.  (If using
    a plain empty ext_modules, build_ext would early-return without doing
    anything.)
    """
    class L(list):
        def __bool__(self):
            return True

    build_ext = Distribution({"ext_modules": L()}).get_command_obj("build_ext")
    build_ext.finalize_options()
    build_ext.run()
    return build_ext.compiler