From b560bf6d1d4b1ae1cafd3310fa4b6f48e68b166f Mon Sep 17 00:00:00 2001 From: Martin Joerg Date: Fri, 28 Nov 2025 13:59:15 +0000 Subject: [PATCH 1/6] python3Packages.graph-tool: fix build against Clang >= 21 --- .../python-modules/graph-tool/default.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/graph-tool/default.nix b/pkgs/development/python-modules/graph-tool/default.nix index 5dc014626300..533a927ac410 100644 --- a/pkgs/development/python-modules/graph-tool/default.nix +++ b/pkgs/development/python-modules/graph-tool/default.nix @@ -2,9 +2,10 @@ buildPythonPackage, lib, fetchurl, + fetchpatch, stdenv, - boost, + boost189, cairomm, cgal, expat, @@ -25,7 +26,17 @@ }: let - boost' = boost.override { + boost' = boost189.override { + patches = [ + # required to build against Clang >= 21 (https://github.com/boostorg/lexical_cast/pull/87) + # TODO: drop when upgrading to Boost >= 1.90 + (fetchpatch { + name = "Reduce-dependency-on-Boost.TypeTraits-now-that-C-11-.patch"; + url = "https://github.com/boostorg/lexical_cast/commit/8fc8a19931c8cb452400af907959fdacbbdd8ec1.patch"; + relative = "include"; + hash = "sha256-OO39ejR+I5ufjqinrMJ6HgjTE7Ph+XBu50PqcIKaIQo="; + }) + ]; enablePython = true; inherit python; }; From b88811668f3b3b658f7ad10134b22ceb24795b74 Mon Sep 17 00:00:00 2001 From: Martin Joerg Date: Fri, 28 Nov 2025 13:59:16 +0000 Subject: [PATCH 2/6] python3Packages.graph-tool: modernize --- .../python-modules/graph-tool/default.nix | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/pkgs/development/python-modules/graph-tool/default.nix b/pkgs/development/python-modules/graph-tool/default.nix index 533a927ac410..48b5682e6c96 100644 --- a/pkgs/development/python-modules/graph-tool/default.nix +++ b/pkgs/development/python-modules/graph-tool/default.nix @@ -44,25 +44,26 @@ in buildPythonPackage rec { pname = "graph-tool"; version = "2.98"; - format = "other"; + pyproject = false; src = fetchurl { url = "https://downloads.skewed.de/graph-tool/graph-tool-${version}.tar.bz2"; hash = "sha256-7vGUi5N/XwQ3Se7nX+DG1+jwNlUdlF6dVeN4cLBsxSc="; }; - postPatch = '' + postPatch = # remove error messages about tput during build process without adding ncurses - substituteInPlace configure \ - --replace-fail 'tput setaf $1' : \ - --replace-fail 'tput sgr0' : - ''; + '' + substituteInPlace configure \ + --replace-fail 'tput setaf $1' : \ + --replace-fail 'tput sgr0' : + ''; - configureFlags = [ - "--with-python-module-path=$(out)/${python.sitePackages}" - "--with-boost-libdir=${boost'}/lib" - "--with-cgal=${cgal}" - ]; + configureFlags = lib.mapAttrsToList (lib.withFeatureAs true) { + boost-libdir = "${lib.getLib boost'}/lib"; + cgal = lib.getDev cgal; + python-module-path = "$(out)/${python.sitePackages}"; + }; enableParallelBuilding = true; From 04168995a12fae329946545583db648ae59171e9 Mon Sep 17 00:00:00 2001 From: Martin Joerg Date: Fri, 28 Nov 2025 13:59:16 +0000 Subject: [PATCH 3/6] python3Packages.graph-tool: enable GCC's link-time optimizer --- .../python-modules/graph-tool/default.nix | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pkgs/development/python-modules/graph-tool/default.nix b/pkgs/development/python-modules/graph-tool/default.nix index 48b5682e6c96..948522337165 100644 --- a/pkgs/development/python-modules/graph-tool/default.nix +++ b/pkgs/development/python-modules/graph-tool/default.nix @@ -59,11 +59,18 @@ buildPythonPackage rec { --replace-fail 'tput sgr0' : ''; - configureFlags = lib.mapAttrsToList (lib.withFeatureAs true) { - boost-libdir = "${lib.getLib boost'}/lib"; - cgal = lib.getDev cgal; - python-module-path = "$(out)/${python.sitePackages}"; - }; + configureFlags = + lib.mapAttrsToList (lib.withFeatureAs true) { + boost-libdir = "${lib.getLib boost'}/lib"; + cgal = lib.getDev cgal; + python-module-path = "$(out)/${python.sitePackages}"; + } + ++ + lib.optionals stdenv.cc.isGNU + # enable GCC's link-time optimizer in order to reduce compilation time and memory usage during compilation + # https://graph-tool.skewed.de/installation.html#memory-requirements-for-compilation + # https://git.skewed.de/count0/graph-tool/-/issues/798#note_5626 + [ "MOD_CXXFLAGS=-flto" ]; enableParallelBuilding = true; From a5a31d13fa7ef8738a7ccb62ef6ed5037c27c252 Mon Sep 17 00:00:00 2001 From: Martin Joerg Date: Fri, 28 Nov 2025 13:59:16 +0000 Subject: [PATCH 4/6] python3Packages.graph-tool: fix dependency categories --- .../python-modules/graph-tool/default.nix | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/pkgs/development/python-modules/graph-tool/default.nix b/pkgs/development/python-modules/graph-tool/default.nix index 948522337165..d3342642ebdc 100644 --- a/pkgs/development/python-modules/graph-tool/default.nix +++ b/pkgs/development/python-modules/graph-tool/default.nix @@ -9,7 +9,6 @@ cairomm, cgal, expat, - gmp, gobject-introspection, gtk3, llvmPackages, @@ -22,6 +21,7 @@ python, scipy, sparsehash, + zstandard, gitUpdater, }: @@ -74,26 +74,30 @@ buildPythonPackage rec { enableParallelBuilding = true; - build-system = [ pkg-config ]; + nativeBuildInputs = [ pkg-config ]; # https://graph-tool.skewed.de/installation.html#manual-compilation - dependencies = [ + buildInputs = [ boost' cairomm cgal expat - gmp - gobject-introspection + mpfr + sparsehash + ] + ++ lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ]; + + dependencies = [ gtk3 matplotlib - mpfr numpy pycairo pygobject3 scipy - sparsehash - ] - ++ lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ]; + zstandard + ]; + + propagatedNativeBuildInputs = [ gobject-introspection ]; pythonImportsCheck = [ "graph_tool" ]; From 3692a637e7e80a8df86e92b09df0c0b4795871ed Mon Sep 17 00:00:00 2001 From: Martin Joerg Date: Fri, 28 Nov 2025 13:59:16 +0000 Subject: [PATCH 5/6] python3Packages.graph-tool: perform more import checks --- pkgs/development/python-modules/graph-tool/default.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/graph-tool/default.nix b/pkgs/development/python-modules/graph-tool/default.nix index d3342642ebdc..cf4b067f31d8 100644 --- a/pkgs/development/python-modules/graph-tool/default.nix +++ b/pkgs/development/python-modules/graph-tool/default.nix @@ -9,6 +9,7 @@ cairomm, cgal, expat, + fontconfig, gobject-introspection, gtk3, llvmPackages, @@ -99,7 +100,14 @@ buildPythonPackage rec { propagatedNativeBuildInputs = [ gobject-introspection ]; - pythonImportsCheck = [ "graph_tool" ]; + preInstallCheck = + # avoid warnings about Matplotlib and Fontconfig configuration issues + '' + export HOME=$(mktemp -d) + export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf + ''; + + pythonImportsCheck = [ "graph_tool.all" ]; passthru.updateScript = gitUpdater { url = "https://git.skewed.de/count0/graph-tool"; From 73589b4e56400e9a91fca0f9a036446fe6966899 Mon Sep 17 00:00:00 2001 From: Martin Joerg Date: Fri, 28 Nov 2025 13:59:16 +0000 Subject: [PATCH 6/6] python3Packages.graph-tool: enable graphviz support --- pkgs/development/python-modules/graph-tool/default.nix | 9 +++++++++ pkgs/top-level/python-packages.nix | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/graph-tool/default.nix b/pkgs/development/python-modules/graph-tool/default.nix index cf4b067f31d8..f455258ea14b 100644 --- a/pkgs/development/python-modules/graph-tool/default.nix +++ b/pkgs/development/python-modules/graph-tool/default.nix @@ -11,6 +11,7 @@ expat, fontconfig, gobject-introspection, + graphviz, gtk3, llvmPackages, matplotlib, @@ -58,6 +59,14 @@ buildPythonPackage rec { substituteInPlace configure \ --replace-fail 'tput setaf $1' : \ --replace-fail 'tput sgr0' : + '' + + + # hardcode path to graphviz library to avoid find_library, which would require setting LD_LIBRARY_PATH + '' + substituteInPlace src/graph_tool/draw/graphviz_draw.py \ + --replace-fail \ + 'ctypes.util.find_library("gvc")' \ + '"${lib.getLib graphviz}/lib/libgvc${stdenv.hostPlatform.extensions.sharedLibrary}"' ''; configureFlags = diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index c83b9dde6d46..52da08753cf9 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -6422,7 +6422,7 @@ self: super: with self; { granian = callPackage ../development/python-modules/granian { }; - graph-tool = callPackage ../development/python-modules/graph-tool { inherit (pkgs) cgal; }; + graph-tool = callPackage ../development/python-modules/graph-tool { inherit (pkgs) cgal graphviz; }; grapheme = callPackage ../development/python-modules/grapheme { };