'Monkey-patch distutils with our own build_ext class knowing
about pycc-compiled extensions modules.'

@classmethod
def monkey_patch_distutils(cls):

    if cls._distutils_monkey_patched:
        return
    _orig_build_ext = build_ext.build_ext
    class _CC_build_ext(_orig_build_ext, ):
        def build_extension(self, ext):
            if isinstance(ext, _CCExtension):
                ext._prepare_object_files(self)
            _orig_build_ext.build_extension(self, ext)
    build_ext.build_ext = _CC_build_ext
    cls._distutils_monkey_patched = True
