NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.1k stars 14.15k forks source link

rPackages.altair installs, but is not usable #247274

Open Kupac opened 1 year ago

Kupac commented 1 year ago

Describe the bug

Altair installs as an R library, but can't produce plots, because the underlying python library is not found.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create a dev shell with R and rPackages.altair
  2. run R, load library
  3. try to reproduce one of the figures from the vignette

Expected behavior

Plot without errors.

Screenshots

library(altair)
alt$Chart()
#> Error: Python module altair was not found.
#> 
#> Detected Python configuration:

Additional context

Python was found because I was using radian:

reticulate::py_config()
#> python:         /nix/store/jhflvwr40xbb0xr6jx4311icp9cym1fp-python3-3.10.12/bin/python3.10
#> libpython:      /nix/store/jhflvwr40xbb0xr6jx4311icp9cym1fp-python3-3.10.12/lib/libpython3.10.so.1.0
#> pythonhome:     /nix/store/jhflvwr40xbb0xr6jx4311icp9cym1fp-python3-3.10.12:/nix/store/jhflvwr40xbb0xr6jx4311icp9cym1fp-python3-3.10.12
#> version:        3.10.12 (main, Jun  6 2023, 22:43:10) [GCC 12.3.0]
#> numpy:           [NOT FOUND]
#> altair:         [NOT FOUND]

In regular R console, even Python is missing, which is strange because altair depends on reticulate, which should depend on python.

We also have a related conversation with @cfhammill about that, and how reticulate doesn't find the right python lib: https://functional.cafe/@kupac/110826277110844252

Notify maintainers

@jbedo can you take a look at this?

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.29, NixOS, 23.05 (Stoat), 23.05.20230520.3005f20`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
jbedo commented 1 year ago

This is really due to reticulate and how to deal with that. I've been thinking about this recently (https://github.com/NixOS/nixpkgs/pull/244612) but it's not clear how to ensure python dependencies are available for packages like altair. We can't have multiple versions of reticulate with different package sets available, so we'd need to handle python deps with a fixed point and that requires some significant refactoring.