[SOLVED] Python: Need to exclude runtime dependency when built on Darwin

EDIT: Solved by making the library a conditional import in the scalene project:

"nvidia-ml-py>=12.555.43; platform_system != 'Darwin'"

The Python 3.12 migration uncovered an issue in scalene – a Python runtime profiler with extremely low overhead.

The problem is that scalene depends on python3.pkgs.nvidia-ml-py on everything but Darwin, and that dependency only builds on x86-64. So I need a way to make this dependency conditional.

Here’s the work in progress:

# ... omitted ...

propagatedBuildInputs = [
  ] ++ lib.optionals stdenv.hostPlatform.isLinux [
    nvidia-ml-py # only avilable on x86_64-linux. Scalene only loads this there.

# ... omitted ...

  pythonRuntimeDeps = [] ++ lib.optionals stdenv.hostPlatform.isLinux [

# ... 

But the runtime dependencies check fails when built on Darwin (it still wants the nvidia package).

How do I make this work?