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