1{ 2 stdenv, 3 lib, 4 buildPythonPackage, 5 fetchFromGitLab, 6 pytestCheckHook, 7 8 setuptools, 9 10 ghostscript_headless, 11}: 12 13buildPythonPackage rec { 14 pname = "ghostscript"; 15 version = "0.7"; 16 pyproject = true; 17 18 src = fetchFromGitLab { 19 owner = "pdftools"; 20 repo = "python-ghostscript"; 21 tag = "v${version}"; 22 hash = "sha256-yBJuAnLK/4YDU9PBsSWPQay4pDws3bP+3rCplysq41w="; 23 }; 24 25 postPatch = 26 let 27 extLib = stdenv.hostPlatform.extensions.sharedLibrary; 28 in 29 '' 30 substituteInPlace ghostscript/__init__.py \ 31 --replace-fail '__version__ = gs.__version__' '__version__ = "${version}"' 32 33 substituteInPlace ghostscript/_gsprint.py \ 34 --replace-fail 'cdll.LoadLibrary("libgs.so")' 'cdll.LoadLibrary("${lib.getLib ghostscript_headless}/lib/libgs${extLib}")' 35 ''; 36 37 build-system = [ 38 setuptools 39 ]; 40 41 nativeCheckInputs = [ 42 pytestCheckHook 43 ]; 44 45 disabledTests = [ 46 # Some tests don't (fully) match anymore. 47 # Not sure if ghostscript ever promised to keep producing the same outputs, bit-by-bit… 48 "test_simple" 49 "test_unicode_arguments" 50 "test_run_string" 51 "test_stdin" 52 ]; 53 54 pythonImportsCheck = [ "ghostscript" ]; 55 56 meta = { 57 description = "Interface to the Ghostscript C-API using ctypes"; 58 homepage = "https://gitlab.com/pdftools/python-ghostscript"; 59 changelog = "https://gitlab.com/pdftools/python-ghostscript/-/blob/v${version}/CHANGES.txt"; 60 license = lib.licenses.gpl3Plus; 61 maintainers = with lib.maintainers; [ flokli ]; 62 }; 63}