1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
{
stdenv,
lib,
fetchFromGitHub,
python,
buildPythonPackage,
imagemagick,
pip,
pytestCheckHook,
pymupdf,
fire,
fonttools,
numpy,
opencv4,
tkinter,
python-docx,
}:
let
version = "0.5.8";
in
buildPythonPackage {
pname = "pdf2docx";
inherit version;
format = "setuptools";
src = fetchFromGitHub {
owner = "dothinking";
repo = "pdf2docx";
rev = "refs/tags/v${version}";
hash = "sha256-tMITDm2NkxWS+H/hhd2LlaPbyuI86ZKaALqqHJqb8V0=";
};
nativeBuildInputs = [
pip
imagemagick
];
pythonRemoveDeps = [ "opencv-python" ];
preBuild = "echo '${version}' > version.txt";
propagatedBuildInputs = [
tkinter
pymupdf
fire
fonttools
numpy
opencv4
python-docx
];
postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
# on linux the icon file can only be xbm format
convert $out/${python.sitePackages}/pdf2docx/gui/icon.ico \
$out/${python.sitePackages}/pdf2docx/gui/icon.xbm
substituteInPlace $out/${python.sitePackages}/pdf2docx/gui/App.py \
--replace 'icon.ico' 'icon.xbm' \
--replace 'iconbitmap(icon_path)' "iconbitmap(f'@{icon_path}')"
'';
nativeCheckInputs = [ pytestCheckHook ];
pytestFlagsArray = [
"-v"
"./test/test.py::TestConversion"
];
# Test fails due to "RuntimeError: cannot find builtin font with name 'Arial'":
disabledTests = [ "test_unnamed_fonts" ];
meta = with lib; {
description = "Convert PDF to DOCX";
mainProgram = "pdf2docx";
homepage = "https://github.com/dothinking/pdf2docx";
changelog = "https://github.com/dothinking/pdf2docx/releases/tag/v${version}";
license = licenses.gpl3Only;
maintainers = with maintainers; [ happysalada ];
};
}
|