build_src.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码
def generate_a_pyrex_source(self, base, ext_name, source, extension):
        if self.inplace or not have_pyrex():
            target_dir = os.path.dirname(base)
        else:
            target_dir = appendpath(self.build_src, os.path.dirname(base))
        target_file = os.path.join(target_dir, ext_name + '.c')
        depends = [source] + extension.depends
        if self.force or newer_group(depends, target_file, 'newer'):
            if have_pyrex():
                import Pyrex.Compiler.Main
                log.info("pyrexc:> %s" % (target_file))
                self.mkpath(target_dir)
                options = Pyrex.Compiler.Main.CompilationOptions(
                    defaults=Pyrex.Compiler.Main.default_options,
                    include_path=extension.include_dirs,
                    output_file=target_file)
                pyrex_result = Pyrex.Compiler.Main.compile(source,
                                                           options=options)
                if pyrex_result.num_errors != 0:
                    raise DistutilsError("%d errors while compiling %r with Pyrex" \
                          % (pyrex_result.num_errors, source))
            elif os.path.isfile(target_file):
                log.warn("Pyrex required for compiling %r but not available,"\
                         " using old target %r"\
                         % (source, target_file))
            else:
                raise DistutilsError("Pyrex required for compiling %r"\
                                     " but notavailable" % (source,))
        return target_file
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号