21 # PyMuPDF needs the C++ bindings generated
22 mupdf-cxx = mupdf.override { enableOcr = true; enableCxx = true; enablePython = true; python3 = python; };
23 in buildPythonPackage rec {
26 format = "setuptools";
28 disabled = pythonOlder "3.7";
30 src = fetchFromGitHub {
34 hash = "sha256-60KT5+EGP+s7HD4UIeaf9x2QVNU9IUbC5WKEJbrIBCI=";
49 ] ++ lib.optionals (stdenv.system == "x86_64-darwin") [
53 propagatedBuildInputs = [
58 # force using system MuPDF (must be defined in environment and empty)
59 PYMUPDF_SETUP_MUPDF_BUILD = "";
61 PYMUPDF_MUPDF_LIB = "${lib.getLib mupdf-cxx}/lib";
62 PYMUPDF_MUPDF_INCLUDE = "${lib.getDev mupdf-cxx}/include";
65 # TODO: manually add mupdf rpath until upstream fixes it
66 postInstall = lib.optionalString stdenv.isDarwin ''
67 for lib in */*.so $out/${python.sitePackages}/*/*.so; do
68 install_name_tool -add_rpath ${lib.getLib mupdf-cxx}/lib "$lib"
77 # fails for indeterminate reasons
79 ] ++ lib.optionals stdenv.isDarwin [
80 # darwin does not support OCR right now
84 pythonImportsCheck = [
90 description = "Python bindings for MuPDF's rendering library";
91 homepage = "https://github.com/pymupdf/PyMuPDF";
92 changelog = "https://github.com/pymupdf/PyMuPDF/releases/tag/${version}";
93 license = licenses.agpl3Only;
94 maintainers = with maintainers; [ teto ];
95 platforms = platforms.unix;