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 26, 2023
1 parent bc0f711 commit 1eead0d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version 2.2.3 Tue 19 Jul 2022 by luispedro
* 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
8 changes: 8 additions & 0 deletions docs/source/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
History
=======

Version 2.2.3
-------------

*Released 26 May 2023*

- Fix ``jug shell`` for newer versions of IPython


Version 2.2.2
-------------

Expand Down
26 changes: 10 additions & 16 deletions jug/subcommands/shell.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2008-2021, Luis Pedro Coelho <[email protected]>
# Copyright (C) 2008-2023, Luis Pedro Coelho <[email protected]>
# 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 @@ -95,23 +95,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 1eead0d

Please sign in to comment.