tweag / jupyenv

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

next/jupyterlab-extension-installation #271

Open djacu opened 2 years ago

djacu commented 2 years ago

Extension Installation Methods

There are two methods for installing JupyterLab extensions: pre-built and source. See JupyterLab Extensions documentation. There are some previous findings from my research here https://github.com/tweag/jupyterWith/issues/222.

Installing from Source

Installing from source will require Node.js and npm. I tried two methods: the Extensions Manager and CLI via jupyter labextension. Both methods failed.

When I tried using the Extensions Manager an error popped up with the following message:

Extension Installation Error

An error occurred installing code>@databeanstalk/jupyterlab-theme-solarized-dark</code.

Error message:

Please install Node.js and npm before continuing installation. You may be able to install Node.js from your package manager, from conda, or directly from the Node.js website (https://nodejs.org).

This was the error when I tried it through the CLI.

$ ./result/bin/jupyter labextension install @wwtelescope/jupyterlab
An error occurred.
ValueError: Please install Node.js and npm before continuing installation. You may be able to install Node.js from your package manager, from conda, or directly from the Node.js website (https://nodejs.org).
See the log file for details:  /tmp/jupyterlab-debug-b33f757o.log

Even if we provide Node.js and npm to the environment, the installation will still be stateful, and it still might not work because much of the jupyter environment has been moved to the nix store. I can see if it is possible, but long term, I don't think we should invest much in this method.

Installing from Pre-Built

Pre-built extensions can be installed with pip or conda. I checked in python39Packages for a few and did not find any. Using pip or conda is definitely not possible.

Roadmap

I see two things we can do.

  1. Establish some set of available extensions that ship with jupyterWith as mentioned in #72. Since pre-built extensions are available via pip and conda, we should be able to package them with poetry and make them available.
  2. Establish some method for end users to install extensions themselves. Regardless of the method chosen, it should be simple and easy for end users. I can foresee both options being necessary because pre-builts are much more simple but not always available and source installs are much more difficult. a. From source: I've already done some work, #222, figuring out what is needed to install an extension from source but it is still incomplete. I believe this option is viable. It does require a "JupyterLab rebuild" and I am not sure how messy that will be. b. From pre-built: We could write instructions on how users can package extensions with poetry and add them to their flakes. I can see issues being submitted because our own experience with poetry required lots of debugging and overlays. It may very well end up with users submitted issues for help and us adding them to the repo, but that would not be terrible. More available extensions is good thing right?
djacu commented 2 years ago

I tried adding nodejs and npm to the resulting jupyter lab environment via

jupyterEnvironment = (mkJupyterEnvFromKernelPath pkgs ./kernels).overrideAttrs (
  oa: {buildInputs = [pkgs.nodePackages.npm pkgs.nodejs];}
);

but the packages were not found.