本文介绍了Distutils编译器选项配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许是一个愚蠢的问题,但是我想知道Python的distutils是从哪里获得编译器选项的?它弄错了一些链接目录,我想一劳永逸地纠正它。

Maybe a stupid question, but I was wondering where Python's distutils get the compiler options from? It gets some linked directories wrong and I want to correct that once and for all.

我知道应该有一个前缀/lib/pythonver/distutils/distutils.cfg,但是我在计算机上的任何地方都找不到distutils.cfg。显然我没有本地setup.cfg或任何$ HOME / .pydistutils.cfg。

I know there should be a prefix/lib/pythonver/distutils/distutils.cfg but I can't find any distutils.cfg anywhere on the computer. Obviously I haven't got a local setup.cfg or any $HOME/.pydistutils.cfg.

我使用的是Enthought 64位发行版,版本7.3( Mac OS X 10.8.3上的Python 2.7)

I'm using the Enthought 64-bit distribution, version 7.3 (Python 2.7) on Mac OS X 10.8.3

干杯,
U。

Cheers,U.

推荐答案

我实际上将它们导出到环境中,就像自动工具的配置一样:

I actually export them to the environment, just like for autotools' configure:

export CC=/usr/local/bin/clang
export CFLAGS=-I${HOME}/include
export LDFLAGS=-lboost

如果还需要分别覆盖链接器,则:

If you also need to override the linker separately:

export LDSHARED=/usr/local/bin/clang -shared

如果您不喜欢导出设置到您的环境,对一次性设置执行以下操作:

And if you don't like exporting the settings to your environment, do something like this for a one-time setting:

CC=/usr/local/bin/clang CFLAGS=-I${HOME}/include python setup.py build

如果要了解构建python时的默认选项,请使用 pyt hon-config-< flag> 。一些标志是 cflags ldflags libs 包含

If you want to find out what the default options were when python was build, use python-config --<flag>. Some flags are cflags, ldflags, libs or includes.

这篇关于Distutils编译器选项配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 20:48