1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 cairosvg, 6 cffi, 7 cssselect2, 8 fetchPypi, 9 flit-core, 10 fontconfig, 11 fonttools, 12 ghostscript, 13 glib, 14 harfbuzz, 15 html5lib, 16 pango, 17 pillow, 18 pydyf, 19 pyphen, 20 pytestCheckHook, 21 pythonOlder, 22 substituteAll, 23 tinycss2, 24}: 25 26buildPythonPackage rec { 27 pname = "weasyprint"; 28 version = "61.2"; 29 format = "pyproject"; 30 31 disabled = pythonOlder "3.8"; 32 33 src = fetchPypi { 34 inherit version; 35 pname = "weasyprint"; 36 hash = "sha256-R99s/u/4xsKM8uTK+DfN4XcV7+RicIradLqi6zkbYFk="; 37 }; 38 39 patches = [ 40 (substituteAll { 41 src = ./library-paths.patch; 42 fontconfig = "${fontconfig.lib}/lib/libfontconfig${stdenv.hostPlatform.extensions.sharedLibrary}"; 43 pangoft2 = "${pango.out}/lib/libpangoft2-1.0${stdenv.hostPlatform.extensions.sharedLibrary}"; 44 gobject = "${glib.out}/lib/libgobject-2.0${stdenv.hostPlatform.extensions.sharedLibrary}"; 45 pango = "${pango.out}/lib/libpango-1.0${stdenv.hostPlatform.extensions.sharedLibrary}"; 46 pangocairo = "${pango.out}/lib/libpangocairo-1.0${stdenv.hostPlatform.extensions.sharedLibrary}"; 47 harfbuzz = "${harfbuzz.out}/lib/libharfbuzz${stdenv.hostPlatform.extensions.sharedLibrary}"; 48 }) 49 ]; 50 51 nativeBuildInputs = [ flit-core ]; 52 53 propagatedBuildInputs = [ 54 cffi 55 cssselect2 56 fonttools 57 html5lib 58 pillow 59 pydyf 60 pyphen 61 tinycss2 62 ] ++ fonttools.optional-dependencies.woff; 63 64 nativeCheckInputs = [ 65 pytestCheckHook 66 ghostscript 67 ]; 68 69 disabledTests = [ 70 # needs the Ahem font (fails on macOS) 71 "test_font_stretch" 72 # sensitive to sandbox environments 73 "test_tab_size" 74 "test_tabulation_character" 75 "test_linear_gradients_5" 76 "test_linear_gradients_12" 77 ]; 78 79 FONTCONFIG_FILE = "${fontconfig.out}/etc/fonts/fonts.conf"; 80 81 # Set env variable explicitly for Darwin, but allow overriding when invoking directly 82 makeWrapperArgs = [ "--set-default FONTCONFIG_FILE ${FONTCONFIG_FILE}" ]; 83 84 postPatch = '' 85 substituteInPlace pyproject.toml \ 86 --replace "--isort --flake8 --cov --no-cov-on-fail" "" 87 ''; 88 89 preCheck = '' 90 # Fontconfig wants to create a cache. 91 export HOME=$TMPDIR 92 ''; 93 94 pythonImportsCheck = [ "weasyprint" ]; 95 96 meta = with lib; { 97 description = "Converts web documents to PDF"; 98 mainProgram = "weasyprint"; 99 homepage = "https://weasyprint.org/"; 100 license = licenses.bsd3; 101 maintainers = with maintainers; [ elohmeier ]; 102 }; 103}