1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, isPy3k
5, cryptography
6, charset-normalizer
7, pythonOlder
8, typing-extensions
9, pytestCheckHook
10, ocrmypdf
11}:
12
13buildPythonPackage rec {
14 pname = "pdfminer-six";
15 version = "20221105";
16 format = "setuptools";
17
18 disabled = !isPy3k;
19
20 src = fetchFromGitHub {
21 owner = "pdfminer";
22 repo = "pdfminer.six";
23 rev = version;
24 hash = "sha256-OyEeQBuYfj4iEcRt2/daSaUfTOjCVSCyHW2qffal+Bk=";
25 };
26
27 propagatedBuildInputs = [
28 charset-normalizer
29 cryptography
30 ] ++ lib.optionals (pythonOlder "3.8") [ typing-extensions ];
31
32 postInstall = ''
33 for file in $out/bin/*.py; do
34 ln $file ''${file//.py/}
35 done
36 '';
37
38 postPatch = ''
39 # Version is not stored in repo, gets added by a GitHub action after tag is created
40 # https://github.com/pdfminer/pdfminer.six/pull/727
41 substituteInPlace pdfminer/__init__.py --replace "__VERSION__" ${version}
42 '';
43
44 pythonImportsCheck = [
45 "pdfminer"
46 "pdfminer.high_level"
47 ];
48
49 nativeCheckInputs = [
50 pytestCheckHook
51 ];
52
53 passthru = {
54 tests = {
55 inherit ocrmypdf;
56 };
57 };
58
59 meta = with lib; {
60 description = "PDF parser and analyzer";
61 homepage = "https://github.com/pdfminer/pdfminer.six";
62 license = licenses.mit;
63 maintainers = with maintainers; [ psyanticy marsam ];
64 };
65}