2022-10-21 18:38:19 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
2024-05-15 15:35:15 +00:00
|
|
|
, fetchpatch2
|
2024-04-21 15:54:59 +00:00
|
|
|
, cython_0
|
2022-10-21 18:38:19 +00:00
|
|
|
, zfs
|
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "py-libzfs";
|
2024-05-15 15:35:15 +00:00
|
|
|
version = "24.04.0";
|
2024-01-02 11:29:13 +00:00
|
|
|
format = "setuptools";
|
2022-10-21 18:38:19 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "truenas";
|
|
|
|
repo = pname;
|
|
|
|
rev = "TS-${version}";
|
2024-05-15 15:35:15 +00:00
|
|
|
hash = "sha256-Uiu0RNE06++iNWUNcKpbZvreT2D7/EqHlFZJXKe3F4A=";
|
2022-10-21 18:38:19 +00:00
|
|
|
};
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
patches = [
|
|
|
|
(fetchpatch2 {
|
|
|
|
url = "https://github.com/truenas/py-libzfs/commit/b5ffe1f1d6097df6e2f5cc6dd3c968872ec60804.patch";
|
|
|
|
hash = "sha256-6r5hQ/o7c4vq4Tfh0l1WbeK3AuPvi+1wzkwkIn1qEes=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
nativeBuildInputs = [ cython_0 ];
|
2022-10-21 18:38:19 +00:00
|
|
|
buildInputs = [ zfs ];
|
|
|
|
|
|
|
|
# Passing CFLAGS in configureFlags does not work, see https://github.com/truenas/py-libzfs/issues/107
|
|
|
|
postPatch = lib.optionalString stdenv.isLinux ''
|
|
|
|
substituteInPlace configure \
|
|
|
|
--replace \
|
|
|
|
'CFLAGS="-DCYTHON_FALLTHROUGH"' \
|
|
|
|
'CFLAGS="-DCYTHON_FALLTHROUGH -I${zfs.dev}/include/libzfs -I${zfs.dev}/include/libspl"' \
|
|
|
|
--replace 'zof=false' 'zof=true'
|
|
|
|
'';
|
|
|
|
|
|
|
|
pythonImportsCheck = [ "libzfs" ];
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Python libzfs bindings";
|
|
|
|
homepage = "https://github.com/truenas/py-libzfs";
|
|
|
|
license = licenses.bsd2;
|
|
|
|
maintainers = with maintainers; [ chuangzhu ];
|
|
|
|
# The project also supports macOS (OpenZFS on OSX, O3X), FreeBSD and OpenSolaris
|
|
|
|
# I don't have a machine to test out, thus only packaged for Linux
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|