joouha / euporie

Jupyter notebooks in the terminal
https://euporie.readthedocs.io
MIT License
1.54k stars 36 forks source link

Xonsh support #63

Closed anki-code closed 1 year ago

anki-code commented 1 year ago

Hi! Thank you for the awesome tool! Is there a way to use xonsh shell language in the cells? Thanks!

For community

⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

joouha commented 1 year ago

Hi,

This should "just work" by installing xonsh's Jupyter kernel and selecting the "xonsh" kernel in euporie.

However, it looks like there is currently an unresolved bug in the xonsh kernel which prevents it from working properly in the latest version of xonsh.

joouha commented 1 year ago

With xonsh_jupyter fixed as per https://github.com/xonsh/xontrib-jupyter/pull/10, if you change your kernel to xonsh, you can run xonsh in euporie:

image

However, testing this has thrown up a couple of bugs in euporie:

anki-code commented 1 year ago

Wow! Looks awesome! Thanks! I will share this to the xonsh community.

anki-code commented 1 year ago

@joouha feel free to add xonsh or/and xontrib topics to the repository settings.

joouha commented 1 year ago

Wow! Looks awesome! Thanks! I will share this to the xonsh community.

Thanks! It won't work out-of-the-box just yet, I still need to fix some bugs and make a new release, but I'll update here when everything works as expected.

anki-code commented 1 year ago

Ok! I will wait the next release. Thanks!

anki-code commented 1 year ago

I've added:

Todo:

Thank you for your efforts to support xonsh!

joouha commented 1 year ago

I've made a new release v2.3.2 which has all the fixes mentioned above.

With the fixes to xontrib-jupyter-shell, xonsh now works really nicely in euporie 🏆

anki-code commented 1 year ago

I've posted news:

  1. to the xonsh channel on gitter:
image
  1. to our new account on mastodon:
image
anki-code commented 1 year ago

Mentioned Euporie in xonsh 0.14 release.

@joouha if you have time please test xontrib-jupyter. I tried to run it with Euporie and sometimes when I run just ls in the cell I have no result in output.

joouha commented 1 year ago

You'll notice that xonsh commands implemented in Python return output, while there is no output from external commands.

This is because the xonsh kernel isn't capturing the stdout of subprocesses spawned by xonsh properly.

joouha commented 1 year ago

I've had a quick look, and it looks like xonsh transforms subproc-mode input lines into uncaptured subprocess calls, which get sent to stdout and are not captured by the kernel.

If you set the XONSH_CAPTURE_ALWAYS environment variable to True, it will work as expected.

I'll make a PR to set this be default in the xonsh kernel.

anki-code commented 1 year ago

Thanks! XONSH_CAPTURE_ALWAYS is False by made decision and PR is not needed. We just need to add this to docs around jupyter xontrib.

joouha commented 1 year ago

It looks to me like the current default value of XONSH_CAPTURE_ALWAYS is False - it HAS to be True for xonsh kernel to capture subprocess output properly, so I think the PR is needed.

anki-code commented 1 year ago

Ah, you mean PR into xontrib-jupyter. Yep, agree. Thanks!

joouha commented 1 year ago

Yes, I meant this one:

https://github.com/xonsh/xontrib-jupyter/pull/21

:-)