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