Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at domenkozar-patch-1 73 lines 2.1 kB view raw
1{ lib 2, stdenv 3, buildPythonPackage 4, isPyPy 5, fetchPypi 6, fetchpatch 7, pytestCheckHook 8, libffi 9, pkg-config 10, pycparser 11, pythonAtLeast 12}: 13 14if isPyPy then null else buildPythonPackage rec { 15 pname = "cffi"; 16 version = "1.15.1"; 17 18 src = fetchPypi { 19 inherit pname version; 20 sha256 = "sha256-1AC/uaN7E1ElPLQCZxzqfom97MKU6AFqcH9tHYrJNPk="; 21 }; 22 23 patches = [ 24 # 25 # Trusts the libffi library inside of nixpkgs on Apple devices. 26 # 27 # Based on some analysis I did: 28 # 29 # https://groups.google.com/g/python-cffi/c/xU0Usa8dvhk 30 # 31 # I believe that libffi already contains the code from Apple's fork that is 32 # deemed safe to trust in cffi. 33 # 34 ./darwin-use-libffi-closures.diff 35 ] ++ lib.optionals (pythonAtLeast "3.11") [ 36 # Fix test that failed because python seems to have changed the exception format in the 37 # final release. This patch should be included in the next version and can be removed when 38 # it is released. 39 (fetchpatch { 40 url = "https://foss.heptapod.net/pypy/cffi/-/commit/8a3c2c816d789639b49d3ae867213393ed7abdff.diff"; 41 sha256 = "sha256-3wpZeBqN4D8IP+47QDGK7qh/9Z0Ag4lAe+H0R5xCb1E="; 42 }) 43 ]; 44 45 postPatch = lib.optionalString stdenv.isDarwin '' 46 # Remove setup.py impurities 47 substituteInPlace setup.py \ 48 --replace "'-iwithsysroot/usr/include/ffi'" "" \ 49 --replace "'/usr/include/ffi'," "" \ 50 --replace '/usr/include/libffi' '${lib.getDev libffi}/include' 51 ''; 52 53 buildInputs = [ libffi ]; 54 55 nativeBuildInputs = [ pkg-config ]; 56 57 propagatedBuildInputs = [ pycparser ]; 58 59 # The tests use -Werror but with python3.6 clang detects some unreachable code. 60 NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang 61 "-Wno-unused-command-line-argument -Wno-unreachable-code -Wno-c++11-narrowing"; 62 63 doCheck = !stdenv.hostPlatform.isMusl; 64 65 checkInputs = [ pytestCheckHook ]; 66 67 meta = with lib; { 68 maintainers = with maintainers; [ domenkozar lnl7 ]; 69 homepage = "https://cffi.readthedocs.org/"; 70 license = licenses.mit; 71 description = "Foreign Function Interface for Python calling C code"; 72 }; 73}