summary refs log tree commit diff
path: root/pkgs/development/python-modules/cffi
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2021-10-11 22:05:28 +0200
committerJonathan Ringer <jonringer@users.noreply.github.com>2021-11-24 15:17:13 -0800
commit169c34a6a7af67bf9fed7cf596af226339af79b1 (patch)
tree6a581ce32f9a902b3cccec053f86664b92f84d74 /pkgs/development/python-modules/cffi
parent54b5495e4e632aa5797b04509acc93baf8800580 (diff)
downloadnixpkgs-169c34a6a7af67bf9fed7cf596af226339af79b1.tar
nixpkgs-169c34a6a7af67bf9fed7cf596af226339af79b1.tar.gz
nixpkgs-169c34a6a7af67bf9fed7cf596af226339af79b1.tar.bz2
nixpkgs-169c34a6a7af67bf9fed7cf596af226339af79b1.tar.lz
nixpkgs-169c34a6a7af67bf9fed7cf596af226339af79b1.tar.xz
nixpkgs-169c34a6a7af67bf9fed7cf596af226339af79b1.tar.zst
nixpkgs-169c34a6a7af67bf9fed7cf596af226339af79b1.zip
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.
Diffstat (limited to 'pkgs/development/python-modules/cffi')
-rw-r--r--pkgs/development/python-modules/cffi/default.nix10
1 files changed, 9 insertions, 1 deletions
diff --git a/pkgs/development/python-modules/cffi/default.nix b/pkgs/development/python-modules/cffi/default.nix
index e5e5e90b043..3092ebec23f 100644
--- a/pkgs/development/python-modules/cffi/default.nix
+++ b/pkgs/development/python-modules/cffi/default.nix
@@ -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.