diff --git a/pkgs/development/python-modules/graph-tool/default.nix b/pkgs/development/python-modules/graph-tool/default.nix index 5dc014626300..f455258ea14b 100644 --- a/pkgs/development/python-modules/graph-tool/default.nix +++ b/pkgs/development/python-modules/graph-tool/default.nix @@ -2,14 +2,16 @@ buildPythonPackage, lib, fetchurl, + fetchpatch, stdenv, - boost, + boost189, cairomm, cgal, expat, - gmp, + fontconfig, gobject-introspection, + graphviz, gtk3, llvmPackages, matplotlib, @@ -21,11 +23,22 @@ python, scipy, sparsehash, + zstandard, gitUpdater, }: 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; }; @@ -33,50 +46,77 @@ 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' : + '' + + + # 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 = [ - "--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}"; + } + ++ + 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; - 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 - gtk3 - matplotlib mpfr - numpy - pycairo - pygobject3 - scipy sparsehash ] ++ lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ]; - pythonImportsCheck = [ "graph_tool" ]; + dependencies = [ + gtk3 + matplotlib + numpy + pycairo + pygobject3 + scipy + zstandard + ]; + + propagatedNativeBuildInputs = [ gobject-introspection ]; + + 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"; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 59cd56ae87ec..434a4fc41ee5 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -6444,7 +6444,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 { };