at 24.11-pre 2.4 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 isPyPy, 6 fetchPypi, 7 setuptools, 8 pytestCheckHook, 9 libffi, 10 pkg-config, 11 pycparser, 12 pythonAtLeast, 13}: 14 15if isPyPy then 16 null 17else 18 buildPythonPackage rec { 19 pname = "cffi"; 20 version = "1.16.0"; 21 pyproject = true; 22 23 src = fetchPypi { 24 inherit pname version; 25 hash = "sha256-vLPvQ+WGZbvaL7GYaY/K5ndkg+DEpjGqVkeAbCXgLMA="; 26 }; 27 28 patches = 29 [ 30 # 31 # Trusts the libffi library inside of nixpkgs on Apple devices. 32 # 33 # Based on some analysis I did: 34 # 35 # https://groups.google.com/g/python-cffi/c/xU0Usa8dvhk 36 # 37 # I believe that libffi already contains the code from Apple's fork that is 38 # deemed safe to trust in cffi. 39 # 40 ./darwin-use-libffi-closures.diff 41 ] 42 ++ lib.optionals (stdenv.cc.isClang && lib.versionAtLeast (lib.getVersion stdenv.cc) "13") [ 43 # -Wnull-pointer-subtraction is enabled with -Wextra. Suppress it to allow the following tests 44 # to run and pass when cffi is built with newer versions of clang: 45 # - testing/cffi1/test_verify1.py::test_enum_usage 46 # - testing/cffi1/test_verify1.py::test_named_pointer_as_argument 47 ./clang-pointer-substraction-warning.diff 48 ]; 49 50 postPatch = lib.optionalString stdenv.isDarwin '' 51 # Remove setup.py impurities 52 substituteInPlace setup.py \ 53 --replace "'-iwithsysroot/usr/include/ffi'" "" \ 54 --replace "'/usr/include/ffi'," "" \ 55 --replace '/usr/include/libffi' '${lib.getDev libffi}/include' 56 ''; 57 58 nativeBuildInputs = [ 59 pkg-config 60 setuptools 61 ]; 62 63 buildInputs = [ libffi ]; 64 65 propagatedBuildInputs = [ pycparser ]; 66 67 # The tests use -Werror but with python3.6 clang detects some unreachable code. 68 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-unused-command-line-argument -Wno-unreachable-code -Wno-c++11-narrowing"; 69 70 doCheck = !stdenv.hostPlatform.isMusl; 71 72 nativeCheckInputs = [ pytestCheckHook ]; 73 74 meta = with lib; { 75 changelog = "https://github.com/python-cffi/cffi/releases/tag/v${version}"; 76 description = "Foreign Function Interface for Python calling C code"; 77 downloadPage = "https://github.com/python-cffi/cffi"; 78 homepage = "https://cffi.readthedocs.org/"; 79 license = licenses.mit; 80 maintainers = teams.python.members; 81 }; 82 }