1 { lib, stdenv, buildPythonPackage, isPyPy, fetchPypi, libffi, pycparser, pytest }:
3 if isPyPy then null else buildPythonPackage rec {
9 sha256 = "fd78e5fee591709f32ef6edb9a015b4aa1a5022598e36227500c8f4e02328d9c";
12 outputs = [ "out" "dev" ];
14 propagatedBuildInputs = [ libffi pycparser ];
15 checkInputs = [ pytest ];
17 # On Darwin, the cffi tests want to hit libm a lot, and look for it in a global
18 # impure search path. It's obnoxious how much repetition there is, and how difficult
19 # it is to get it to search somewhere else (since we do actually have a libm symlink in libSystem)
20 prePatch = lib.optionalString stdenv.isDarwin ''
21 substituteInPlace testing/cffi0/test_parsing.py \
22 --replace 'lib_m = "m"' 'lib_m = "System"' \
23 --replace '"libm" in name' '"libSystem" in name'
24 substituteInPlace testing/cffi0/test_unicode_literals.py --replace 'lib_m = "m"' 'lib_m = "System"'
25 substituteInPlace testing/cffi0/test_zdistutils.py --replace 'self.lib_m = "m"' 'self.lib_m = "System"'
26 substituteInPlace testing/cffi1/test_recompiler.py --replace 'lib_m = "m"' 'lib_m = "System"'
27 substituteInPlace testing/cffi0/test_function.py --replace "lib_m = 'm'" "lib_m = 'System'"
28 substituteInPlace testing/cffi0/test_verify.py --replace "lib_m = ['m']" "lib_m = ['System']"
31 # The tests use -Werror but with python3.6 clang detects some unreachable code.
32 NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang
33 "-Wno-unused-command-line-argument -Wno-unreachable-code";
35 doCheck = !stdenv.hostPlatform.isMusl && !stdenv.isDarwin; # TODO: Investigate
37 py.test -k "not test_char_pointer_conversion"
41 maintainers = with maintainers; [ domenkozar lnl7 ];
42 homepage = "https://cffi.readthedocs.org/";
43 license = licenses.mit;
44 description = "Foreign Function Interface for Python calling C code";