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