1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 liberasurecode,
7 six,
8}:
9
10buildPythonPackage rec {
11 pname = "pyeclib";
12 version = "unstable-2022-03-11";
13 format = "setuptools";
14
15 src = fetchFromGitHub {
16 owner = "openstack";
17 repo = "pyeclib";
18 rev = "b50040969a03f7566ffcb468336e875d21486113";
19 hash = "sha256-nYYjocStC0q/MC6pum3J4hlXiu/R5xODwIE97Ho3iEY=";
20 };
21
22 postPatch = ''
23 # patch dlopen call
24 substituteInPlace src/c/pyeclib_c/pyeclib_c.c \
25 --replace "liberasurecode.so" "${liberasurecode}/lib/liberasurecode.so"
26 # python's platform.platform() doesn't return "Darwin" (anymore?)
27 substituteInPlace setup.py \
28 --replace '"Darwin"' '"macOS"'
29 '';
30
31 preBuild =
32 let
33 ldLibraryPathEnvName = if stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH";
34 in
35 ''
36 # required for the custom _find_library function in setup.py
37 export ${ldLibraryPathEnvName}="${lib.makeLibraryPath [ liberasurecode ]}"
38 '';
39
40 buildInputs = [ liberasurecode ];
41
42 nativeCheckInputs = [ six ];
43
44 pythonImportsCheck = [ "pyeclib" ];
45
46 meta = with lib; {
47 description = "This library provides a simple Python interface for implementing erasure codes.";
48 homepage = "https://github.com/openstack/pyeclib";
49 license = licenses.bsd2;
50 maintainers = teams.openstack.members;
51 };
52}