2021-12-26 17:43:05 +00:00
|
|
|
{ lib, stdenv, buildPythonPackage, isPyPy, fetchPypi, pytestCheckHook,
|
|
|
|
libffi, pkg-config, pycparser
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
if isPyPy then null else buildPythonPackage rec {
|
|
|
|
pname = "cffi";
|
2022-08-12 12:06:08 +00:00
|
|
|
version = "1.15.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2022-08-12 12:06:08 +00:00
|
|
|
sha256 = "sha256-1AC/uaN7E1ElPLQCZxzqfom97MKU6AFqcH9tHYrJNPk=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
buildInputs = [ libffi ];
|
|
|
|
|
2021-12-26 17:43:05 +00:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
propagatedBuildInputs = [ pycparser ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
postPatch = lib.optionalString stdenv.isDarwin ''
|
2021-12-26 17:43:05 +00:00
|
|
|
# Remove setup.py impurities
|
2022-04-27 09:35:20 +00:00
|
|
|
substituteInPlace setup.py \
|
|
|
|
--replace "'-iwithsysroot/usr/include/ffi'" "" \
|
|
|
|
--replace "'/usr/include/ffi'," "" \
|
|
|
|
--replace '/usr/include/libffi' '${lib.getDev libffi}/include'
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# The tests use -Werror but with python3.6 clang detects some unreachable code.
|
2021-02-05 17:12:51 +00:00
|
|
|
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang
|
2021-12-26 17:43:05 +00:00
|
|
|
"-Wno-unused-command-line-argument -Wno-unreachable-code -Wno-c++11-narrowing";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-26 17:43:05 +00:00
|
|
|
# Lots of tests fail on aarch64-darwin due to "Cannot allocate write+execute memory":
|
|
|
|
# * https://cffi.readthedocs.io/en/latest/using.html#callbacks
|
|
|
|
doCheck = !stdenv.hostPlatform.isMusl && !(stdenv.isDarwin && stdenv.isAarch64);
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
checkInputs = [ pytestCheckHook ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = with maintainers; [ domenkozar lnl7 ];
|
|
|
|
homepage = "https://cffi.readthedocs.org/";
|
2021-02-05 17:12:51 +00:00
|
|
|
license = licenses.mit;
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Foreign Function Interface for Python calling C code";
|
|
|
|
};
|
|
|
|
}
|