Skip to content
Open
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
21 changes: 7 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,22 @@ jobs:
- qt5
- qt6
python-version:
- "3.11"
- "3.12"
- "3.13"
- "3.14"
# 3.14t needs a jupyter-core release
# - "3.14t"
- "pypy-3.11"
- "3.15"
exclude:
# qt6 not supported on 3.14 yet
- python-version: "3.15"
qt: qt6
- python-version: "3.14"
qt: qt6
- python-version: "3.13"
qt: qt5
- python-version: "3.12"
qt: qt5
- python-version: "3.11"
qt: qt5

steps:
- name: Checkout
Expand All @@ -69,19 +68,13 @@ jobs:

- name: Run the tests
timeout-minutes: 15
if: ${{ !startsWith( matrix.python-version, 'pypy' ) && !startsWith(matrix.os, 'windows') }}
if: ${{ !startsWith(matrix.os, 'windows') }}
run: |
hatch run cov:test --cov-fail-under 50

- name: Run the tests on pypy
timeout-minutes: 15
if: ${{ startsWith( matrix.python-version, 'pypy' ) }}
run: |
hatch run test:nowarn --ignore=tests/test_debugger.py

- name: Run the tests on Windows
timeout-minutes: 15
if: ${{ !startsWith( matrix.python-version, 'pypy' ) && startsWith(matrix.os, 'windows') }}
if: ${{ startsWith(matrix.os, 'windows') }}
run: |
hatch run cov:nowarn

Expand Down Expand Up @@ -165,7 +158,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.11"]
python-version: ["3.12"]
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down Expand Up @@ -199,7 +192,7 @@ jobs:

- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.11"
python-version: "3.12"

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@925e40fa6066f4533e0c40803bd4b6d0d2f4a781 # v1.1.0
Expand Down
33 changes: 0 additions & 33 deletions examples/embedding/inprocess_terminal.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""An in-process terminal example."""

import os
import sys

import tornado
from jupyter_console.ptshell import ZMQTerminalInteractiveShell

from ipykernel.inprocess.manager import InProcessKernelManager
Expand All @@ -14,44 +12,13 @@ def print_process_id():
print("Process ID is:", os.getpid())


def init_asyncio_patch():
"""set default asyncio policy to be compatible with tornado
Tornado 6 (at least) is not compatible with the default
asyncio implementation on Windows
Pick the older SelectorEventLoopPolicy on Windows
if the known-incompatible default policy is in use.
do this as early as possible to make it a low priority and overridable
ref: https://github.com/tornadoweb/tornado/issues/2608
FIXME: if/when tornado supports the defaults in asyncio,
remove and bump tornado requirement for py38
"""
if (
sys.platform.startswith("win")
and sys.version_info >= (3, 8)
and tornado.version_info < (6, 1)
):
import asyncio

try:
from asyncio import WindowsProactorEventLoopPolicy, WindowsSelectorEventLoopPolicy
except ImportError:
pass
# not affected
else:
if type(asyncio.get_event_loop_policy()) is WindowsProactorEventLoopPolicy:
# WindowsProactorEventLoopPolicy is not compatible with tornado 6
# fallback to the pre-3.8 default of Selector
asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())


def main():
"""The main function."""
print_process_id()

# Create an in-process kernel
# >>> print_process_id()
# will print the same process ID as the main process
init_asyncio_patch()
kernel_manager = InProcessKernelManager()
kernel_manager.start_kernel()
kernel = kernel_manager.kernel
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
requires-python = ">=3.11"
requires-python = ">=3.12"
dependencies = [
"debugpy>=1.6.5",
"ipython>=7.23.1",
Expand Down
22 changes: 9 additions & 13 deletions tests/test_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,13 @@ def test_control_thread_priority():
assert control_dates[-1] <= shell_dates[0]


def _ensure_datetime(arg):
# Support arg which is a datetime or str.
if isinstance(arg, str):
return datetime.fromisoformat(arg)
return arg


def test_sequential_control_messages():
with new_kernel() as kc:
msg_id = kc.execute("import time")
Expand All @@ -790,22 +797,11 @@ def test_sequential_control_messages():
# Get replies
replies = [get_reply(kc, msg_id, channel="control") for msg_id in msg_ids]

def ensure_datetime(arg):
# Support arg which is a datetime or str.
if isinstance(arg, str):
if sys.version_info[:2] < (3, 11) and arg.endswith("Z"):
# Python < 3.11 doesn't support "Z" suffix in datetime.fromisoformat,
# so use alternative timezone format.
# https://github.com/python/cpython/issues/80010
arg = arg[:-1] + "+00:00"
return datetime.fromisoformat(arg)
return arg

# Check messages are processed in order, one at a time, and of a sensible duration.
previous_end = None
for reply, sleep in zip(replies, sleeps, strict=False):
start = ensure_datetime(reply["metadata"]["started"])
end = ensure_datetime(reply["header"]["date"])
start = _ensure_datetime(reply["metadata"]["started"])
end = _ensure_datetime(reply["header"]["date"])

if previous_end is not None:
assert start >= previous_end
Expand Down
5 changes: 5 additions & 0 deletions tests/test_subshells.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import annotations

import platform
import sys
import time
from collections import Counter
from queue import Empty
Expand Down Expand Up @@ -189,6 +190,10 @@ def on_reply(message):

@pytest.mark.parametrize("are_subshells", [(False, True), (True, False), (True, True)])
@pytest.mark.parametrize("overlap", [True, False])
@pytest.mark.skipif(
"__pypy__" in sys.builtin_module_names,
reason="fails on pypy",
)
def test_run_concurrently_sequence(are_subshells, overlap, request):
if request.config.getvalue("--cov"):
pytest.skip("Skip time-sensitive subshell tests if measuring coverage")
Expand Down
Loading