1{ lib, stdenv
2, fetchFromGitHub
3, fetchpatch
4, buildPythonPackage
5, isPyPy
6, pkgs
7, python
8, six
9}:
10
11buildPythonPackage rec {
12 pname = "pyparted";
13 version = "3.12.0";
14 disabled = isPyPy;
15
16 src = fetchFromGitHub {
17 repo = pname;
18 owner = "dcantrell";
19 rev = "v${version}";
20 hash = "sha256-LfBLR0A/wnfBtXISAAY6Nl4vnk1rtY03F+PT8UIMrEs=";
21 };
22
23 postPatch = ''
24 sed -i -e 's|mke2fs|${pkgs.e2fsprogs}/bin/mke2fs|' tests/baseclass.py
25 sed -i -e '
26 s|e\.path\.startswith("/tmp/temp-device-")|"temp-device-" in e.path|
27 ' tests/test__ped_ped.py
28 '' + lib.optionalString stdenv.isi686 ''
29 # remove some integers in this test case which overflow on 32bit systems
30 sed -i -r -e '/class *UnitGetSizeTestCase/,/^$/{/[0-9]{11}/d}' \
31 tests/test__ped_ped.py
32 '';
33
34 patches = [
35 ./fix-test-pythonpath.patch
36 (fetchpatch {
37 url = "https://github.com/dcantrell/pyparted/commit/07ba882d04fa2099b53d41370416b97957d2abcb.patch";
38 hash = "sha256-yYfLdy+TOKfN3gtTMgOWPebPTRYyaOYh/yFTowCbdjg=";
39 })
40 (fetchpatch {
41 url = "https://github.com/dcantrell/pyparted/commit/a01b4eeecf63b0580c192c7c2db7a5c406a7ad6d.patch";
42 hash = "sha256-M/8hYiKUBzaTOxPYDFK5BAvCm6WJGx+693qwj3HzdRA=";
43 })
44 ];
45
46 preConfigure = ''
47 PATH="${pkgs.parted}/sbin:$PATH"
48 '';
49
50 nativeBuildInputs = [ pkgs.pkg-config ];
51 nativeCheckInputs = [ six ];
52 propagatedBuildInputs = [ pkgs.parted ];
53
54 checkPhase = ''
55 patchShebangs Makefile
56 make test PYTHON=${python.executable}
57 '';
58
59 meta = with lib; {
60 homepage = "https://github.com/dcantrell/pyparted/";
61 description = "Python interface for libparted";
62 license = licenses.gpl2Plus;
63 platforms = platforms.linux;
64 maintainers = with maintainers; [ lsix ];
65 };
66}