diff --git a/pkgs/development/python-modules/weasyprint/default.nix b/pkgs/development/python-modules/weasyprint/default.nix index ecc13b1d6377..a3c8181cf7de 100644 --- a/pkgs/development/python-modules/weasyprint/default.nix +++ b/pkgs/development/python-modules/weasyprint/default.nix @@ -1,17 +1,24 @@ { buildPythonPackage, fetchPypi, fetchpatch, + pytestCheckHook, + brotli, cairosvg, + fonttools, + pydyf, pyphen, cffi, cssselect, lxml, html5lib, tinycss, + zopfli, glib, + harfbuzz, pango, fontconfig, lib, stdenv, + ghostscript, pytest, pytest-runner, pytest-isort, @@ -23,35 +30,48 @@ buildPythonPackage rec { pname = "weasyprint"; - version = "52"; + version = "53.4"; disabled = !isPy3k; - # excluded test needs the Ahem font - checkPhase = '' - runHook preCheck - pytest -k 'not test_font_stretch' - runHook postCheck - ''; + pytestFlagsArray = [ + # setup.py is auto-generated and doesn't pass the flake8 check + "--ignore=setup.py" + # ffi.py is patched by us and doesn't pass the flake8 check + "--ignore=weasyprint/text/ffi.py" + ]; - # ignore failing flake8-test - prePatch = '' - substituteInPlace setup.cfg \ - --replace '[tool:pytest]' '[tool:pytest]\nflake8-ignore = E501' - ''; + disabledTests = [ + # test_font_stretch needs the Ahem font (fails on macOS) + "test_font_stretch" + ]; - checkInputs = [ pytest pytest-runner pytest-isort pytest-flake8 pytest-cov ]; + checkInputs = [ + pytestCheckHook + ghostscript + pytest + pytest-runner + pytest-isort + pytest-flake8 + pytest-cov + ]; FONTCONFIG_FILE = "${fontconfig.out}/etc/fonts/fonts.conf"; - propagatedBuildInputs = [ cairosvg pyphen cffi cssselect lxml html5lib tinycss ]; + propagatedBuildInputs = [ + brotli + cairosvg + cffi + cssselect + fonttools + html5lib + lxml + pydyf + pyphen + tinycss + zopfli + ]; - # 47043a1fd7e50a892b9836466f521df85d597c4.patch can be removed after next release of weasyprint, see: - # https://github.com/Kozea/WeasyPrint/issues/1333#issuecomment-818062970 patches = [ - (fetchpatch { - url = "https://github.com/Kozea/WeasyPrint/commit/47043a1fd7e50a892b9836466f521df85d597c44.patch"; - sha256 = "0l9z0hrav3bcdajlg3vbzljq0lkw7hlj8ppzrq3v21hbj1il1nsb"; - }) (substituteAll { src = ./library-paths.patch; fontconfig = "${fontconfig.lib}/lib/libfontconfig${stdenv.hostPlatform.extensions.sharedLibrary}"; @@ -59,13 +79,14 @@ buildPythonPackage rec { gobject = "${glib.out}/lib/libgobject-2.0${stdenv.hostPlatform.extensions.sharedLibrary}"; pango = "${pango.out}/lib/libpango-1.0${stdenv.hostPlatform.extensions.sharedLibrary}"; pangocairo = "${pango.out}/lib/libpangocairo-1.0${stdenv.hostPlatform.extensions.sharedLibrary}"; + harfbuzz = "${harfbuzz.out}/lib/libharfbuzz${stdenv.hostPlatform.extensions.sharedLibrary}"; }) ]; src = fetchPypi { inherit version; - pname = "WeasyPrint"; - sha256 = "0rwf43111ws74m8b1alkkxzz57g0np3vmd8as74adwnxslfcg4gs"; + pname = "weasyprint"; + sha256 = "sha256-EMyxfVXHMJa98e3T7+WMuFWwfkwwfZutTryaPxP/RYA="; }; meta = with lib; { diff --git a/pkgs/development/python-modules/weasyprint/library-paths.patch b/pkgs/development/python-modules/weasyprint/library-paths.patch index c6eb87c94585..9a10990fd43f 100644 --- a/pkgs/development/python-modules/weasyprint/library-paths.patch +++ b/pkgs/development/python-modules/weasyprint/library-paths.patch @@ -1,38 +1,31 @@ -diff --git a/weasyprint/fonts.py b/weasyprint/fonts.py -index 79e3b5b..4438eb4 100644 ---- a/weasyprint/fonts.py -+++ b/weasyprint/fonts.py -@@ -45,11 +45,8 @@ else: - # with OSError: dlopen() failed to load a library: cairo / cairo-2 - # So let's hope we find the same file as cairo already did ;) - # Same applies to pangocairo requiring pangoft2 -- fontconfig = dlopen(ffi, 'fontconfig', 'libfontconfig', -- 'libfontconfig-1.dll', -- 'libfontconfig.so.1', 'libfontconfig-1.dylib') -- pangoft2 = dlopen(ffi, 'pangoft2-1.0', 'libpangoft2-1.0-0', -- 'libpangoft2-1.0.so.0', 'libpangoft2-1.0.dylib') -+ fontconfig = dlopen(ffi, '@fontconfig@') -+ pangoft2 = dlopen(ffi, '@pangoft2@') - - ffi.cdef(''' - // FontConfig -diff --git a/weasyprint/text.py b/weasyprint/text.py -index 1dc5e4d..b070bad 100644 ---- a/weasyprint/text.py -+++ b/weasyprint/text.py -@@ -255,12 +255,9 @@ def dlopen(ffi, *names): +diff --git a/weasyprint/text/ffi.py b/weasyprint/text/ffi.py +index 0734cbea..22e31a5e 100644 +--- a/weasyprint/text/ffi.py ++++ b/weasyprint/text/ffi.py +@@ -387,21 +387,11 @@ def _dlopen(ffi, *names): return ffi.dlopen(names[0]) # pragma: no cover --gobject = dlopen(ffi, 'gobject-2.0', 'libgobject-2.0-0', 'libgobject-2.0.so.0', -- 'libgobject-2.0.dylib') --pango = dlopen(ffi, 'pango-1.0', 'libpango-1.0-0', 'libpango-1.0.so.0', -- 'libpango-1.0.dylib') --pangocairo = dlopen(ffi, 'pangocairo-1.0', 'libpangocairo-1.0-0', -- 'libpangocairo-1.0.so.0', 'libpangocairo-1.0.dylib') -+gobject = dlopen(ffi, '@gobject@') -+pango = dlopen(ffi, '@pango@') -+pangocairo = dlopen(ffi, '@pangocairo@') +-gobject = _dlopen( +- ffi, 'gobject-2.0-0', 'gobject-2.0', 'libgobject-2.0-0', +- 'libgobject-2.0.so.0', 'libgobject-2.0.dylib') +-pango = _dlopen( +- ffi, 'pango-1.0-0', 'pango-1.0', 'libpango-1.0-0', 'libpango-1.0.so.0', +- 'libpango-1.0.dylib') +-harfbuzz = _dlopen( +- ffi, 'harfbuzz', 'harfbuzz-0.0', 'libharfbuzz-0', +- 'libharfbuzz.so.0', 'libharfbuzz.so.0', 'libharfbuzz.0.dylib') +-fontconfig = _dlopen( +- ffi, 'fontconfig-1', 'fontconfig', 'libfontconfig', 'libfontconfig-1.dll', +- 'libfontconfig.so.1', 'libfontconfig-1.dylib') +-pangoft2 = _dlopen( +- ffi, 'pangoft2-1.0-0', 'pangoft2-1.0', 'libpangoft2-1.0-0', +- 'libpangoft2-1.0.so.0', 'libpangoft2-1.0.dylib') ++gobject = _dlopen(ffi, '@gobject@') ++pango = _dlopen(ffi, '@pango@') ++harfbuzz = _dlopen(ffi, '@harfbuzz@') ++fontconfig = _dlopen(ffi, '@fontconfig@') ++pangoft2 = _dlopen(ffi, '@pangoft2@') gobject.g_type_init() - +