devenv icon indicating copy to clipboard operation
devenv copied to clipboard

Best way to add sys dependencies of Python libraries?

Open YPares opened this issue 1 year ago • 5 comments
trafficstars

I'm making a devenv setup to provide python and spaCy (which depends on zlib and libstdc++). I ended up with:

# devenv.nix
{ pkgs, ... }:
{
  packages = [ pkgs.zlib pkgs.stdenv ];

  languages.python.enable = true;
  languages.python.version = "3.11";
  languages.python.venv.enable = true;
  languages.python.venv.requirements = ./requirements.txt;

  enterShell = "export LD_LIBRARY_PATH=${pkgs.zlib}/lib:${pkgs.stdenv.cc.cc.lib}/lib:$LD_LIBRARY_PATH";
}
# requirements.txt
spacy==3.7

Is that the recommended way to do so? (Ideally I'd like nix itself to provide spaCy, so it and its dependencies are locked along with the rest of the config, but adding it to packages resulted in build errors)

YPares avatar May 24 '24 08:05 YPares