5

I'm trying to install AMFAST in a virtual_env location based on a dependencies file. I have export ARCHFLAGS="-arch x86_64" in my local .profile, and have confirmed its presence by running env and seeing it listed. However, whenever I run PIP targeting the virtual environment, gcc is set to target i386 and ppc. I've also tried prepending env ARCHFLAGS="-arch i386 -arch x86_64" and env ARCHFLAGS="-arch x86_64" to the PIP command, but gcc always has the flags -arch i386 -arch ppc -arch x86_64. How can I get gcc to read my archflags?

example:

sudo pip install -E ~/Documents/project/project_env -r ~/Documents/project/trunk/django/dependencies.txt`  

output
...

Running setup.py install for amfast  
  building 'amfast.encode' extension  
  gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c amfast/ext_src/encoder.c -o build/temp.macosx-10.6-universal-2.6/amfast/ext_src/encoder.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
  amfast/ext_src/encoder.c:2121: fatal error: error writing to -: Broken pipe
  compilation terminated.
  lipo: can't open input file: /var/tmp//ccoYlfhN.out (No such file or directory)
  error: command 'gcc-4.2' failed with exit status 1
selfsimilar
  • 1,397
  • 2
  • 18
  • 31

1 Answers1

14

Most likely the problem is that the ARCHFLAGS environment variable is not being passed through by sudo. By default, some versions of sudo filter out most env variables as a security measure (see man sudo). Try running it this way:

sudo ARCHFLAGS="-arch x86_64" pip install -E ~/Documents/project/project_env -r ~/Documents/project/trunk/django/dependencies.txt`
Ned Deily
  • 83,389
  • 16
  • 128
  • 151
  • 1
    if you don't mind the security implications, you can add a line to /etc/sudoers by running "sudo visudo" and after the lines with Defaults env_keep += "..." add the line Defaults env_keep += "ARCHFLAGS" . This way the ARCHFLAGS will be preserved by sudo. – blootsvoets Nov 05 '14 at 16:16