Merge pull request #307098 from r-ryantm/auto-update/cilium-cli
[NixPkgs.git] / pkgs / development / python-modules / pypdf / default.nix
blob5e48ca58781c1cd557d7e4d0ef46a5de79875e6c
1 { lib
2 , buildPythonPackage
3 , fetchFromGitHub
4 , fetchpatch2
5 , pythonOlder
7 # build-system
8 , flit-core
10 # docs
11 , sphinxHook
12 , sphinx-rtd-theme
13 , myst-parser
15 # propagates
16 , typing-extensions
18 # optionals
19 , cryptography
20 , pillow
22 # tests
23 , fpdf2
24 , pytestCheckHook
25 , pytest-timeout
28 buildPythonPackage rec {
29   pname = "pypdf";
30   version = "4.1.0";
31   format = "pyproject";
33   src = fetchFromGitHub {
34     owner = "py-pdf";
35     repo = "pypdf";
36     rev = "refs/tags/${version}";
37     # fetch sample files used in tests
38     fetchSubmodules = true;
39     hash = "sha256-Z3flDC102FwEaNtef0YAfmAFSxpimQNyxt9tRfpKueg=";
40   };
42   patches = [
43     (fetchpatch2 {
44       # add missing test marker on networked test
45       url = "https://github.com/py-pdf/pypdf/commit/f43268734a529d4098e6258bf346148fd24c54f0.patch";
46       includes = [
47         "tests/test_generic.py"
48       ];
49       hash = "sha256-Ow32UB4crs3OgT+AmA9TNmcO5Y9SoSahybzD3AmWmVk=";
50     })
51   ];
53   outputs = [
54     "out"
55     "doc"
56   ];
58   nativeBuildInputs = [
59     flit-core
61     # docs
62     sphinxHook
63     sphinx-rtd-theme
64     myst-parser
65   ];
67   postPatch = ''
68     substituteInPlace pyproject.toml \
69       --replace "--disable-socket" ""
70   '';
72   propagatedBuildInputs = lib.optionals (pythonOlder "3.10") [
73     typing-extensions
74   ];
76   passthru.optional-dependencies = rec {
77     full = crypto ++ image;
78     crypto = [
79       cryptography
80     ];
81     image = [
82       pillow
83     ];
84   };
86   pythonImportsCheck = [
87     "pypdf"
88   ];
90   nativeCheckInputs = [
91     (fpdf2.overridePythonAttrs { doCheck = false; })  # avoid reference loop
92     pytestCheckHook
93     pytest-timeout
94   ] ++ passthru.optional-dependencies.full;
96   pytestFlagsArray = [
97     # don't access the network
98     "-m" "'not enable_socket'"
99   ];
101   disabledTests = [
102     # requires fpdf2 which we don't package yet
103     "test_compression"
104     # infinite recursion when including fpdf2
105     "test_merging_many_temporary_files"
106   ];
108   meta = with lib; {
109     description = "A pure-python PDF library capable of splitting, merging, cropping, and transforming the pages of PDF files";
110     homepage = "https://github.com/py-pdf/pypdf";
111     changelog = "https://github.com/py-pdf/pypdf/blob/${src.rev}/CHANGELOG.md";
112     license = licenses.bsd3;
113     maintainers = with maintainers; [ ];
114   };