How to enable optional deps in python apps

How can I install a python package with its optional dependencies as a package in home-manager?
For example I’m trying to install litellm[proxy]. I was hoping I can override python and do a:

    (pkgs.python3Packages.litellm.override {
      python = pkgs.python.withPackages(ps: pkgs.python3Packages.litellm.optional-dependencies.proxy);
    }) 

But it doesn’t look like packages take python as an argument.

I could try:

    (pkgs.python3Packages.litellm.overrideAttrs {
      dependencies = pkgs.python3Packages.litellm.dependencies ++ pkgs.python3Packages.litellm.passthru.optional-dependencies.proxy;
    })

which feels very awkward. (edit: and doesn’t actually work)

Am I missing some obvious and simple way to achieve this?

overrideAttrs won’t work, you’d use overridePythonAttrs here

1 Like

I assume this works

python3.withPackages (ps: with ps; [
  litellm
  litellm.optional-dependencies.proxy
])