tweag / jupyenv

Declarative and reproducible Jupyter environments - powered by Nix
https://jupyenv.io/
MIT License
627 stars 131 forks source link

[Bug]: poetry + fastai fails with "error: infinite recursion encountered" #542

Open AlexChalk opened 1 month ago

AlexChalk commented 1 month ago

Current Behavior

poetry + fastai build fails with "error: infinite recursion encountered".

Expected Behavior

Build completes successfully.

Steps To Reproduce

mkdir my-project
cd my-project
nix flake init --template github:tweag/jupyenv

then, in kernels.nix:

{ pkgs, ... }: {
  kernel.python.minimal = {
    enable = true;
    projectDir = ./my-custom-python;
  };
}

then

mkdir my-custom-python
cd my-custom-python
cat <<'EOF' > ./pyproject.toml
[tool.poetry]
name = "jupyter-nix-kernel-ipython"
version = "0.1.0"
description = ""
authors = []

[tool.poetry.dependencies]
python = "^3.9"
numpy = "^1.23.0"
ipykernel = "^6.15.0"
fastai = "^2.7.15"

[tool.poetry.dev-dependencies]
# build systems for dependencies
hatchling = "^1.3.1"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
EOF
cat <<'EOF' > ./poetry.toml
[virtualenvs]
create = false
EOF
nix-shell -p poetry --run "poetry update --lock"
cd ..
nix flake update
nix build

OS

- system: `"x86_64-linux"`
 - host os: `Linux 6.6.32, NixOS, 24.11 (Vicuña), 24.11pre632549.ad57eef4ef06`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - channels(root): `"nixos, nixos-hardware, nixos-stable-24.05, nixos-unstable"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Version

inputs.jupyenv.url = "github:tweag/jupyenv"

Additional Context

Relevant log output

error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'wrapper-chmod-python3-3.10.9-env'
         whose name attribute is located at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/stdenv/generic/make-derivation.nix:279:7

       … while evaluating attribute 'buildCommand' of derivation 'wrapper-chmod-python3-3.10.9-env'

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/build-support/trivial-builders.nix:82:14:

           81|       enableParallelBuilding = true;
           82|       inherit buildCommand name;
             |              ^
           83|       passAsFile = [ "buildCommand" ]

       … while evaluating derivation 'python-machine-learning-jupyter-kernel'
         whose name attribute is located at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/stdenv/generic/make-derivation.nix:279:7

       … while evaluating attribute 'buildCommand' of derivation 'python-machine-learning-jupyter-kernel'

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/build-support/trivial-builders.nix:82:14:

           81|       enableParallelBuilding = true;
           82|       inherit buildCommand name;
             |              ^
           83|       passAsFile = [ "buildCommand" ]

       … from call site

         at /nix/store/2lnahmiii1pzwsy28ccw04jf91x3mqfh-source/lib/jupyter.nix:121:10:

          120|       ''
          121|       + (kernelLib.copyKernelSpec kernelLogos kernelInstance)
             |          ^
          122|       + (kernelLib.copyKernelLogos kernelLogos kernelInstance)

       … while calling 'copyKernelSpec'

         at /nix/store/2lnahmiii1pzwsy28ccw04jf91x3mqfh-source/lib/kernels.nix:280:33:

          279|   */
          280|   copyKernelSpec = kernelLogos: kernelInstance: let
             |                                 ^
          281|     kernelSpec = createKernelSpec kernelLogos kernelInstance;

       … while evaluating derivation 'wrapper-python3-3.10.9-env'
         whose name attribute is located at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/stdenv/generic/make-derivation.nix:279:7

       … while evaluating attribute 'buildCommand' of derivation 'wrapper-python3-3.10.9-env'

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/build-support/trivial-builders.nix:82:14:

           81|       enableParallelBuilding = true;
           82|       inherit buildCommand name;
             |              ^
           83|       passAsFile = [ "buildCommand" ]

       … while evaluating derivation 'python3-3.10.9-env'
         whose name attribute is located at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/stdenv/generic/make-derivation.nix:279:7

       … while evaluating attribute 'passAsFile' of derivation 'python3-3.10.9-env'

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/build-support/trivial-builders.nix:83:7:

           82|       inherit buildCommand name;
           83|       passAsFile = [ "buildCommand" ]
             |       ^
           84|         ++ (derivationArgs.passAsFile or []);

       … from call site

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/development/interpreters/python/wrapper.nix:20:13:

           19|   env = let
           20|     paths = requiredPythonModules (extraLibs ++ [ python ] ) ;
             |             ^
           21|     pythonPath = "${placeholder "out"}/${python.sitePackages}";

       … while calling 'requiredPythonModules'

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/development/interpreters/python/python-packages-base.nix:50:27:

           49|   # Get list of required Python modules given a list of derivations.
           50|   requiredPythonModules = drvs: let
             |                           ^
           51|     modules = lib.filter hasPythonModule drvs;

       … from call site

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/development/interpreters/python/with-packages.nix:3:19:

            2|
            3| f: let packages = f pythonPackages; in buildEnv.override { extraLibs = packages; }
             |                   ^
            4|

       … while calling anonymous lambda

         at /nix/store/56ab52irgf1r1j2qydba0094pw2x0sja-source/default.nix:367:39:

          366|     in
          367|     poetryPython.python.withPackages (ps: envPkgs ++ (extraPackages ps));
             |                                       ^
          368|

       … from call site

         at /nix/store/56ab52irgf1r1j2qydba0094pw2x0sja-source/default.nix:294:23:

          293|       */
          294|       storePackages = requiredPythonModules (builtins.foldl' (acc: v: acc ++ v) [ ] (lib.attrValues inputAttrs));
             |                       ^
          295|     in

       … while calling 'requiredPythonModules'

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/development/interpreters/python/python-packages-base.nix:50:27:

           49|   # Get list of required Python modules given a list of derivations.
           50|   requiredPythonModules = drvs: let
             |                           ^
           51|     modules = lib.filter hasPythonModule drvs;

       … from call site

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/development/interpreters/python/python-packages-base.nix:67:33:

           66|         pythonPath = [ ]; # Deprecated, for compatibility.
           67|         requiredPythonModules = requiredPythonModules drv.propagatedBuildInputs;
             |                                 ^
           68|       };

       … while calling 'requiredPythonModules'

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/development/interpreters/python/python-packages-base.nix:50:27:

           49|   # Get list of required Python modules given a list of derivations.
           50|   requiredPythonModules = drvs: let
             |                           ^
           51|     modules = lib.filter hasPythonModule drvs;

       … from call site

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/development/interpreters/python/python-packages-base.nix:67:33:

           66|         pythonPath = [ ]; # Deprecated, for compatibility.
           67|         requiredPythonModules = requiredPythonModules drv.propagatedBuildInputs;
             |                                 ^
           68|       };

       … while calling 'requiredPythonModules'

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/development/interpreters/python/python-packages-base.nix:50:27:

           49|   # Get list of required Python modules given a list of derivations.
           50|   requiredPythonModules = drvs: let
             |                           ^
           51|     modules = lib.filter hasPythonModule drvs;

       … while calling anonymous lambda

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/lib/lists.nix:646:25:

          645|    */
          646|   unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) [];
             |                         ^
          647|

       … while evaluating derivation 'python3.10-packaging-24.0'
         whose name attribute is located at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/stdenv/generic/make-derivation.nix:279:7

       … while evaluating attribute 'nativeBuildInputs' of derivation 'python3.10-packaging-24.0'

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/stdenv/generic/make-derivation.nix:319:7:

          318|       depsBuildBuild              = lib.elemAt (lib.elemAt dependencies 0) 0;
          319|       nativeBuildInputs           = lib.elemAt (lib.elemAt dependencies 0) 1;
             |       ^
          320|       depsBuildTarget             = lib.elemAt (lib.elemAt dependencies 0) 2;

       … while evaluating derivation 'pip-install-hook'
         whose name attribute is located at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/stdenv/generic/make-derivation.nix:279:7

       … while evaluating attribute 'buildCommand' of derivation 'pip-install-hook'

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/build-support/trivial-builders.nix:82:14:

           81|       enableParallelBuilding = true;
           82|       inherit buildCommand name;
             |              ^
           83|       passAsFile = [ "buildCommand" ]

       … from call site

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/build-support/trivial-builders.nix:576:12:

          575|         cp ${script} $out/nix-support/setup-hook
          576|       '' + lib.optionalString (deps != []) ''
             |            ^
          577|         printWords ${toString deps} > $out/nix-support/propagated-build-inputs

       … while calling 'optionalString'

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/lib/strings.nix:214:5:

          213|     # String to return if condition is true
          214|     string: if cond then string else "";
             |     ^
          215|

       … while evaluating derivation 'python3.10-pip-24.0'
         whose name attribute is located at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/stdenv/generic/make-derivation.nix:279:7

       … while evaluating attribute 'nativeBuildInputs' of derivation 'python3.10-pip-24.0'

         at /nix/store/lzgxbh8c61phbh074y2707l2yw6vvaa1-source/pkgs/stdenv/generic/make-derivation.nix:319:7:

          318|       depsBuildBuild              = lib.elemAt (lib.elemAt dependencies 0) 0;
          319|       nativeBuildInputs           = lib.elemAt (lib.elemAt dependencies 0) 1;
             |       ^
          320|       depsBuildTarget             = lib.elemAt (lib.elemAt dependencies 0) 2;

       error: infinite recursion encountered

       at «none»:0: (source not available)