at 25.11-pre 1.8 kB view raw
1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 pythonOlder, 6 7 # build-system 8 flit-core, 9 10 # docs 11 sphinxHook, 12 sphinx-rtd-theme, 13 myst-parser, 14 15 # propagates 16 typing-extensions, 17 18 # optionals 19 cryptography, 20 pillow, 21 22 # tests 23 fpdf2, 24 pytestCheckHook, 25 pytest-timeout, 26}: 27 28buildPythonPackage rec { 29 pname = "pypdf"; 30 version = "5.4.0"; 31 pyproject = true; 32 33 disabled = pythonOlder "3.8"; 34 35 src = fetchFromGitHub { 36 owner = "py-pdf"; 37 repo = "pypdf"; 38 tag = version; 39 # fetch sample files used in tests 40 fetchSubmodules = true; 41 hash = "sha256-Do697G3CH3itIF+LFFr7h+mohIuzx2JZpGPnbVQ3sOw="; 42 }; 43 44 outputs = [ 45 "out" 46 "doc" 47 ]; 48 49 postPatch = '' 50 substituteInPlace pyproject.toml \ 51 --replace-fail "--disable-socket" "" 52 ''; 53 54 build-system = [ flit-core ]; 55 56 nativeBuildInputs = [ 57 sphinxHook 58 sphinx-rtd-theme 59 myst-parser 60 ]; 61 62 dependencies = lib.optionals (pythonOlder "3.11") [ typing-extensions ]; 63 64 optional-dependencies = rec { 65 full = crypto ++ image; 66 crypto = [ cryptography ]; 67 image = [ pillow ]; 68 }; 69 70 pythonImportsCheck = [ "pypdf" ]; 71 72 nativeCheckInputs = [ 73 (fpdf2.overridePythonAttrs { doCheck = false; }) # avoid reference loop 74 pytestCheckHook 75 pytest-timeout 76 ] ++ optional-dependencies.full; 77 78 pytestFlagsArray = [ 79 # don't access the network 80 "-m" 81 "'not enable_socket'" 82 ]; 83 84 meta = with lib; { 85 description = "Pure-python PDF library capable of splitting, merging, cropping, and transforming the pages of PDF files"; 86 homepage = "https://github.com/py-pdf/pypdf"; 87 changelog = "https://github.com/py-pdf/pypdf/blob/${src.tag}/CHANGELOG.md"; 88 license = licenses.bsd3; 89 maintainers = with maintainers; [ javaes ]; 90 }; 91}