我正在尝试为 32 位和 64 位架构编译 SciPy,因为一些使用该库的应用程序只是一个拱门或其他拱门,遵循一些 SO questions的建议。大约两个月前,这个命令在一个类似的版本中对我有用,但现在似乎一些编译的共享库只针对 x86_64:
sudo ARCHFLAGS="-arch i386 -arch x86_64" pip install scipy
我已经尝试过这个命令的几个版本,包括之前设置环境变量sudo
,包括-m32 -m64
在 FFlags 中,使用 OSX 命令行工具,完整的 Xcode 安装,使用 clang 而不是 OSX 附带的 LLVM,遵循官方 SciPy 安装说明, easy_install 而不是 pip 甚至 ./configure'ing 单独等,但我似乎无法让它工作。奇怪的是,有些 .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 编译器不同?brew install gfortran
根据 SciPy 文档,我使用的应该是好的。我认为重要的行将是C 编译器:clang行,它似乎几乎相同,包括两个 -arch。
我尝试过的最后一个最详细的构建是:
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 编译)