From c04e1db9dcf2b621bbb39fac61b14bea83cfc160 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Thu, 30 Jan 2025 20:47:33 -0500 Subject: [PATCH 1/3] python312Packages.pypdfium2: pin to git revision Previously, we were fetching headers from a branch, not a fixed revision, so a new patch in the branch broke the build because hashes changed. Closes #378154 Signed-off-by: Ihar Hrachyshka --- .../python-modules/pypdfium2/default.nix | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pkgs/development/python-modules/pypdfium2/default.nix b/pkgs/development/python-modules/pypdfium2/default.nix index 1d1e9a0769b4..f883cfc54904 100644 --- a/pkgs/development/python-modules/pypdfium2/default.nix +++ b/pkgs/development/python-modules/pypdfium2/default.nix @@ -3,21 +3,25 @@ pkgs, buildPythonPackage, fetchFromGitHub, - fetchurl, + fetchgit, setuptools-scm, pdfium-binaries, numpy, pillow, pytestCheckHook, - python, }: let pdfiumVersion = "${pdfium-binaries.version}"; - headers = fetchurl { - url = "https://pdfium.googlesource.com/pdfium/+archive/refs/heads/chromium/${pdfiumVersion}/public.tar.gz"; - hash = "sha256-vKfs4Jd8LEtA3aTI+DcJMS0VOErq1IR1eThnMlxiER0="; + headers = fetchgit { + url = "https://pdfium.googlesource.com/pdfium"; + # The latest revision on the chromium/${pdfiumVersion} branch + rev = "f6da7d235728aeaff6586d2190badfb4290a9979"; + hash = "sha256-xUylu//APbwpI+k6cQ7OrPCwDXp9qw0ZVaCba/d5zVg="; + sparseCheckout = [ + "public" + ]; }; # They demand their own fork of ctypesgen @@ -84,8 +88,8 @@ buildPythonPackage rec { in '' # Preseed the headers and version file - mkdir -p ${headersDir} - tar -xf ${headers} -C ${headersDir} + mkdir -p ${bindingsDir} + cp -r ${headers}/public ${headersDir} install -m 644 ${inputVersionFile} ${versionFile} # Make generated bindings consider pdfium derivation path when loading dynamic libraries From 138706cd3a860b1fed1fec5e41b31e26a70d3535 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Fri, 31 Jan 2025 16:57:25 -0500 Subject: [PATCH 2/3] pdfium-binaries: add python3Packages.pypdfium2 to passthru.tests This is to make sure pypdfium2 build is not broken on version update. Signed-off-by: Ihar Hrachyshka --- pkgs/by-name/pd/pdfium-binaries/package.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/pd/pdfium-binaries/package.nix b/pkgs/by-name/pd/pdfium-binaries/package.nix index 4ae0b7cac35b..95202c7ff11b 100644 --- a/pkgs/by-name/pd/pdfium-binaries/package.nix +++ b/pkgs/by-name/pd/pdfium-binaries/package.nix @@ -2,6 +2,7 @@ lib, fetchzip, stdenv, + python3Packages, }: let version = "6968"; @@ -41,7 +42,12 @@ stdenv.mkDerivation { runHook postInstall ''; - passthru.updateScript = ./update.sh; + passthru = { + updateScript = ./update.sh; + tests = { + inherit (python3Packages) pypdfium2; + }; + }; meta = { description = "Binary distribution of PDFium"; From 317696ace280b346eb80961d3dcb4b25bd0b19e2 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Fri, 31 Jan 2025 18:18:23 -0500 Subject: [PATCH 3/3] pdfium-binaries: add comment to update pypdfium2 headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Robert Schütz --- pkgs/by-name/pd/pdfium-binaries/package.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/by-name/pd/pdfium-binaries/package.nix b/pkgs/by-name/pd/pdfium-binaries/package.nix index 95202c7ff11b..8f4394c11416 100644 --- a/pkgs/by-name/pd/pdfium-binaries/package.nix +++ b/pkgs/by-name/pd/pdfium-binaries/package.nix @@ -5,6 +5,7 @@ python3Packages, }: let + # also update rev of headers in python3Packages.pypdfium2 version = "6968"; src = let