From ea651fa6314e17bcff35af51397e2a145bcd3f35 Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Sun, 14 Sep 2025 13:45:51 +0200 Subject: [PATCH] python3Packages.qdldl: fix for CMake v4 by properly using our qdldl, and, while here, fixing its CMake exports --- pkgs/by-name/qd/qdldl/package.nix | 7 ++ .../python-modules/qdldl/default.nix | 13 +++ .../python-modules/qdldl/use-qdldl.patch | 93 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 +- 4 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/python-modules/qdldl/use-qdldl.patch diff --git a/pkgs/by-name/qd/qdldl/package.nix b/pkgs/by-name/qd/qdldl/package.nix index bacdab3305e5..c88db5f6f18b 100644 --- a/pkgs/by-name/qd/qdldl/package.nix +++ b/pkgs/by-name/qd/qdldl/package.nix @@ -16,6 +16,13 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-pRlxqy5G8mxKXTIn4ruV/95TzpzNB/ArJX+WrEJRqW4="; }; + # fix abs dir concatenation + postPatch = '' + substituteInPlace CMakeLists.txt --replace-fail \ + "$/$""{CMAKE_INSTALL_INCLUDEDIR}" \ + "$""{CMAKE_INSTALL_INCLUDEDIR}" + ''; + nativeBuildInputs = [ cmake ]; diff --git a/pkgs/development/python-modules/qdldl/default.nix b/pkgs/development/python-modules/qdldl/default.nix index f128b8fd399d..e64e54f03eba 100644 --- a/pkgs/development/python-modules/qdldl/default.nix +++ b/pkgs/development/python-modules/qdldl/default.nix @@ -2,12 +2,14 @@ lib, buildPythonPackage, fetchFromGitHub, + replaceVars, cmake, numpy, pybind11, setuptools, scipy, pytestCheckHook, + qdldl, }: buildPythonPackage rec { @@ -22,6 +24,13 @@ buildPythonPackage rec { hash = "sha256-XHdvYWORHDYy/EIqmlmFQZwv+vK3I+rPIrvcEW1JyIw="; }; + # use up-to-date qdldl for CMake v4 + patches = [ + (replaceVars ./use-qdldl.patch { + inherit qdldl; + }) + ]; + dontUseCmakeConfigure = true; build-system = [ @@ -36,6 +45,10 @@ buildPythonPackage rec { scipy ]; + propagatedBuildInputs = [ + qdldl + ]; + pythonImportsCheck = [ "qdldl" ]; nativeCheckInputs = [ pytestCheckHook ]; diff --git a/pkgs/development/python-modules/qdldl/use-qdldl.patch b/pkgs/development/python-modules/qdldl/use-qdldl.patch new file mode 100644 index 000000000000..7a8dd7b46f0e --- /dev/null +++ b/pkgs/development/python-modules/qdldl/use-qdldl.patch @@ -0,0 +1,93 @@ +From 0293de5a5bd209386b3c021ee661e85eee1985a9 Mon Sep 17 00:00:00 2001 +From: Guilhem Saurel +Date: Sun, 21 Sep 2025 14:55:32 +0200 +Subject: [PATCH] Use up-to-date qdldl for CMake v4 + +--- + c/CMakeLists.txt | 5 +++-- + c/amd/include/SuiteSparse_config.h | 2 +- + c/amd/include/perm.h | 2 +- + cpp/qdldl.hpp | 2 +- + setup.py | 3 ++- + 5 files changed, 8 insertions(+), 6 deletions(-) + +diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt +index 728204d..df15d84 100644 +--- a/c/CMakeLists.txt ++++ b/c/CMakeLists.txt +@@ -12,7 +12,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) + + set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/out) + +-add_subdirectory(qdldl EXCLUDE_FROM_ALL) ++find_package(qdldl REQUIRED CONFIG) + + set( + amd_src +@@ -37,7 +37,8 @@ set( + + + # Add QDLDL+AMD library +-add_library(qdldlamd STATIC ${amd_src} $) ++add_library(qdldlamd STATIC ${amd_src}) ++target_link_libraries(qdldlamd qdldl::qdldl) + target_include_directories(qdldlamd PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/amd/include + ${CMAKE_CURRENT_SOURCE_DIR}/qdldl/include +diff --git a/c/amd/include/SuiteSparse_config.h b/c/amd/include/SuiteSparse_config.h +index ea3cea4..19ac8df 100644 +--- a/c/amd/include/SuiteSparse_config.h ++++ b/c/amd/include/SuiteSparse_config.h +@@ -42,7 +42,7 @@ + extern "C" { + #endif + +-#include "qdldl_types.h" ++#include "qdldl/qdldl_types.h" + #define DLONG + typedef QDLDL_float c_float; + +diff --git a/c/amd/include/perm.h b/c/amd/include/perm.h +index 16c2617..841abe1 100644 +--- a/c/amd/include/perm.h ++++ b/c/amd/include/perm.h +@@ -2,7 +2,7 @@ + extern "C" { + # endif // ifdef __cplusplus + +-#include "qdldl_types.h" ++#include "qdldl/qdldl_types.h" + + /** + * C = A(p,p)= PAP' where A and C are symmetric the upper part stored; +diff --git a/cpp/qdldl.hpp b/cpp/qdldl.hpp +index 83b4970..1a7b5d1 100644 +--- a/cpp/qdldl.hpp ++++ b/cpp/qdldl.hpp +@@ -1,5 +1,5 @@ + // Source code for QDLDL, AMD and permutations +-#include "qdldl/include/qdldl.h" ++#include "qdldl/qdldl.h" + #include "amd/include/amd.h" + #include "amd/include/perm.h" + #include +diff --git a/setup.py b/setup.py +index edb50ed..c0e4c23 100644 +--- a/setup.py ++++ b/setup.py +@@ -97,10 +97,11 @@ class build_ext_qdldl(build_ext): + qdldl = Extension('qdldl', + sources=glob(os.path.join('cpp', '*.cpp')), + include_dirs=[os.path.join('c'), +- os.path.join('c', 'qdldl', 'include'), ++ "@qdldl@/include", + get_pybind_include(), + get_pybind_include(user=False)], + language='c++', ++ extra_link_args=['-lqdldl'], + extra_compile_args=compile_args + ['-std=c++11'], + extra_objects=[qdldl_lib]) + +-- +2.51.0 + diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 8b6c87566660..6d19e5b35a09 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -15469,7 +15469,7 @@ self: super: with self; { qdarkstyle = callPackage ../development/python-modules/qdarkstyle { }; - qdldl = callPackage ../development/python-modules/qdldl { }; + qdldl = callPackage ../development/python-modules/qdldl { inherit (pkgs) qdldl; }; qdrant-client = callPackage ../development/python-modules/qdrant-client { };