Skip to content

Commit

Permalink
ENH Work around IPython regression
Browse files Browse the repository at this point in the history
Jug shell fails in newer versions of IPython, see ipython/ipython#13966
  • Loading branch information
luispedro committed May 11, 2023
1 parent dee23ce commit d647c15
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Expand Up @@ -5,6 +5,8 @@ Unreleased
subcommands)
* Fix message in `jug shell` when there are no dependencies (it would
repeatedly print the message stating "this will only be run once")
* jug pack: Make it much faster to invalidate elements
* jug shell: Fix for newer versions of IPython

Version 2.2.2 Tue 19 Jul 2022 by luispedro
* Fix `jug cleanup` when packs are used (`jug pack`)
Expand Down
26 changes: 10 additions & 16 deletions jug/subcommands/shell.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2008-2022, Luis Pedro Coelho <luis@luispedro.org>
# Copyright (C) 2008-2023, Luis Pedro Coelho <luis@luispedro.org>
# vim: set ts=4 sts=4 sw=4 expandtab smartindent:
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -99,23 +99,17 @@ class ShellCommand(SubCommand):
def run(self, store, options, jugspace, *args, **kwargs):
try:
import IPython
if IPython.version_info[0] >= 1:
from IPython.terminal.embed import InteractiveShellEmbed
from IPython.terminal.ipapp import load_default_config
else:
from IPython.frontend.terminal.embed import InteractiveShellEmbed
from IPython.frontend.terminal.ipapp import load_default_config
from IPython.terminal.embed import InteractiveShellEmbed
from IPython.terminal.ipapp import load_default_config
config = load_default_config()
ipshell = InteractiveShellEmbed(config=config, display_banner=_ipython_banner)
if IPython.core.getipython.get_ipython() is None:
ipshell = InteractiveShellEmbed.instance(config=config, display_banner=_ipython_banner)
else:
ipshell = InteractiveShellEmbed(config=config, display_banner=_ipython_banner)
except ImportError:
try:
# Fallback for older Python:
from IPython.Shell import IPShellEmbed
ipshell = IPShellEmbed(banner=_ipython_banner)
except ImportError:
import sys
sys.stderr.write(_ipython_not_found_msg)
sys.exit(1)
import sys
sys.stderr.write(_ipython_not_found_msg)
sys.exit(1)

def _load_all():
'''
Expand Down

0 comments on commit d647c15

Please sign in to comment.