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, cryptography
19, pillow
20
21# tests
22, pytestCheckHook
23, pytest-timeout
24}:
25
26buildPythonPackage rec {
27 pname = "pypdf";
28 version = "3.16.0";
29 format = "pyproject";
30
31 src = fetchFromGitHub {
32 owner = "py-pdf";
33 repo = "pypdf";
34 rev = "refs/tags/${version}";
35 # fetch sample files used in tests
36 fetchSubmodules = true;
37 hash = "sha256-vE5ujknMpufBuwWqtjkLegTRe4eDAvBVPCVM6It2pHQ=";
38 };
39
40 outputs = [
41 "out"
42 "doc"
43 ];
44
45 nativeBuildInputs = [
46 flit-core
47
48 # docs
49 sphinxHook
50 sphinx-rtd-theme
51 myst-parser
52 ];
53
54 postPatch = ''
55 substituteInPlace pyproject.toml \
56 --replace "--disable-socket" ""
57 '';
58
59 propagatedBuildInputs = lib.optionals (pythonOlder "3.10") [
60 typing-extensions
61 ];
62
63 passthru.optional-dependencies = rec {
64 full = crypto ++ image;
65 crypto = [
66 cryptography
67 ];
68 image = [
69 pillow
70 ];
71 };
72
73 pythonImportsCheck = [
74 "pypdf"
75 ];
76
77 nativeCheckInputs = [
78 pytestCheckHook
79 pytest-timeout
80 ] ++ passthru.optional-dependencies.full;
81
82 pytestFlagsArray = [
83 # don't access the network
84 "-m" "'not enable_socket'"
85 ];
86
87 disabledTests = [
88 # requires fpdf2 which we don't package yet
89 "test_compression"
90 ];
91
92 meta = with lib; {
93 description = "A pure-python PDF library capable of splitting, merging, cropping, and transforming the pages of PDF files";
94 homepage = "https://github.com/py-pdf/pypdf";
95 changelog = "https://github.com/py-pdf/pypdf/blob/${src.rev}/CHANGELOG.md";
96 license = licenses.bsd3;
97 maintainers = with maintainers; [ hexa ];
98 };
99}