Author: Marc Abramowitz <[email protected]>
Branch: osx_use_homebrew
Changeset: r1642:86f07caeaaf0
Date: 2015-01-27 17:12 -0800
http://bitbucket.org/cffi/cffi/changeset/86f07caeaaf0/
Log: OS X with Homebrew: set PKG_CONFIG_PATH
so that it automatically finds a Homebrew-installed libffi
Without this, I get:
[marca@marca-mac2 cffi]$ python setup.py build Package
libffi was not found in the pkg-config search path. Perhaps you
should add the directory containing `libffi.pc' to the
PKG_CONFIG_PATH environment variable No package 'libffi' found
... /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -g
-DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64
-I/usr/include/ffi -I/usr/include/libffi -I/Library/Frameworks/Pytho
n.framework/Versions/2.7/include/python2.7 -c c/_cffi_backend.c -o
build/temp.macosx-10.6-intel-2.7/c/_cffi_backend.o
c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found
#include <ffi.h> ^ 1 error generated. error:
command '/usr/bin/clang' failed with exit status 1
With this, I get:
[marca@marca-mac2 cffi]$ python setup.py build_ext -i ...
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -g -DNDEBUG
-g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64
-I/usr/local/Cellar/libffi/3.0.13/lib/libffi-3.0.13/include -I/Libra
ry/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c
c/_cffi_backend.c -o
build/temp.macosx-10.6-intel-2.7/c/_cffi_backend.o creating
build/lib.macosx-10.6-intel-2.7 /usr/bin/clang -bundle
-undefined dynamic_lookup -g -arch x86_64
build/temp.macosx-10.6-intel-2.7/c/_cffi_backend.o
-L/usr/local/Cellar/libffi/3.0.13/lib -lffi -o
build/lib.macosx-10.6-intel-2.7/_cffi_backend.so copying
build/lib.macosx-10.6-intel-2.7/_cffi_backend.so -> [marca
@marca-mac2 cffi]$ ls -l _cffi_backend.so
-rwxr-xr-x+ 1 marca staff 99844 Jan 27 17:11 _cffi_backend.so*
[marca@marca-mac2 cffi]$ python -c "import _cffi_backend;
print(_cffi_backend)" <module '_cffi_backend' from
'_cffi_backend.so'>
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -66,12 +66,24 @@
sys.stderr.write("The above error message can be safely ignored\n")
def use_pkg_config():
+ if sys.platform == 'darwin' and os.path.exists('/usr/local/bin/brew'):
+ use_homebrew_for_libffi()
+
_ask_pkg_config(include_dirs, '--cflags-only-I', '-I', sysroot=True)
_ask_pkg_config(extra_compile_args, '--cflags-only-other')
_ask_pkg_config(library_dirs, '--libs-only-L', '-L', sysroot=True)
_ask_pkg_config(extra_link_args, '--libs-only-other')
_ask_pkg_config(libraries, '--libs-only-l', '-l')
+def use_homebrew_for_libffi():
+ # We can build by setting:
+ # PKG_CONFIG_PATH = $(brew --prefix libffi)/lib/pkgconfig
+ with os.popen('brew --prefix libffi') as brew_prefix_cmd:
+ prefix = brew_prefix_cmd.read().strip()
+ pkgconfig = os.path.join(prefix, 'lib', 'pkgconfig')
+ os.environ['PKG_CONFIG_PATH'] = (
+ os.environ.get('PKG_CONFIG_PATH', '') + ':' + pkgconfig)
+
if sys.platform == 'win32':
COMPILE_LIBFFI = 'c/libffi_msvc' # from the CPython distribution
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit