at 23.05-pre 1.5 kB view raw
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.1"; 8 9 src = fetchPypi { 10 inherit pname version; 11 sha256 = "sha256-1AC/uaN7E1ElPLQCZxzqfom97MKU6AFqcH9tHYrJNPk="; 12 }; 13 14 buildInputs = [ libffi ]; 15 16 nativeBuildInputs = [ pkg-config ]; 17 18 propagatedBuildInputs = [ pycparser ]; 19 20 postPatch = lib.optionalString stdenv.isDarwin '' 21 # Remove setup.py impurities 22 substituteInPlace setup.py \ 23 --replace "'-iwithsysroot/usr/include/ffi'" "" \ 24 --replace "'/usr/include/ffi'," "" \ 25 --replace '/usr/include/libffi' '${lib.getDev libffi}/include' 26 ''; 27 28 # The tests use -Werror but with python3.6 clang detects some unreachable code. 29 NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang 30 "-Wno-unused-command-line-argument -Wno-unreachable-code -Wno-c++11-narrowing"; 31 32 # Lots of tests fail on aarch64-darwin due to "Cannot allocate write+execute memory": 33 # * https://cffi.readthedocs.io/en/latest/using.html#callbacks 34 doCheck = !stdenv.hostPlatform.isMusl && !(stdenv.isDarwin && stdenv.isAarch64); 35 36 checkInputs = [ pytestCheckHook ]; 37 38 meta = with lib; { 39 maintainers = with maintainers; [ domenkozar lnl7 ]; 40 homepage = "https://cffi.readthedocs.org/"; 41 license = licenses.mit; 42 description = "Foreign Function Interface for Python calling C code"; 43 }; 44}