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

Update IHaskell.IPython.EasyKernel.installKernelspec to use jupyter instead of ipython #1403

Open
benrbray opened this issue Mar 15, 2023 · 1 comment

Comments

@benrbray
Copy link

benrbray commented Mar 15, 2023

I wanted to run the Calc and Simple examples found in the ipython-kernel/examples folder, and noticed that the installKernelspec function is calling ipython kernelspec ... (an outdated way of doing it) instead of jupyter kernelspec ... (the new way).

-- Install the kernelspec, using the `writeKernelspec` field of the kernel configuration.
installKernelspec :: MonadIO m
=> KernelConfig m output result -- ^ Kernel configuration to install
-> Bool -- ^ Whether to use Jupyter `--replace`
-> Maybe FilePath -- ^ (Optional) prefix to install into for Jupyter `--prefix`
-> m ()
installKernelspec config replace installPrefixMay =
liftIO $ withTmpDir $ \tmp -> do
let kernelDir = tmp </> languageName (kernelLanguageInfo config)
createDirectoryIfMissing True kernelDir
kernelSpec <- writeKernelspec config kernelDir
let filename = kernelDir </> "kernel.json"
BL.writeFile filename $ encode $ toJSON kernelSpec
let replaceFlag = ["--replace" | replace]
installPrefixFlag = maybe ["--user"] (\prefix -> ["--prefix", prefix]) installPrefixMay
cmd = concat [["kernelspec", "install"], installPrefixFlag, [kernelDir], replaceFlag]
void $ rawSystem "ipython" cmd
where
withTmpDir act = do
tmp <- getTemporaryDirectory
withTempDirectory tmp "easyKernel" act

Error

As-is, I get the following error when attempting to install the simple-calc-example kernel:

ben@zagreus:~/oss/IHaskell/ipython-kernel$ cabal run simple-calc-example -- install
Resolving dependencies...
Up to date
Installing kernelspec...
[TerminalIPythonApp] WARNING | Unrecognized alias: 'user', it will have no effect.
[TerminalIPythonApp] WARNING | File 'kernelspec' doesn't exist

When I change the string "ipython" to "jupyter", the kernel installs without any issue and I'm able to open it from a running Jupyter notebook server.

Proposed Change

  • call jupyter instead of ipython in installKernelspec and anywhere else the change is needed
  • (optional) update comments / function / package names to reflect the split between Jupyter and IPython.
    • this is a breaking change to the package names, though, so understandable if the renaming is rejected
    • however, Jupyter has been separate from IPython since 2014, so perhaps it would be more clear if IHaskell reflected this change

References

@vaibhavsagar
Copy link
Member

I don't want to rename the packages, but your other proposed changes seem reasonable to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants