From 794348a645f2fe34667e70f00f561b4f045c832a Mon Sep 17 00:00:00 2001 From: Hugo McNally Date: Tue, 24 Jun 2025 16:10:12 +0100 Subject: [PATCH] pythonPackages.cocotb: Ensure the required dynamic libraries are stated cocotb uses dlopen so that it's dynamic libraries are python version agnostic. Here we patch its dynamic libraries to make sure the correct libpython is found and used. --- pkgs/development/python-modules/cocotb/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/development/python-modules/cocotb/default.nix b/pkgs/development/python-modules/cocotb/default.nix index f69e6f81827c..5b25f03143ca 100644 --- a/pkgs/development/python-modules/cocotb/default.nix +++ b/pkgs/development/python-modules/cocotb/default.nix @@ -4,6 +4,7 @@ fetchFromGitHub, setuptools, setuptools-scm, + python, cocotb-bus, find-libpython, pytestCheckHook, @@ -46,6 +47,14 @@ buildPythonPackage rec { substituteInPlace setup.py --replace "'cocotb-bus<1.0'" "" ''; + # cocotb uses dlopen so that it's dynamic libraries are python version agnostic. + # Here we patch its dynamic libraries to make sure the correct libpython is found and used. + preFixup = lib.optionalString stdenv.hostPlatform.isLinux '' + for lib in $out/lib/python*/site-packages/cocotb/libs/*.so; do + patchelf --add-rpath ${python}/lib --add-needed libpython3.so $lib + done + ''; + disabledTests = [ # https://github.com/cocotb/cocotb/commit/425e1edb8e7133f4a891f2f87552aa2748cd8d2c#diff-4df986cbc2b1a3f22172caea94f959d8fcb4a128105979e6e99c68139469960cL33 "test_cocotb"