From bd383ac0e3a51cf5d3b5c102bbef6745c976a0cb Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Thu, 29 May 2025 23:43:48 +0200 Subject: [PATCH 1/3] python312Packages.weasyprint: cleanup --- .../python-modules/weasyprint/default.nix | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/pkgs/development/python-modules/weasyprint/default.nix b/pkgs/development/python-modules/weasyprint/default.nix index 696bee47ac5f5..1061e7e56f47c 100644 --- a/pkgs/development/python-modules/weasyprint/default.nix +++ b/pkgs/development/python-modules/weasyprint/default.nix @@ -1,26 +1,32 @@ { - stdenv, lib, + stdenv, pkgs, buildPythonPackage, - cffi, - cssselect2, - fetchPypi, - flit-core, + fetchFromGitHub, fontconfig, - fonttools, glib, harfbuzz, pango, + + # build-system + flit-core, + + # dependencies + cffi, + cssselect2, + fonttools, pillow, pydyf, pyphen, + tinycss2, + tinyhtml5, + + # tests pytest-cov-stub, pytestCheckHook, - pythonOlder, replaceVars, - tinycss2, - tinyhtml5, + writableTmpDirAsHomeHook, }: buildPythonPackage rec { @@ -28,12 +34,11 @@ buildPythonPackage rec { version = "65.1"; pyproject = true; - disabled = pythonOlder "3.9"; - - src = fetchPypi { - inherit version; - pname = "weasyprint"; - hash = "sha256-EgKBvb1C/6p9flztvjGCos7zbqWtl/6fNX5DvmoeWOo="; + src = fetchFromGitHub { + owner = "Kozea"; + repo = "WeasyPrint"; + tag = "v${version}"; + hash = "sha256-iSeuRX1dnnrGZbcb1yTxOJPD5kgIWY6oz/0v02QJqSs="; }; patches = [ @@ -64,6 +69,7 @@ buildPythonPackage rec { pkgs.ghostscript pytest-cov-stub pytestCheckHook + writableTmpDirAsHomeHook ]; disabledTests = [ @@ -93,11 +99,6 @@ buildPythonPackage rec { # Set env variable explicitly for Darwin, but allow overriding when invoking directly makeWrapperArgs = [ "--set-default FONTCONFIG_FILE ${FONTCONFIG_FILE}" ]; - preCheck = '' - # Fontconfig wants to create a cache. - export HOME=$TMPDIR - ''; - pythonImportsCheck = [ "weasyprint" ]; meta = { From 103f8664beeefb344c6772804c99428b458b5bf9 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Thu, 29 May 2025 23:44:47 +0200 Subject: [PATCH 2/3] python312Packages.weasyprint: add versionCheckHook --- pkgs/development/python-modules/weasyprint/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/development/python-modules/weasyprint/default.nix b/pkgs/development/python-modules/weasyprint/default.nix index 1061e7e56f47c..77e64d1a00603 100644 --- a/pkgs/development/python-modules/weasyprint/default.nix +++ b/pkgs/development/python-modules/weasyprint/default.nix @@ -26,6 +26,7 @@ pytest-cov-stub, pytestCheckHook, replaceVars, + versionCheckHook, writableTmpDirAsHomeHook, }: @@ -69,8 +70,10 @@ buildPythonPackage rec { pkgs.ghostscript pytest-cov-stub pytestCheckHook + versionCheckHook writableTmpDirAsHomeHook ]; + versionCheckProgramArg = "--version"; disabledTests = [ # needs the Ahem font (fails on macOS) From 1f3967f132dd023cfb17b008dbbcb8d693bd72b9 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Thu, 29 May 2025 23:51:03 +0200 Subject: [PATCH 3/3] python312Packages.weasyprint: mark as broken on darwin --- pkgs/development/python-modules/weasyprint/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/development/python-modules/weasyprint/default.nix b/pkgs/development/python-modules/weasyprint/default.nix index 77e64d1a00603..3767704c8200c 100644 --- a/pkgs/development/python-modules/weasyprint/default.nix +++ b/pkgs/development/python-modules/weasyprint/default.nix @@ -111,5 +111,10 @@ buildPythonPackage rec { homepage = "https://weasyprint.org/"; license = lib.licenses.bsd3; teams = [ lib.teams.apm ]; + badPlatforms = [ + # Fatal Python error: Segmentation fault + # "...weasyprint/pdf/fonts.py", line 221 in _harfbuzz_subset + lib.systems.inspect.patterns.isDarwin + ]; }; }