jupyterlab / jupyterlab-desktop

JupyterLab desktop application, based on Electron.
BSD 3-Clause "New" or "Revised" License
3.76k stars 365 forks source link

Creating custom builds with alternative kernels #853

Open psychemedia opened 3 months ago

psychemedia commented 3 months ago

Is there a recipe for building custom Jupyter Desktop installers that bundle alternative kernels?

I am looking to distribute JupyterLab-Desktop to users in a limited permissions secure environment who only require access to an R kernel, and was wondering easy that might be with a custom built installer?

JasonWeill commented 3 months ago

@psychemedia Thanks for opening this! Creating a custom environment, such as with Anaconda's conda tool, should let you deploy JupyterLab Desktop and other packages for custom kernels. This is not likely to be a feature in JupyterLab Desktop itself, though. Would using a package manager solve this problem for you?

psychemedia commented 3 months ago

The issue is not so much installing a new kernel into an already downloaded JupyterLab distribution, it's more a case of building a distribution with a different kernel built in (and then most likely disabling the ability to install further packages).

I'm exploring solutions that can be used in secure environments (prison estates, essentially), so as you might imagine there are certain conditions attached with installing software depending on the prison category.

JasonWeill commented 3 months ago

Coincidentally, the previous issue (#852) asks about using JupyterLab Desktop in a completely offline/airgapped environment. On my macOS laptop, I tried using JupyterLab Desktop with no network connections at all, and it worked for me. I would expect that deploying a JupyterLab Desktop installation with additional kernels and configuration should be possible, but I'm not experienced with doing so.

See a Discourse thread, with a response by @minrk, here: https://discourse.jupyter.org/t/install-common-jupyterlab-extension-and-custom-kernel-in-jupyterhub/24442/2

psychemedia commented 3 months ago

Presumably we can install additional kernels via the server setup file? https://github.com/jupyterlab/jupyterlab-desktop/blob/master/env_installer/jlab_server.yaml

For example, for R: https://github.com/jupyter-xeus/xeus-r/ or https://anaconda.org/r/r-irkernel (do they include https://anaconda.org/r/r as a dependency?)

[UPDATE: simply adding xeus-r to the config file did not seem to result in an R kernel being registered within a custom JupyterLab-desktop build.]

What does https://github.com/jupyter-xeus/xeus-r/

Where we custom jupyter extensions be installed into the application? Into env_installer as pip dependencies? How could we then remove the pip installer?

mbektas commented 3 months ago

@psychemedia You can customize the bundled Python environment by updating the jlab_server.yaml as you guessed. You can add / remove packages to that file.

It is also possible to make changes to the environment configuration by placing files into env_installer/extras/ directory. See this page_config.json which disables the announcements extension.

You can refer to developer documentation for creating an installer locally.

psychemedia commented 3 months ago

@mbektas thanks. I tried adding the xeus R kernel to the server yaml and rebuilt the app but didn't see the r kernel listed as an option in the app?

mbektas commented 3 months ago

sorry I missed another command that needs to be called after updating the yaml. yarn update_conda_lock. I opened a test PR that adds xeus-r. Installers will be available here.

psychemedia commented 3 months ago

@mbektas Testing on my Mac, (osx-arm64), the downloaded application reports as broken when I try to run it.

image
mbektas commented 3 months ago

that alert is shown because the created installers are not code signed & notarized. We only sign & notarize installers that will be released. If you build locally, you shouldn't run into this issue. If you plan to distribute a customized JupyterLab Desktop installer for macOS you will need to sign and notarize yourself.

psychemedia commented 3 months ago

Ah, of course... so this maybe is the temp workaround: % xattr -d com.apple.quarantine /Applications/JupyterLab.app

And for local build: yarn create_env_installer:osx-arm64 && yarn dist:osx-arm64-dev (-dev removes signing requirement).