cffi: Include pkg-config

The build was falling back on impure paths because pkg-config was
missing. This caused a mismatch between headers picked up at
compile-time and run-time, specifically `ffi.h` from libffi and then one
in `/usr/include/ffi` on macOS.
This commit is contained in:
toonn 2021-10-11 22:05:28 +02:00 committed by Jonathan Ringer
parent 54b5495e4e
commit 169c34a6a7

View file

@ -1,4 +1,6 @@
{ lib, stdenv, buildPythonPackage, isPyPy, fetchPypi, libffi, pycparser, pytestCheckHook }:
{ lib, stdenv, buildPythonPackage, isPyPy, fetchPypi, pytestCheckHook,
libffi, pkg-config, pycparser
}:
if isPyPy then null else buildPythonPackage rec {
pname = "cffi";
@ -13,9 +15,15 @@ if isPyPy then null else buildPythonPackage rec {
buildInputs = [ libffi ];
nativeBuildInputs = [ pkg-config ];
propagatedBuildInputs = [ pycparser ];
prePatch = lib.optionalString stdenv.isDarwin ''
# Remove setup.py impurities
substituteInPlace setup.py --replace "'-iwithsysroot/usr/include/ffi'" ""
substituteInPlace setup.py --replace "'/usr/include/ffi'," ""
substituteInPlace setup.py --replace '/usr/include/libffi' '${lib.getDev libffi}/include'
'';
# The tests use -Werror but with python3.6 clang detects some unreachable code.