unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: 64990@debbugs.gnu.org
Cc: dan.munteanu@mdc-berlin.de
Subject: bug#64990: jupyter kernels install kernel.json without GUIX_PYTHONPATH
Date: Tue, 01 Aug 2023 13:38:42 +0200	[thread overview]
Message-ID: <87v8dz7yep.fsf@elephly.net> (raw)

Consider this scenario: a number of users access a shared jupyterhub /
jupyterlab installation, which allows them to launch their own jupyter
kernels.  The shared installation was deployed with Guix.  The user
kernels are installed like this:

    $ guix shell python python-ipykernel python-foo python-bar …
    $ [env] python3 -m ipykernel install --user --name whatever --display-name whatever
    Installed kernelspec whatever in /home/rekado/.local/share/jupyter/kernels/whatever

The installed kernel.json looks like this:

--8<---------------cut here---------------start------------->8---
{
 "argv": [
  "/gnu/store/…-profile/bin/python3",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "whatever",
 "language": "python",
 "metadata": {
  "debugger": true
 }
]
--8<---------------cut here---------------end--------------->8---

That’s not sufficient because the “ipykernel_launcher” module is
provided by the python-ipykernel package and the shared jupyter{hub,lab}
doesn’t know about this package.  That’s because it doesn’t use the
GUIX_PYTHONPATH of the profile containing the user’s packages.

Perhaps we could add a profile hook that adds an “env” field to the
generated kernel.json file, which augments the existing GUIX_PYTHONPATH
with the appropriate value for the current profile.

We can do this on the command line like this:

--8<---------------cut here---------------start------------->8---
  python3 -m ipykernel install \
    --user --name whatever --display-name whatever \
    --env GUIX_PYTHONPATH "${GUIX_PYTHONPATH}:\${GUIX_PYTHONPATH}"
--8<---------------cut here---------------end--------------->8---

Or we can edit the JSON directly.

The documentation of the kernel.json format is available here:
https://jupyter-client.readthedocs.io/en/stable/kernels.html#kernel-specs

-- 
Ricardo




                 reply	other threads:[~2023-08-01 12:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v8dz7yep.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=64990@debbugs.gnu.org \
    --cc=dan.munteanu@mdc-berlin.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).