Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AlexChalk opened this issue Jun 2, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@AlexChalk
Copy link

AlexChalk commented Jun 2, 2024

Current Behavior

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

  • The issue seems to be how pip is specified in the dependency tree.
  • poetry + fastai builds fine for a poetryEnv like the following, although this isn't creating an ipython kernel:
  outputs = { self, nixpkgs, poetry2nix }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
      inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryEnv ;
    in
    {
      packages.${system} = {
        my-package = mkPoetryEnv {
          projectDir = self;
        };
        default = self.packages.${system}.my-package;
      };
     ....

(link to complete example repo that does create kernel)

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

  • I see the same behaviour with nixos-24.05 and nixos-23.11.
  • I also see the same behaviour with every jupyenv commit hash up to 3ad2c9512c9efd586cf63adde454e734a8ce049c.

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)
@AlexChalk AlexChalk added the bug Something isn't working label Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants