11

I am attempting to install Fabric, which requires pycrypto. During the build for pycrypto I always receive a "Broken Pipe" error. I don't know where to start to fix the problem.

I'm running Mac OS X Snow Leopard 10.6.6, all updates installed; Python 2.6.1; GCC 4.2; XCode 4 (in case that updated GCC)

The exact error is:

$ sudo python setup.py build
Password:
running build
running build_py
running build_ext
warning: GMP library not found; Not building Crypto.PublicKey._fastmath.
building 'Crypto.Hash.MD2' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -fwrapv -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c src/MD2.c -o build/temp.macosx-10.6-universal-2.6/src/MD2.o
/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as: assembler (/usr/bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/darwin/ppc/as) for architecture ppc not installed
Installed assemblers are:
/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386
src/MD2.c:134: fatal error: error writing to -: Broken pipe
compilation terminated.
lipo: can't open input file: /var/tmp//ccfADoXD.out (No such file or directory)
error: command 'gcc-4.2' failed with exit status 1
1
  • 1
    Well, the problem is that it's trying to build a PPC binary. In the gcc line, it has "-arch ppc", which would be causing it. No idea how to fix it though. Mar 20, 2011 at 20:15

3 Answers 3

15

This is a better solution that works for all Python C extension building on ALL Python versions on Mac OS X 10.6 using XCode 4.

ARCHFLAGS="-arch i386 -arch x86_64" python setup.py build

This way you don't have to muck around with the setup.py files for all the C extensions you are trying to build.

2
  • Make sure you sudo this May 10, 2011 at 19:05
  • @Jon. That depends. You can install Python packages locally on your own home directory.
    – Y.H Wong
    May 22, 2011 at 12:18
2

As Tony pointed out the issue is PPC related. XCode 4 removed the PPC assembler. Setup tools tries to install for all architectures by default, i386, ppc and x86_64.

I added this code to my pycrypto-2.3 setup.py in line 122 and following. This searches the set compiler options for 'ppc' and removes it and the predecessing '-arch' instruction'.

    # removing PPC flag from compiler options
    index = self.compiler.compiler_so.index('ppc')

    del self.compiler.compiler_so[index]
    del self.compiler.compiler_so[index-1]

Running the usual sudo python setup.py install on the modified file installed pycrypto without a problem.

This is a terrible workaround, but should work for now until setuptools can better detect that 10.6 with XCode 4 no longer has PPC as an applicable target architecture. Suggestions to fix this problem over all are accepted.

1
  • There's a better solution. The hint can be found under /System/Frameworks/Python.framework/Versions/VERSION/lib/PYTHON_VERSION/distutils/sysconfig.py:customize_compiler
    – Y.H Wong
    Mar 22, 2011 at 6:18
1

Another option is to copy back the ppc assemblers from a previous version of xcode. You only have to copy the folders ppc and ppc64 from the location /usr/libexec/gcc/darwin/

I recognize that's also a terrible workaround, but it did work for me!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .