All I want to do is try out a Python package, spacy-wordnet. But it’s not in nixpkgs, so here we go on an epic journey.
The readme says to run: pip install spacy-wordnet
. But that apparently doesn’t work on NixOS.
And pypi2nix
is broken. So I turn to poetry2nix
. I create a new Poetry project with poetry init
, then poetry add spacy-wordnet
. Then I add a default.nix that looks like this:
{ pkgs ? import <nixpkgs> {} }:
let
myAppEnv = pkgs.poetry2nix.mkPoetryEnv {
projectDir = ./.;
editablePackageSources = {
my-app = ./src;
};
};
in myAppEnv.env
per instructions in poetry2nix. That fails with pip._internal.exceptions.InstallationSubprocessError: Command errored out with exit status 1
So I try to get together a nix expression for it. There’s no resolver, apparently, so I have to declare each of the individual dependencies, and write build instructions for each of the dependencies, too.
So now I’m not only packaging spacy-wordnet, I’m packaging pyscaffold
, and pyscaffold’s dependency configupdater
. And probably more.
with import <nixpkgs> {};
( let
spacyWordnet = pkgs.python3Packages.buildPythonPackage rec {
pname = "spacy-wordnet";
version = "0.0.5";
src = pkgs.python3Packages.fetchPypi {
inherit version;
inherit pname;
sha256 = "bErMjM0VIsQHnPFoEe80fPClpJyiCyNBuapegMgcPbc=";
};
propagatedBuildInputs = with pkgs.python3Packages; [ nltk spacy pyscaffold ];
doCheck = false;
};
pyscaffold = pkgs.python3Packages.buildPythonPackage rec {
pname = "PyScaffold";
version = "4.2.1";
src = pkgs.python3Packages.fetchPypi {
inherit version;
inherit pname;
sha256 = "yM+pmDUD8xswH0sL7AqPQVGPmjo4U0cc6U+fncdwo+I=";
};
propagatedBuildInputs = with pkgs.python3Packages; [ setuptools-scm configupdater ];
doCheck = false;
};
configupdater = pkgs.python3Packages.buildPythonPackage rec {
pname = "configupdater";
version = "3.1";
src = pkgs.python3Packages.fetchPypi {
inherit version;
pname = "ConfigUpdater";
sha256 = "3cxSUPUIuRMcRf0dvOrj8RKQfd11l9oc/zDFG/fIfts=";
};
propagatedBuildInputs = with pkgs.python3Packages; [ ];
doCheck = false;
};
in pkgs.python3.buildEnv.override rec {
extraLibs = with pkgs.python3Packages; [
spacy
spacyWordnet
pandas
# spacy_models.en_core_web_lg
scikitlearn
nltk
altair
numpy
];
}).env
This doesn’t work because it says that configupdater
is missing for pyscaffold
. But it’s clearly there.
And so then I notice that I’m many hours into this packaging problem, and all I want to do is just try out one stupid python package. Why is this so hard to do on NixOS? Am I just supposed to use Docker for everything?
What do Python developers do on NixOS? Does everyone just do development in an Ubuntu VM? I’m at my wits’ end here.