Mac OS X install instructions

6,269 views
Skip to first unread message

David Griffin

unread,
Oct 20, 2013, 2:29:57 PM10/20/13
to pytho...@googlegroups.com
So, I wasn't too thrilled with the prospect of having to edit config files to install CFFI, so I've got an alternative that might be worth adding to the documentation. This method uses homebrew, which I assume most OS X developers have installed, and homebrew's libffi which supports pkg-config (although requires an export variable to be set). Simple instructions:

1) Install homebrew: http://brew.sh
2) Run the following commands in a terminal

brew install pkg-config libffi
export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.0.13/lib/pkgconfig/ # May change with libffi version
pip install cffi

And everything should just work, without having to edit config files.


- David Griffin

Armin Rigo

unread,
Oct 21, 2013, 5:46:23 AM10/21/13
to pytho...@googlegroups.com
Hi,

On Sun, Oct 20, 2013 at 8:29 PM, David Griffin <habi...@gmail.com> wrote:
> This method uses homebrew, which I assume most OS X
> developers have installed

Thanks. I have no presumption of assuming what OS/X people commonly
install on their machine, but I've added your instructions to the
docs.


A bientôt,

Armin.

Mark Roberts

unread,
Oct 25, 2013, 1:46:58 PM10/25/13
to pytho...@googlegroups.com
This is fantastic, but I'm a little bit concerned by not using libffi bundled with OSX.  Do you know whether they just outright stopped bundling libffi with OSX or whether it was just moved out of /usr/include (because /usr/include ... disappeared?)

-Mark

David Griffin

unread,
Oct 26, 2013, 12:17:58 AM10/26/13
to pytho...@googlegroups.com
I'm honestly not sure. I believe that (as of Mavericks, and probably before as well) libffi now lives at /usr/lib/libffi.dylib - it might be possible to link against that. However, this would likely have to be done using the other edit config files method because there's no pkg-config data (at least not for libffi; I can see pkg-config data for some files, but I'm pretty certain these are ones I've installed via homebrew).

- David

Mark Roberts

unread,
Oct 27, 2013, 6:03:31 AM10/27/13
to pytho...@googlegroups.com
Hey,

So I rammed my head up against the wall for the last couple of days trying to make this (and pretty much anything else) work for getting cffi support back in Python and pypy.  As it turns out, installing the developer tools (xcode-select --install) and reinstalling python via pyenv just outright worked.  I didn't even have to brew link libffi.  I did continue to have a problem where my path was set incorrectly when using screen but not when not using screen... that appeared to be something related to libexec/pathhelper forcing system paths instead of pyenv.

-Mark

David Griffin

unread,
Nov 18, 2013, 9:54:13 AM11/18/13
to pytho...@googlegroups.com
I can confirm that this works on Mavericks; hence the instructions for Mavericks should be amended to:

xcode-select --install
pip install cffi

For a version of Python from Homebrew (which I tested) and/or Pyenv (Marks instructions).

- David

Ville Nummela

unread,
May 23, 2014, 11:28:48 AM5/23/14
to pytho...@googlegroups.com
Hi all,

For the record: I'm using the Anaconda(1.9.2) Python 2.7 distro on OS X 10.9.3, with xcode 5.1 installed.

I was trying to pip install cffi, but kept getting the error c/_cffi_backend.c:14:10: fatal error: 'ffi.h' file not found.

Finally I found a solution here:

...which is quite close to that of David's, except for the exports. So here's what I did:

Installed homebrew (basically just for this, as it does not support Anaconda), and then

brew install pkg-config libffi
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.0.13/lib/pkgconfig/
pip install cffi
The only problem is, that the lzmaffi library - which is what I need cffi for - still refuses to install:

  File "/Users/ville/anaconda/lib/python2.7/site-packages/cffi/ffiplatform.py", line 50, in _build

    raise VerificationError('%s: %s' % (e.__class__.__name__, e))

This could be due to the use of homebrew somehow, but unfortunately how that might be is not immediately obvious to me...

Regards,

   Ville

Armin Rigo

unread,
May 25, 2014, 10:32:27 AM5/25/14
to pytho...@googlegroups.com
Hi Ville,

On 23 May 2014 17:28, Ville Nummela <ville....@gmail.com> wrote:
> File
> "/Users/ville/anaconda/lib/python2.7/site-packages/cffi/ffiplatform.py",
> line 50, in _build
> raise VerificationError('%s: %s' % (e.__class__.__name__, e))

You will have more chances to get an answer to this question by giving
more details about the error. As reported, it's a bit like saying "I
have written a C program but it doesn't compile! Why?".


A bientôt,

Armin.
Reply all
Reply to author
Forward
0 new messages