diff --git a/pkgs/development/python-modules/ghostscript/default.nix b/pkgs/development/python-modules/ghostscript/default.nix new file mode 100644 index 000000000000..34d88bd2c91d --- /dev/null +++ b/pkgs/development/python-modules/ghostscript/default.nix @@ -0,0 +1,63 @@ +{ + stdenv, + lib, + buildPythonPackage, + fetchFromGitLab, + pytestCheckHook, + + setuptools, + + ghostscript_headless, +}: + +buildPythonPackage rec { + pname = "ghostscript"; + version = "0.7"; + pyproject = true; + + src = fetchFromGitLab { + owner = "pdftools"; + repo = "python-ghostscript"; + tag = "v${version}"; + hash = "sha256-yBJuAnLK/4YDU9PBsSWPQay4pDws3bP+3rCplysq41w="; + }; + + postPatch = + let + extLib = stdenv.hostPlatform.extensions.sharedLibrary; + in + '' + substituteInPlace ghostscript/__init__.py \ + --replace-fail '__version__ = gs.__version__' '__version__ = "${version}"' + + substituteInPlace ghostscript/_gsprint.py \ + --replace-fail 'cdll.LoadLibrary("libgs.so")' 'cdll.LoadLibrary("${lib.getLib ghostscript_headless}/lib/libgs${extLib}")' + ''; + + build-system = [ + setuptools + ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + disabledTests = [ + # Some tests don't (fully) match anymore. + # Not sure if ghostscript ever promised to keep producing the same outputs, bit-by-bit… + "test_simple" + "test_unicode_arguments" + "test_run_string" + "test_stdin" + ]; + + pythonImportsCheck = [ "ghostscript" ]; + + meta = { + description = "Interface to the Ghostscript C-API using ctypes."; + homepage = "https://gitlab.com/pdftools/python-ghostscript"; + changelog = "https://gitlab.com/pdftools/python-ghostscript/-/blob/v${version}/CHANGES.txt"; + license = lib.licenses.gpl3Plus; + maintainers = with lib.maintainers; [ flokli ]; + }; +} diff --git a/pkgs/development/python-modules/img2pdf/default.nix b/pkgs/development/python-modules/img2pdf/default.nix index 1d29ce17352a..08f676729163 100644 --- a/pkgs/development/python-modules/img2pdf/default.nix +++ b/pkgs/development/python-modules/img2pdf/default.nix @@ -1,5 +1,6 @@ { lib, + pkgs, buildPythonPackage, fetchFromGitea, fetchpatch, @@ -10,7 +11,6 @@ pillow, stdenv, exiftool, - ghostscript, imagemagick, mupdf-headless, netpbm, @@ -67,7 +67,7 @@ buildPythonPackage rec { nativeCheckInputs = [ exiftool - ghostscript + pkgs.ghostscript imagemagick mupdf-headless netpbm diff --git a/pkgs/development/python-modules/pdfplumber/default.nix b/pkgs/development/python-modules/pdfplumber/default.nix index 5130c287c9c1..3678634fd942 100644 --- a/pkgs/development/python-modules/pdfplumber/default.nix +++ b/pkgs/development/python-modules/pdfplumber/default.nix @@ -1,8 +1,8 @@ { lib, + pkgs, buildPythonPackage, fetchFromGitHub, - ghostscript, jupyterlab, nbexec, pandas, @@ -42,7 +42,7 @@ buildPythonPackage rec { ''; nativeCheckInputs = [ - ghostscript + pkgs.ghostscript jupyterlab nbexec pandas diff --git a/pkgs/development/python-modules/pydyf/default.nix b/pkgs/development/python-modules/pydyf/default.nix index 46a001bb1c26..8f9b12f17c0a 100644 --- a/pkgs/development/python-modules/pydyf/default.nix +++ b/pkgs/development/python-modules/pydyf/default.nix @@ -1,9 +1,9 @@ { + pkgs, lib, buildPythonPackage, fetchPypi, flit-core, - ghostscript, pillow, pytestCheckHook, pytest-cov-stub, @@ -30,7 +30,7 @@ buildPythonPackage rec { nativeBuildInputs = [ flit-core ]; nativeCheckInputs = [ - ghostscript + pkgs.ghostscript pillow pytestCheckHook pytest-cov-stub diff --git a/pkgs/development/python-modules/weasyprint/default.nix b/pkgs/development/python-modules/weasyprint/default.nix index 36824cdcc2ff..696bee47ac5f 100644 --- a/pkgs/development/python-modules/weasyprint/default.nix +++ b/pkgs/development/python-modules/weasyprint/default.nix @@ -1,4 +1,7 @@ { + stdenv, + lib, + pkgs, buildPythonPackage, cffi, cssselect2, @@ -6,10 +9,8 @@ flit-core, fontconfig, fonttools, - ghostscript, glib, harfbuzz, - lib, pango, pillow, pydyf, @@ -18,7 +19,6 @@ pytestCheckHook, pythonOlder, replaceVars, - stdenv, tinycss2, tinyhtml5, }: @@ -61,7 +61,7 @@ buildPythonPackage rec { ] ++ fonttools.optional-dependencies.woff; nativeCheckInputs = [ - ghostscript + pkgs.ghostscript pytest-cov-stub pytestCheckHook ]; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 15b2df126598..6b4e3e795bd7 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -5551,6 +5551,8 @@ self: super: with self; { ghome-foyer-api = callPackage ../development/python-modules/ghome-foyer-api { }; + ghostscript = callPackage ../development/python-modules/ghostscript { }; + ghp-import = callPackage ../development/python-modules/ghp-import { }; ghrepo-stats = callPackage ../development/python-modules/ghrepo-stats { };