Pip / easy_install忽略了SciPy安装中的ARCHFLAGS?

时间:2012-04-06 16:06:52

标签: python gcc architecture scipy pip

我正在尝试为32位和64位架构编译SciPy,因为使用该库的一些应用程序只有一个拱形或另一个,遵循few {{3的建议}} SO。大约两个月前,这个命令在类似的版本中对我有用,但现在似乎有些已编译的共享库只针对x86_64:

sudo ARCHFLAGS="-arch i386 -arch x86_64" pip install scipy

我已经尝试过这个命令的几个版本,包括在sudo之前设置环境变量,包括FFlags中的-m32 -m64,使用OSX命令行工具,一个完整的Xcode安装,使用clang代替跟随questions,easy_install而不是pip甚至./configure'之后的OSX附带的LLVM,等等,但我似乎无法让它工作。奇怪的是,一些.so正在构建两种架构,但有些不是:

dhcp-10-249-71-202:~ kastman$ file /Library/Python/2.7/site-packages/scipy/optimize/*.so
/Library/Python/2.7/site-packages/scipy/optimize/_cobyla.so:   Mach-O 64-bit bundle x86_64
/Library/Python/2.7/site-packages/scipy/optimize/_lbfgsb.so:   Mach-O 64-bit bundle x86_64
/Library/Python/2.7/site-packages/scipy/optimize/_minpack.so:  Mach-O 64-bit bundle x86_64
/Library/Python/2.7/site-packages/scipy/optimize/_nnls.so:     Mach-O 64-bit bundle x86_64
/Library/Python/2.7/site-packages/scipy/optimize/_slsqp.so:    Mach-O 64-bit bundle x86_64
/Library/Python/2.7/site-packages/scipy/optimize/_zeros.so:    Mach-O universal binary with 2 architectures
/Library/Python/2.7/site-packages/scipy/optimize/_zeros.so (for architecture i386): Mach-O bundle i386
/Library/Python/2.7/site-packages/scipy/optimize/_zeros.so (for architecture x86_64):   Mach-O 64-bit bundle x86_64
/Library/Python/2.7/site-packages/scipy/optimize/minpack2.so:  Mach-O 64-bit bundle x86_64
/Library/Python/2.7/site-packages/scipy/optimize/moduleTNC.so: Mach-O universal binary with 2 architectures
/Library/Python/2.7/site-packages/scipy/optimize/moduleTNC.so (for architecture i386):  Mach-O bundle i386
/Library/Python/2.7/site-packages/scipy/optimize/moduleTNC.so (for architecture x86_64):    Mach-O 64-bit bundle x86_64

查看make日志,看起来args正在成功传递给看起来有用的库和那些没有成功的库:

# Minpack doesn't build fat binaries
/usr/local/bin/gfortran -Wall -Wall -undefined dynamic_lookup -bundle build/temp.macosx-10.7-intel-2.7/build/src.macosx-10.7-intel-2.7/scipy/optimize/minpack2/minpack2module.o build/temp.macosx-10.7-intel-2.7/build/src.macosx-10.7-intel-2.7/fortranobject.o build/temp.macosx-10.7-intel-2.7/scipy/optimize/minpack2/dcsrch.o build/temp.macosx-10.7-intel-2.7/scipy/optimize/minpack2/dcstep.o -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin11/4.6.2 -Lbuild/temp.macosx-10.7-intel-2.7 -lgfortran -o build/lib.macosx-10.7-intel-2.7/scipy/optimize/minpack2.so
building 'scipy.optimize._slsqp' extension
compiling C sources
C compiler: clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe

#... but moduleTNC does.
llvm-gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.7-intel-2.7/scipy/optimize/tnc/moduleTNC.o build/temp.macosx-10.7-intel-2.7/scipy/optimize/tnc/tnc.o -Lbuild/temp.macosx-10.7-intel-2.7 -o build/lib.macosx-10.7-intel-2.7/scipy/optimize/moduleTNC.so
building 'scipy.optimize._cobyla' extension
compiling C sources
C compiler: clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe

差异是否可能是我正在使用的gfortran编译器?根据SciPy文档,我使用了brew install gfortran,这应该是好的。我认为重要的一行是 C编译器:clang 行,它看起来几乎相同,包括-arch's。

我尝试过的最后一个最详细的构建是:

sudo env ARCHFLAGS="-arch i386 -arch x86_64" ARCH="i386 x86_64" CC="clang" CXX="clang" FFLAGS="-ff2c -m32 -m64" pip install scipy

有人有关于如何进一步诊断此问题的建议吗?

(OSX 10.7,最近的MacBookPro,使用CLI工具和Xcode编译gcc)

1 个答案:

答案 0 :(得分:3)

从源代码和构建中拉出似乎正确创建了胖二进制文件。我不确定这是否已经修复过了(我没有在scipy开发列表中看到任何内容)或者它是否与pip / easy_install有关,但这是我为了让它工作而做的事情:< / p>

git clone https://github.com/scipy/scipy.git; cd scipy
export ARCHFLAGS='-arch i386 -arch x86_64'
python setup.py config
python setup.py build
sudo python setup.py install

没有特殊的CC环境变量,gfortran来自brew install gfortran,令人惊讶的是它看起来像gcc是llvm-gcc。