Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions IPython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

https://ipython.org
"""
#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Copyright (c) 2008-2011, IPython Development Team.
# Copyright (c) 2001-2007, Fernando Perez <[email protected]>
# Copyright (c) 2001, Janko Hauser <[email protected]>
Expand All @@ -12,23 +12,23 @@
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------

import os
import sys

#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Setup everything
#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------

# Don't forget to also update setup.py when this changes!
if sys.version_info < (3, 8):
raise ImportError(
"""
"""
IPython 8+ supports Python 3.8 and above, following NEP 29.
When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
Python 3.3 and 3.4 were supported up to IPython 6.x.
Expand All @@ -40,11 +40,12 @@

https://github.com/ipython/ipython/blob/master/README.rst

""")
"""
)

#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Setup the top level names
#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------

from .core.getipython import get_ipython
from .core import release
Expand All @@ -56,9 +57,9 @@
from .utils.frame import extract_module_locals

# Release data
__author__ = '%s <%s>' % (release.author, release.author_email)
__license__ = release.license
__version__ = release.version
__author__ = "%s <%s>" % (release.author, release.author_email)
__license__ = release.license
__version__ = release.version
version_info = release.version_info
# list of CVEs that should have been patched in this release.
# this is informational and should not be relied upon.
Expand All @@ -84,17 +85,19 @@ def embed_kernel(module=None, local_ns=None, **kwargs):
allowing configuration of the Kernel. Will only have an effect
on the first embed_kernel call for a given process.
"""

(caller_module, caller_locals) = extract_module_locals(1)
if module is None:
module = caller_module
if local_ns is None:
local_ns = caller_locals

# Only import .zmq when we really need it
from ipykernel.embed import embed_kernel as real_embed_kernel

real_embed_kernel(module=module, local_ns=local_ns, **kwargs)


def start_ipython(argv=None, **kwargs):
"""Launch a normal IPython instance (as opposed to embedded)

Expand All @@ -120,8 +123,10 @@ def start_ipython(argv=None, **kwargs):
such as `config`.
"""
from IPython.terminal.ipapp import launch_new_instance

return launch_new_instance(argv=argv, **kwargs)


def start_kernel(argv=None, **kwargs):
"""Launch a normal IPython kernel instance (as opposed to embedded)

Expand Down Expand Up @@ -152,4 +157,5 @@ def start_kernel(argv=None, **kwargs):
stacklevel=2,
)
from ipykernel.kernelapp import launch_new_instance

return launch_new_instance(argv=argv, **kwargs)
4 changes: 2 additions & 2 deletions IPython/__main__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# encoding: utf-8
"""Terminal-based IPython entry point.
"""
#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Copyright (c) 2012, IPython Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------

from IPython import start_ipython

Expand Down
15 changes: 8 additions & 7 deletions IPython/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,25 @@ def pytest_collection_modifyitems(items):

def get_ipython():
from .terminal.interactiveshell import TerminalInteractiveShell

if TerminalInteractiveShell._instance:
return TerminalInteractiveShell.instance()

config = tools.default_config()
config.TerminalInteractiveShell.simple_prompt = True

# Create and initialize our test-friendly IPython instance.
shell = TerminalInteractiveShell.instance(config=config)
return shell
return TerminalInteractiveShell.instance(config=config)


@pytest.fixture(scope='session', autouse=True)
@pytest.fixture(scope="session", autouse=True)
def work_path():
path = pathlib.Path("./tmp-ipython-pytest-profiledir")
os.environ["IPYTHONDIR"] = str(path.absolute())
if path.exists():
raise ValueError('IPython dir temporary path already exists ! Did previous test run exit successfully ?')
raise ValueError(
"IPython dir temporary path already exists ! Did previous test run exit successfully ?"
)
path.mkdir()
yield
shutil.rmtree(str(path.resolve()))
Expand All @@ -58,8 +60,7 @@ def nopage(strng, start=0, screen_lines=0, pager_cmd=None):


def xsys(self, cmd):
"""Replace the default system call with a capturing one for doctest.
"""
"""Replace the default system call with a capturing one for doctest."""
# We use getoutput, but we need to strip it because pexpect captures
# the trailing newline differently from commands.getoutput
print(self.getoutput(cmd, split=False, depth=1).rstrip(), end="", file=sys.stdout)
Expand All @@ -70,7 +71,7 @@ def xsys(self, cmd):
# unfortunately this will fail on some test that get executed as _collection_
# time (before the fixture run), in particular parametrized test that contain
# yields. so for now execute at import time.
#@pytest.fixture(autouse=True, scope='session')
# @pytest.fixture(autouse=True, scope='session')
def inject():

builtins.get_ipython = get_ipython
Expand Down
7 changes: 5 additions & 2 deletions IPython/consoleapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

from warnings import warn

warn("The `IPython.consoleapp` package has been deprecated since IPython 4.0."
"You should import from jupyter_client.consoleapp instead.", stacklevel=2)
warn(
"The `IPython.consoleapp` package has been deprecated since IPython 4.0."
"You should import from jupyter_client.consoleapp instead.",
stacklevel=2,
)

from jupyter_client.consoleapp import *
Loading