From a514ef1f2f66062e4791ca35583d20f6bc062084 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Sat, 23 Aug 2025 21:42:39 -0400 Subject: [PATCH 1/3] pdfium-binaries: 7087 -> 7363 --- pkgs/by-name/pd/pdfium-binaries/package.nix | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkgs/by-name/pd/pdfium-binaries/package.nix b/pkgs/by-name/pd/pdfium-binaries/package.nix index ae3ef3a350dd..7b96a89ba2d8 100644 --- a/pkgs/by-name/pd/pdfium-binaries/package.nix +++ b/pkgs/by-name/pd/pdfium-binaries/package.nix @@ -9,7 +9,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "pdfium-binaries"; # also update rev of headers in python3Packages.pypdfium2 - version = "7087"; + version = "7363"; src = let @@ -28,17 +28,17 @@ stdenv.mkDerivation (finalAttrs: { hash = if withV8 then selectSystem { - x86_64-linux = "sha256-nKHXcBTEp165g18HLzaNGfKt8MtTYpKBGNgwIpSO0u4="; - aarch64-linux = "sha256-wip/ry42aDbyGiwYSUX8koxDuf88BLGZAmMZE0s+fL0="; - x86_64-darwin = "sha256-7pUMfNFgGqQ8Dnox57sHfrKKke+i8CGEma4tePJaTDA="; - aarch64-darwin = "sha256-o59kmTNC4nSCFLfww3E+4iIYs2kQ30yyFaX9f2Za7os="; + x86_64-linux = "sha256-KbAJUdbT3XjLs68y4xwEG5w8o/89epkXSCKpQsyuNec="; + aarch64-linux = "sha256-zvaTKszH5yT1afzs0W3LV1caN6gaCIJiKIh9bElfI48="; + x86_64-darwin = "sha256-xGnmndTkYSIGn44Y4cfYW36QmkVAOhgIlcsWaRYFbCk="; + aarch64-darwin = "sha256-NYY/YIVtSux4B6UZb7kkZs+GzxXNopmvtknw/HhVEQs="; } else selectSystem { - x86_64-linux = "sha256-zn7QlTvChQa2mQCe5K+zEGVUtuD+l/jEtlKticrrSKg="; - aarch64-linux = "sha256-080X72NNfKaanHeVtmxE/4uNV6Ue4f/1Mri/p3nOT8c="; - x86_64-darwin = "sha256-XMStU0MN9ieCrLQnQL4/jKrNWxgQl9OtZHg9EmemPhU="; - aarch64-darwin = "sha256-Q8R/p1hX6+JeVTFc6w7MC9GPNGqxlu6m+iawRIMndic="; + x86_64-linux = "sha256-mlSmVeE1oDQ1OlW8K7EXk51r7GCbDXH2l/tbat2aiB0="; + aarch64-linux = "sha256-YiCMdwQ2Y0F120iKW3ZkxJKvDgP/vpPw1ItmRnsnz9U="; + x86_64-darwin = "sha256-I2fWQC+GKzZwqTPwXkl9vDJ/HIH3GKzD+kNaUDcNKuw="; + aarch64-darwin = "sha256-AhYAr5SySWJO3jbvs+DvEZ/WaCJ+KhxpFVyOVsJxuXE="; }; stripRoot = false; }; From 0a89c97fd8a6fa913734236523b0fea5af05a2ba Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Mon, 25 Aug 2025 19:32:27 -0400 Subject: [PATCH 2/3] python313Packages.zebrafy: handle pypdfium2 5.x --- pkgs/development/python-modules/zebrafy/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/development/python-modules/zebrafy/default.nix b/pkgs/development/python-modules/zebrafy/default.nix index c3bf90c078f0..b68ac63bdd6f 100644 --- a/pkgs/development/python-modules/zebrafy/default.nix +++ b/pkgs/development/python-modules/zebrafy/default.nix @@ -2,6 +2,7 @@ lib, buildPythonPackage, fetchFromGitHub, + fetchpatch, setuptools, setuptools-scm, pillow, @@ -22,6 +23,14 @@ buildPythonPackage rec { hash = "sha256-B8jrFQh5swDMfYjdMcY0Hh2VAzknDwarDKVAML6F2r4="; }; + patches = [ + # fix compatibility with pypdfium2 5.x: https://github.com/miikanissi/zebrafy/pull/20 + (fetchpatch { + url = "https://github.com/miikanissi/zebrafy/pull/20/commits/cc15c4a28d9e8aec022d22397ff752600b9ede52.patch"; + hash = "sha256-KAjfKPqmTvfoQN7YPLayPyq2sueDASyU/lMCgLCl1RU="; + }) + ]; + build-system = [ setuptools setuptools-scm From fbf2b41342f138a22a4c336b0ddadf2c5545b736 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Sat, 23 Aug 2025 21:45:02 -0400 Subject: [PATCH 3/3] python313Packages.pypdfium2: 4.30.1 -> 5.0.0 --- pkgs/by-name/pd/pdfium-binaries/package.nix | 1 - .../python-modules/pypdfium2/default.nix | 81 +++++-------------- .../pypdfium2/fix-cc-detection.patch | 25 ------ 3 files changed, 18 insertions(+), 89 deletions(-) delete mode 100644 pkgs/development/python-modules/pypdfium2/fix-cc-detection.patch diff --git a/pkgs/by-name/pd/pdfium-binaries/package.nix b/pkgs/by-name/pd/pdfium-binaries/package.nix index 7b96a89ba2d8..b61b8b12d42f 100644 --- a/pkgs/by-name/pd/pdfium-binaries/package.nix +++ b/pkgs/by-name/pd/pdfium-binaries/package.nix @@ -8,7 +8,6 @@ stdenv.mkDerivation (finalAttrs: { pname = "pdfium-binaries"; - # also update rev of headers in python3Packages.pypdfium2 version = "7363"; src = diff --git a/pkgs/development/python-modules/pypdfium2/default.nix b/pkgs/development/python-modules/pypdfium2/default.nix index 8a566a791873..5acd2148dcce 100644 --- a/pkgs/development/python-modules/pypdfium2/default.nix +++ b/pkgs/development/python-modules/pypdfium2/default.nix @@ -1,10 +1,9 @@ { stdenv, lib, - pkgs, + pkgsCross, buildPythonPackage, fetchFromGitHub, - fetchgit, gitUpdater, setuptools-scm, pdfium-binaries, @@ -13,22 +12,9 @@ pytestCheckHook, removeReferencesTo, python, - replaceVars, }: let - pdfiumVersion = "${pdfium-binaries.version}"; - - headers = fetchgit { - url = "https://pdfium.googlesource.com/pdfium"; - # The latest revision on the chromium/${pdfiumVersion} branch - rev = "9232d7c94a0007377a8034222f47683fe391d474"; - hash = "sha256-dI3jTyVYc0EmMLHTiVjGSf3C2noS9Ru5WijEJFtiSFk="; - sparseCheckout = [ - "public" - ]; - }; - # They demand their own fork of ctypesgen ctypesgen = buildPythonPackage rec { pname = "ctypesgen"; @@ -38,34 +24,26 @@ let src = fetchFromGitHub { owner = "pypdfium2-team"; repo = "ctypesgen"; - rev = "848e9fbb1374f7f58a7ebf5e5da5c33292480b30"; - hash = "sha256-3JA7cW/xaEj/DxMHEypROwrKGo7EwUEcipRqALTvydw="; + rev = "3961621c3e057015362db82471e07f3a57822b15"; + hash = "sha256-0OBY7/Zn12rG20jNYG65lANTRVRIFvE0SgUdYGFpRtU="; }; - patches = [ - (replaceVars ./fix-cc-detection.patch { - cc = "${stdenv.cc.targetPrefix}cc"; - }) - ]; - build-system = [ setuptools-scm ]; - - env.SETUPTOOLS_SCM_PRETEND_VERSION = "${version}"; }; in buildPythonPackage rec { pname = "pypdfium2"; - version = "4.30.1"; + version = "5.0.0"; pyproject = true; src = fetchFromGitHub { owner = "pypdfium2-team"; repo = "pypdfium2"; tag = version; - hash = "sha256-v8f/XruGJYK3H9z4Q1rLg4fEnPHa8tTOlNTBMVxPEgA="; + hash = "sha256-to6l8kfi6pYRs+hv+9zdxpSyhKCxX79G/EMdz6OBBaA="; }; build-system = [ @@ -81,43 +59,19 @@ buildPythonPackage rec { pdfium-binaries ]; - # Build system insists on fetching from the internet unless "cached" files - # are prepared. Even then, some code patching needs to happen to make it not - # talk to the internet. + preBuild = '' + getVersion() { + cat ${pdfium-binaries}/VERSION | grep $1 | sed 's/.*=//' + } + export GIVEN_FULLVER="$(getVersion MAJOR).$(getVersion MINOR).$(getVersion BUILD).$(getVersion PATCH)" + ''; - # The project doesn't seem very open to allow for offline building either, - # see: https://github.com/pypdfium2-team/pypdfium2/discussions/274 - preBuild = - let - pdfiumLib = lib.makeLibraryPath [ pdfium-binaries ]; - inputVersionFile = (pkgs.formats.json { }).generate "version.json" { - version = lib.strings.toInt pdfiumVersion; - source = "generated"; - flags = [ ]; - run_lds = [ pdfiumLib ]; - guard_symbols = false; - }; - bindingsDir = "data/bindings"; - headersDir = "${bindingsDir}/headers"; - versionFile = "${bindingsDir}/version.json"; - in - '' - # Preseed the headers and version file - mkdir -p ${bindingsDir} - cp -r ${headers}/public ${headersDir} - install -m 644 ${inputVersionFile} ${versionFile} - - # Make generated bindings consider pdfium derivation path when loading dynamic libraries - substituteInPlace setupsrc/pypdfium2_setup/emplace.py \ - --replace-fail 'build_pdfium_bindings(pdfium_ver, flags=flags, guard_symbols=True, run_lds=[])' \ - 'build_pdfium_bindings(pdfium_ver, flags=flags, guard_symbols=True, run_lds=["${pdfiumLib}"])' - - # Short circuit the version pull from the internet - substituteInPlace setupsrc/pypdfium2_setup/packaging_base.py \ - --replace-fail 'PdfiumVer.to_full(build)._asdict()' \ - '{"major": 133, "minor": 0, "build": ${pdfiumVersion}, "patch": 1}' - ''; - env.PDFIUM_PLATFORM = "system:${pdfiumVersion}"; + env = { + PDFIUM_PLATFORM = "system-search:${pdfium-binaries.version}"; + PDFIUM_HEADERS = "${pdfium-binaries}/include"; + PDFIUM_BINARY = "${pdfium-binaries}/lib/libpdfium${stdenv.targetPlatform.extensions.sharedLibrary}"; + CPP = "${stdenv.cc.targetPrefix}cpp"; + }; # Remove references to stdenv in comments. postInstall = '' @@ -138,6 +92,7 @@ buildPythonPackage rec { updateScript = gitUpdater { allowedVersions = "^[.0-9]+$"; }; + tests.cross = pkgsCross.aarch64-multiplatform.python3Packages.pypdfium2; }; meta = { diff --git a/pkgs/development/python-modules/pypdfium2/fix-cc-detection.patch b/pkgs/development/python-modules/pypdfium2/fix-cc-detection.patch deleted file mode 100644 index e01cc90901f5..000000000000 --- a/pkgs/development/python-modules/pypdfium2/fix-cc-detection.patch +++ /dev/null @@ -1,25 +0,0 @@ -diff --git a/src/ctypesgen/__main__.py b/src/ctypesgen/__main__.py -index 23ee014..2d0cfc1 100644 ---- a/src/ctypesgen/__main__.py -+++ b/src/ctypesgen/__main__.py -@@ -89,17 +89,9 @@ def main_impl(args, cmd_str): - assert _is_relative_to(args.output, args.linkage_anchor) - - if args.cpp: -- assert shutil.which(args.cpp[0]), f"Given pre-processor {args.cpp[0]!r} is not available." -- else: -- if shutil.which("gcc"): -- args.cpp = ["gcc", "-E"] -- elif shutil.which("cpp"): -- args.cpp = ["cpp"] -- elif shutil.which("clang"): -- args.cpp = ["clang", "-E"] -- else: -- raise RuntimeError("C pre-processor auto-detection failed: neither gcc nor clang available.") -- -+ print("cpp argument ignored for nix build") -+ args.cpp = ["@cc@", "-E"] -+ - # Important: must not use +=, this would mutate the original object, which is problematic when default=[] is used and ctypesgen called repeatedly from within python - args.compile_libdirs = args.compile_libdirs + args.universal_libdirs - args.runtime_libdirs = args.runtime_libdirs + args.universal_libdirs