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]: Including matplotlib in 'extraPackages' leads to infinite recursion #338

Closed
collinarnett opened this issue Nov 2, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@collinarnett
Copy link

Current Behavior

{
  name,
  availableKernels,
  extraArgs,
}:
availableKernels.python {
  name = "jupyterWith-testing"; # must be unique
  displayName = "jupyterWith-testing";
  extraPackages = ps: [ ps.numpy ps.matplotlib ];
}

adding matplotlib to the example in the tutorial

leads to

$ nix run
warning: Using saved setting for 'extra-substituters = https://tweag-jupyter.cachix.org' from ~/.local/share/nix/trusted-settings.json.
warning: Using saved setting for 'extra-trusted-public-keys = tweag-jupyter.cachix.org-1:UtNH4Zs6hVUFpFBTLaA4ejYavPo5EFFqgd7G7FxGW9g=' from ~/.local/share/nix/trusted-settings.json.
warning: creating lock file '/home/collin/projects/jupyterWith-test/flake.lock'
error: infinite recursion encountered

       at /nix/store/fr68dr66gmggn62jir7vp1bcnignwxp9-source/pkgs/stdenv/generic/make-derivation.nix:311:7:

          310|       depsBuildBuild              = lib.elemAt (lib.elemAt dependencies 0) 0;
          311|       nativeBuildInputs           = lib.elemAt (lib.elemAt dependencies 0) 1;
             |       ^
          312|       depsBuildTarget             = lib.elemAt (lib.elemAt dependencies 0) 2;
(use '--show-trace' to show detailed location information)

Expected Behavior

Jupyter notebook with matplotlib and numpy available.

Steps To Reproduce

Add ps.matplotlib to extraPackages

Version

$ nix-shell -p nix-info --run "nix-info -m
"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.59, NixOS, 22.11 (Raccoon), 22.11.20221024.afd4752`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.11.0`
 - channels(collin): `""`
 - channels(root): `"nixos-21.11.335130.386234e2a61"`
 - nixpkgs: `/nix/store/msv8qjxnga8h81biz33gpa4pyw9kg0j1-source

Additional Context

This is probably related to nix-community/poetry2nix#750. I'm not sure how I feel about having poetry2nix under jupyterWith. In the past I've had many issues using poetry2nix. Trying to diagnose nix issues + poetry issues is a real headache with nix's non-descriptive error messages. The previous jupyterWith was convenient because I could just specify what packages I wanted without caring about what versions I wanted. I understand the documentation is still under construction so maybe there's a simple method to use jupyterWith like I did previously.

Relevant log output

No response

@collinarnett collinarnett added the bug Something isn't working label Nov 2, 2022
@djacu
Copy link
Contributor

djacu commented Nov 4, 2022

Hey 👋
Thanks for the bug report!

We noticed there were some issues recently and figure it is because we had not updated the top level flake.lock file in a while. We are actively working on updating all the kernels so they work again. You can see the progress in this branch:
https://github.com/tweag/jupyterWith/tree/update_flake_lock_action

I also had trouble getting matplotlib working on the new branch and using extraPackages. As you can see from this output.

$ nix run
error: attribute 'format' missing

       at /nix/store/cc1lfn4pzkl0b4g13qr943ddv8w8lsrs-source/pkgs/development/tools/poetry2nix/poetry2nix/overrides/default.nix:1463:40:

         1462|             ++ lib.optionals (self.isPyPy) [ tk xorg.libX11 ];
         1463|           preConfigure = lib.optional (old.format != "wheel") preConfigure;
             |                                        ^
         1464|         }
(use '--show-trace' to show detailed location information)

However, I was able to get it working using the other method mentioned in the TUTORIALS file.

kernels/mypython/default.nix

{
  name,
  availableKernels,
  extraArgs,
}:
availableKernels.python {
  projectDir = ./.;
  displayName = "my-python";
  name = "my-python";
}

kernels/mypython/pyproject.toml

[tool.poetry]
name = "my-python-kernel"
version = "0.1.0"
description = ""
authors = []

[tool.poetry.dependencies]
python = "^3.9"
ipykernel = "*"
numpy = "*"
scipy = "*"
matplotlib = "*"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

I was able to use all 3 packages (numpy, scipy, and matplotlib) in a notebook successfully.

@djacu
Copy link
Contributor

djacu commented Jan 21, 2023

This should be fixed with #415.
A new example kernel was added to the CI that pulls in numpy, scipy, and matplotlib via extraPackages. All seems to be working now.

@djacu djacu closed this as completed Jan 21, 2023
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