From d647c15adc8f88492216a86c5473834d8718926a Mon Sep 17 00:00:00 2001 From: Luis Pedro Coelho Date: Thu, 11 May 2023 09:41:57 +0200 Subject: [PATCH] ENH Work around IPython regression Jug shell fails in newer versions of IPython, see https://github.com/ipython/ipython/issues/13966 --- ChangeLog | 2 ++ jug/subcommands/shell.py | 26 ++++++++++---------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 58cbc81..c443cbc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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`) diff --git a/jug/subcommands/shell.py b/jug/subcommands/shell.py index 70c66dc..b846e5e 100755 --- a/jug/subcommands/shell.py +++ b/jug/subcommands/shell.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright (C) 2008-2022, Luis Pedro Coelho +# Copyright (C) 2008-2023, Luis Pedro Coelho # vim: set ts=4 sts=4 sw=4 expandtab smartindent: # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -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(): '''