nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv, buildPythonPackage, isPyPy, fetchPypi, pytestCheckHook,
2 libffi, pkg-config, pycparser
3}:
4
5if isPyPy then null else buildPythonPackage rec {
6 pname = "cffi";
7 version = "1.15.0";
8
9 src = fetchPypi {
10 inherit pname version;
11 sha256 = "920f0d66a896c2d99f0adbb391f990a84091179542c205fa53ce5787aff87954";
12 };
13
14 outputs = [ "out" "dev" ];
15
16 buildInputs = [ libffi ];
17
18 nativeBuildInputs = [ pkg-config ];
19
20 propagatedBuildInputs = [ pycparser ];
21
22 postPatch = lib.optionalString stdenv.isDarwin ''
23 # Remove setup.py impurities
24 substituteInPlace setup.py \
25 --replace "'-iwithsysroot/usr/include/ffi'" "" \
26 --replace "'/usr/include/ffi'," "" \
27 --replace '/usr/include/libffi' '${lib.getDev libffi}/include'
28 '';
29
30 # The tests use -Werror but with python3.6 clang detects some unreachable code.
31 NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang
32 "-Wno-unused-command-line-argument -Wno-unreachable-code -Wno-c++11-narrowing";
33
34 # Lots of tests fail on aarch64-darwin due to "Cannot allocate write+execute memory":
35 # * https://cffi.readthedocs.io/en/latest/using.html#callbacks
36 doCheck = !stdenv.hostPlatform.isMusl && !(stdenv.isDarwin && stdenv.isAarch64);
37
38 checkInputs = [ pytestCheckHook ];
39
40 meta = with lib; {
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";
45 };
46}