From de3593489c6864665099e6337e4c482c99c2efe7 Mon Sep 17 00:00:00 2001 From: Ethan Rooke Date: Sun, 26 Feb 2023 23:03:32 -0600 Subject: [PATCH 1/3] Document ModuleNotFoundError Poetry does not lock down information about the build system used to build dependencies. As such poetry2nix cannot automatically figure out build inputs. https://github.com/nix-community/poetry2nix/issues/568 This documents how to help poetry2nix out with figuring out buildinputs. --- docs/documentation/how-to.md | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/docs/documentation/how-to.md b/docs/documentation/how-to.md index 28e19b77..12eaf981 100644 --- a/docs/documentation/how-to.md +++ b/docs/documentation/how-to.md @@ -149,6 +149,51 @@ kernel.python.python-with-numpy.projectDir = ./my-custom-python; Eventually, you will see the recognizable messages from JupyterLab in your terminal. Open up the Web UI in your browser and use your custom kernel. +??? question "Did something go wrong?" + + If nix fails to build a kernel with an error like the following. + + ```shell + error: builder for '/nix/store/y44r14sxadnk0pccy8ciz8p1g6wpwbzq-python3.10-pathspec-0.11.0.drv' failed with exit code 2; + last 10 log lines: + > File "", line 1050, in _gcd_import + > File "", line 1027, in _find_and_load + > File "", line 992, in _find_and_load_unlocked + > File "", line 241, in _call_with_frames_removed + > File "", line 1050, in _gcd_import + > File "", line 1027, in _find_and_load + > File "", line 1004, in _find_and_load_unlocked + > ModuleNotFoundError: No module named 'flit_core' + ``` + + There is some python package with a build dependency that poetry2nix is + unaware about. To fix this you need to tell jupyenv about the dependency + through an override. Create an `overrides.nix`. + + ```nix title="overrides.nix" + final: prev: let + addNativeBuildInputs = drvName: inputs: { + "${drvName}" = prev.${drvName}.overridePythonAttrs ( + old: { + nativeBuildInputs = (old.nativeBuildInputs or []) ++ inputs; + } + ); + }; + in + {} // addNativeBuildInputs "pathspec" [final.flit-core] + ``` + + Note we used `"pathspec"` here as that was the package which generated the + error and `final.flit-core` as that was the missing module.Add the override + to your kernel. + + ```nix title="kernels.nix" + kernel.python.python-with-numpy.overrides = overrides.nix; + ``` + + Start the jupyter environment with `nix run`. + + ### Julia kernel The Julia kernel requires some stateful operations to work properly. From 9823b090dee5ec7bf4e291a1df5cfeb57ee1fddc Mon Sep 17 00:00:00 2001 From: Ethan Rooke Date: Thu, 2 Mar 2023 07:51:44 -0600 Subject: [PATCH 2/3] Use path syntax for including the overrides.nix --- docs/documentation/how-to.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/documentation/how-to.md b/docs/documentation/how-to.md index 12eaf981..e5fe9713 100644 --- a/docs/documentation/how-to.md +++ b/docs/documentation/how-to.md @@ -188,7 +188,7 @@ kernel.python.python-with-numpy.projectDir = ./my-custom-python; to your kernel. ```nix title="kernels.nix" - kernel.python.python-with-numpy.overrides = overrides.nix; + kernel.python.python-with-numpy.overrides = ./overrides.nix; ``` Start the jupyter environment with `nix run`. From 44beaace809b5b44238eb05e682b22c2945fd94f Mon Sep 17 00:00:00 2001 From: Ethan Rooke Date: Sat, 4 Mar 2023 13:38:49 -0600 Subject: [PATCH 3/3] Use generic placeholder --- docs/documentation/how-to.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/documentation/how-to.md b/docs/documentation/how-to.md index e5fe9713..d09fe656 100644 --- a/docs/documentation/how-to.md +++ b/docs/documentation/how-to.md @@ -184,11 +184,11 @@ kernel.python.python-with-numpy.projectDir = ./my-custom-python; ``` Note we used `"pathspec"` here as that was the package which generated the - error and `final.flit-core` as that was the missing module.Add the override + error and `final.flit-core` as that was the missing module. Add the override to your kernel. ```nix title="kernels.nix" - kernel.python.python-with-numpy.overrides = ./overrides.nix; + kernel.python..overrides = ./overrides.nix; ``` Start the jupyter environment with `nix run`.