depot/third_party/nixpkgs/pkgs/development/python-modules/pypdf/default.nix
Default email bcb2f287e1 Project import generated by Copybara.
GitOrigin-RevId: d603719ec6e294f034936c0d0dc06f689d91b6c3
2024-06-20 20:27:18 +05:30

90 lines
1.7 KiB
Nix

{
lib,
buildPythonPackage,
fetchFromGitHub,
pythonOlder,
# build-system
flit-core,
# docs
sphinxHook,
sphinx-rtd-theme,
myst-parser,
# propagates
typing-extensions,
# optionals
cryptography,
pillow,
# tests
fpdf2,
pytestCheckHook,
pytest-timeout,
}:
buildPythonPackage rec {
pname = "pypdf";
version = "4.2.0";
format = "pyproject";
src = fetchFromGitHub {
owner = "py-pdf";
repo = "pypdf";
rev = "refs/tags/${version}";
# fetch sample files used in tests
fetchSubmodules = true;
hash = "sha256-ksLpxfRxrNVXezF0VjbAqadpF6bv/SAOOnCKabhugo0=";
};
outputs = [
"out"
"doc"
];
nativeBuildInputs = [
flit-core
# docs
sphinxHook
sphinx-rtd-theme
myst-parser
];
postPatch = ''
substituteInPlace pyproject.toml \
--replace "--disable-socket" ""
'';
propagatedBuildInputs = lib.optionals (pythonOlder "3.10") [ typing-extensions ];
passthru.optional-dependencies = rec {
full = crypto ++ image;
crypto = [ cryptography ];
image = [ pillow ];
};
pythonImportsCheck = [ "pypdf" ];
nativeCheckInputs = [
(fpdf2.overridePythonAttrs { doCheck = false; }) # avoid reference loop
pytestCheckHook
pytest-timeout
] ++ passthru.optional-dependencies.full;
pytestFlagsArray = [
# don't access the network
"-m"
"'not enable_socket'"
];
meta = with lib; {
description = "Pure-python PDF library capable of splitting, merging, cropping, and transforming the pages of PDF files";
homepage = "https://github.com/py-pdf/pypdf";
changelog = "https://github.com/py-pdf/pypdf/blob/${src.rev}/CHANGELOG.md";
license = licenses.bsd3;
maintainers = with maintainers; [ javaes ];
};
}