使用distutils进行构建时,如何覆盖Cython的默认编译标志? [英] How does one overwrite the default compile flags for Cython when building with distutils?

查看:66
本文介绍了使用distutils进行构建时,如何覆盖Cython的默认编译标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在linux中编译一些cython扩展,并注意到从distutils机制构建时,它默认使用-O2。我想知道是否有一种简单的方法可以将其更改为-O3。

I am compiling some cython extensions in linux and noticed that it defaults to using -O2 when building from the distutils mechanism. I was wondering if there was a simple way to change that to a -O3.

我尝试在Extension对象上使用extra_compile_args,但这导致-O2和-O3作为参数传递给gcc。我有点想和其他深奥的gcc选项一起玩,因此希望我可以控制编译步骤。一个明显的问题是为什么不运行cython my.pyx并手动编译结果?。我想回答的是...但是从命令行运行时/ usr / local / bin /中的cython可执行文件抛出DistributionNotFound:Cython == 0.12.1错误。

I have tried using the extra_compile_args on Extension objects, but that leads to both -O2 and -O3 being passed as arguments to gcc. I kind of want to play with other esoteric gcc options and thus am hoping I can just control the compilation step. An obvious question is "why don't I just run cython my.pyx and compile the results manually?". I would love to, is my answer... but the cython executable in /usr/local/bin/ throws a DistributionNotFound: Cython==0.12.1 error when run from the command line. I haven't quite figured that one out.

无论如何,我不确定它是cython的东西,distutils的东西还是破烂的apt软件包的东西。我只是将cython从ubuntu 11.10 apt repo中抢了下来(并且目前正在使用ubuntu 11.10)。

Anyway, I am not sure if its a cython thing, a distutils thing or a broken apt package thing. I simply grabbed cython out of the ubuntu 11.10 apt repo (and am currently using ubuntu 11.10).

推荐答案

larsmans评论是正确的-使用/ usr / bin / cython解决了我的问题。

larsmans comment was right - using /usr/bin/cython addresses my issue.

这篇关于使用distutils进行构建时,如何覆盖Cython的默认编译标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆