From c59455a95a9c8d88e0ec6ea1f7137a4075d76b09 Mon Sep 17 00:00:00 2001 From: Pierre Raybaut <1311787+PierreRaybaut@users.noreply.github.com> Date: Fri, 23 Oct 2026 13:46:36 +0200 Subject: [PATCH] chore: require Python 3.10 or newer Refs DataLab-Platform/DataLab-Kernel#1 Assisted-by: GPT-6.1 Sol --- .github/workflows/test.yml | 2 +- README.md | 1 + datalab_kernel/kernel.py | 8 +-- datalab_kernel/matplotlib_backend.py | 6 +- datalab_kernel/plotly_backend.py | 18 ++++-- datalab_kernel/tests/unit/test_kernel.py | 8 +++ doc/release_notes/release_0.02.md | 5 ++ doc/requirements.rst | 73 ++++++++++++++---------- pyproject.toml | 5 +- requirements.txt | 19 ++++-- 10 files changed, 95 insertions(+), 50 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0a87678..7b7dd93 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.13"] + python-version: ["3.10", "3.13", "3.14"] steps: - uses: actions/checkout@v7 diff --git a/README.md b/README.md index 82085ae..bebd6a0 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,7 @@ DataLab-Kernel uses **xeus-python** as its backend, which provides: The kernel requires: +- Python 3.10 or later - `xeus-python>=0.17.0` - The xeus-based Python kernel - `xeus-python-shell>=0.6.0` - Python shell utilities for xeus-python - `sigima>=1.0` - Scientific signal and image processing diff --git a/datalab_kernel/kernel.py b/datalab_kernel/kernel.py index f4ce23e..233d573 100644 --- a/datalab_kernel/kernel.py +++ b/datalab_kernel/kernel.py @@ -17,6 +17,8 @@ from __future__ import annotations +import sys + from datalab_kernel import __version__ # Kernel metadata (used by kernel spec and for identification) @@ -25,11 +27,11 @@ KERNEL_IMPLEMENTATION = "datalab-kernel" KERNEL_IMPLEMENTATION_VERSION = __version__ KERNEL_LANGUAGE = "python" -KERNEL_LANGUAGE_VERSION = "3.9" +KERNEL_LANGUAGE_VERSION = f"{sys.version_info.major}.{sys.version_info.minor}" KERNEL_LANGUAGE_INFO = { "name": "python", - "version": "3.9", + "version": KERNEL_LANGUAGE_VERSION, "mimetype": "text/x-python", "codemirror_mode": {"name": "ipython", "version": 3}, "pygments_lexer": "ipython3", @@ -79,8 +81,6 @@ def launch_kernel(): It launches xeus-python with the DataLab startup configuration. """ - import sys - # Import and launch xeus-python try: # xeus-python provides an extension module for launching diff --git a/datalab_kernel/matplotlib_backend.py b/datalab_kernel/matplotlib_backend.py index 71f7465..2dd81ca 100644 --- a/datalab_kernel/matplotlib_backend.py +++ b/datalab_kernel/matplotlib_backend.py @@ -157,7 +157,7 @@ def _add_table_results_to_axes( # Format each row (typically just one row for statistics) for row in data: - for header, value in zip(headers, row): + for header, value in zip(headers, row, strict=False): # Format numeric values if isinstance(value, float): if abs(value) < 0.001 or abs(value) >= 10000: @@ -184,7 +184,7 @@ def _add_table_results_to_axes( coords = ( geometry.coords[0] if geometry.coords.ndim > 1 else geometry.coords ) - for label, value in zip(coord_labels, coords): + for label, value in zip(coord_labels, coords, strict=False): if isinstance(value, float): if abs(value) < 0.001 or abs(value) >= 10000: formatted = f"{value:.3g}" @@ -1187,7 +1187,7 @@ def _render_to_png(self) -> bytes: all_geo_results: list = [] for idx, (ax, img, img_title, result) in enumerate( - zip(axes_flat, self._objs, titles, results_list) + zip(axes_flat, self._objs, titles, results_list, strict=False) ): obj_type = type(img).__name__ diff --git a/datalab_kernel/plotly_backend.py b/datalab_kernel/plotly_backend.py index a97fa83..22e4dd0 100644 --- a/datalab_kernel/plotly_backend.py +++ b/datalab_kernel/plotly_backend.py @@ -244,7 +244,7 @@ def _build_annotation_text( lines.append(f"{table.title}:") headers = list(table.headers) for row in table.data: - for header, value in zip(headers, row): + for header, value in zip(headers, row, strict=False): if isinstance(value, float): formatted = ( f"{value:.3g}" @@ -264,7 +264,7 @@ def _build_annotation_text( coords = ( geometry.coords[0] if geometry.coords.ndim > 1 else geometry.coords ) - for lbl, val in zip(coord_labels, coords): + for lbl, val in zip(coord_labels, coords, strict=False): if isinstance(val, float): formatted = ( f"{val:.3g}" @@ -474,7 +474,11 @@ def _add_image_roi_shapes( # Close the polygon xs = list(points[:, 0]) + [points[0, 0]] ys = list(points[:, 1]) + [points[0, 1]] - path = "M " + " L ".join(f"{x},{y}" for x, y in zip(xs, ys)) + " Z" + path = ( + "M " + + " L ".join(f"{x},{y}" for x, y in zip(xs, ys, strict=False)) + + " Z" + ) fig.add_shape( type="path", path=path, @@ -1014,7 +1018,7 @@ def _build_signal_figure(self) -> go.Figure: # Build interleaved arrays: (x, baseline) -> (x, y) -> None gap xs: list = [] ys: list = [] - for xi, yi in zip(x, y): + for xi, yi in zip(x, y, strict=False): xs.extend([xi, xi, None]) ys.extend([baseline, yi, None]) fig.add_trace( @@ -1431,7 +1435,7 @@ def _build_figure(self) -> go.Figure: baseline = float(obj.get_metadata_option("baseline")) xs: list = [] ys: list = [] - for xi, yi in zip(x, y): + for xi, yi in zip(x, y, strict=False): xs.extend([xi, xi, None]) ys.extend([baseline, yi, None]) fig.add_trace( @@ -1770,7 +1774,9 @@ def _build_figure(self) -> go.Figure: all_tbl_results: list = [] all_geo_results: list = [] - for idx, (img, result) in enumerate(zip(self._objs, results_list)): + for idx, (img, result) in enumerate( + zip(self._objs, results_list, strict=False) + ): row = idx // ncols + 1 col = idx % ncols + 1 diff --git a/datalab_kernel/tests/unit/test_kernel.py b/datalab_kernel/tests/unit/test_kernel.py index 6968560..1b5f4f8 100644 --- a/datalab_kernel/tests/unit/test_kernel.py +++ b/datalab_kernel/tests/unit/test_kernel.py @@ -12,6 +12,7 @@ from __future__ import annotations import json +import sys import pytest @@ -76,6 +77,7 @@ def test_kernel_metadata_exists(self): KERNEL_IMPLEMENTATION, KERNEL_LANGUAGE, KERNEL_LANGUAGE_INFO, + KERNEL_LANGUAGE_VERSION, ) assert KERNEL_IMPLEMENTATION == "datalab-kernel" @@ -83,6 +85,9 @@ def test_kernel_metadata_exists(self): assert KERNEL_DISPLAY_NAME == "DataLab" assert "xeus-python" in KERNEL_BANNER assert isinstance(KERNEL_LANGUAGE_INFO, dict) + expected_version = f"{sys.version_info.major}.{sys.version_info.minor}" + assert expected_version == KERNEL_LANGUAGE_VERSION + assert KERNEL_LANGUAGE_INFO["version"] == KERNEL_LANGUAGE_VERSION assert isinstance(KERNEL_HELP_LINKS, list) def test_get_kernel_info_function(self): @@ -99,6 +104,9 @@ def test_get_kernel_info_function(self): assert "help_links" in info assert info["implementation"] == "datalab-kernel" + assert info["language_info"]["version"] == ( + f"{sys.version_info.major}.{sys.version_info.minor}" + ) class TestStartupModule: diff --git a/doc/release_notes/release_0.02.md b/doc/release_notes/release_0.02.md index be2d069..f7c2631 100644 --- a/doc/release_notes/release_0.02.md +++ b/doc/release_notes/release_0.02.md @@ -1,5 +1,10 @@ # Version 0.2 # +## Unreleased ## + +* Python 3.10 or later is now required. Python 3.9 users must keep an earlier compatible release. +* Kernel language information now reports the Python version actually running the kernel, rather than always announcing Python 3.9. + ## DataLab-Kernel Version 0.2.11 (2026-02-15) ## ### 🛠️ Bug Fixes since version 0.2.10 ### diff --git a/doc/requirements.rst b/doc/requirements.rst index 105ccad..bdf7dba 100644 --- a/doc/requirements.rst +++ b/doc/requirements.rst @@ -1,4 +1,4 @@ -The ``datalab-kernel`` package requires the following Python modules: +The `datalab-kernel` package requires the following Python modules: .. list-table:: :header-rows: 1 @@ -8,28 +8,31 @@ The ``datalab-kernel`` package requires the following Python modules: - Version - Summary * - Python - - >=3.9 + - >=3.10 - Python programming language - * - ipykernel - - >= 6.0 - - IPython Kernel for Jupyter - * - jupyter-client - - >= 7.0 - - Jupyter protocol client APIs - * - NumPy - - >= 1.22 + * - xeus-python + - >=0.17.0 + - A wheel for xeus-python + * - xeus-python-shell + - >=0.6.0 + - The xeus-python core python logic. + * - numpy + - >=1.22 - Fundamental package for array computing in Python + * - httpx + - >=0.25.0 + - The next generation HTTP client. * - h5py - - >= 3.0 + - >=3.0 - Read and write HDF5 files from Python * - matplotlib - - >= 3.5 + - >=3.5 - Python plotting package - * - Sigima - - >= 1.0 - - Scientific signal and image processing library + * - sigima + - >=1.0 + - Scientific computing engine for 1D signals and 2D images, part of the DataLab open-source platform. -Optional modules for DataLab integration: +Optional modules for development: .. list-table:: :header-rows: 1 @@ -38,11 +41,17 @@ Optional modules for DataLab integration: * - Name - Version - Summary - * - datalab-platform - - >= 1.0 - - DataLab - Scientific Data Analysis Platform + * - pytest + - >=7.0 + - pytest: simple powerful testing with Python + * - pytest-cov + - >=4.0 + - Pytest plugin for measuring coverage. + * - ruff + - >=0.1.0 + - An extremely fast Python linter and code formatter, written in Rust. -Development dependencies: +Optional modules for building the documentation: .. list-table:: :header-rows: 1 @@ -51,12 +60,18 @@ Development dependencies: * - Name - Version - Summary - * - pytest - - >= 7.0 - - Python testing framework - * - pytest-cov - - >= 4.0 - - Pytest coverage plugin - * - ruff - - >= 0.1.0 - - Fast Python linter and formatter + * - sphinx + - >=7.0 + - Python documentation generator + * - pydata-sphinx-theme + - >=0.14 + - Bootstrap-based Sphinx theme from the PyData community + * - myst-nb + - >=1.0 + - A Jupyter Notebook Sphinx reader built on top of the MyST markdown parser. + * - sphinx-design + - >=0.5 + - A sphinx extension for designing beautiful, view size responsive web components. + * - sphinx-copybutton + - >=0.5 + - Add a copy button to each of your code cells. \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index e3fd5f1..58cebda 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,6 @@ classifiers = [ "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", @@ -26,7 +25,7 @@ classifiers = [ "Topic :: Scientific/Engineering", ] keywords = ["jupyter", "kernel", "datalab", "scientific", "data processing", "xeus"] -requires-python = ">=3.9" +requires-python = ">=3.10" dependencies = [ "xeus-python>=0.17.0", "xeus-python-shell>=0.6.0", @@ -90,7 +89,7 @@ markers = [ [tool.ruff] line-length = 88 -target-version = "py39" +target-version = "py310" [tool.ruff.lint] select = ["E", "F", "W", "I", "UP", "B", "C4", "SIM"] diff --git a/requirements.txt b/requirements.txt index 58459ad..9aaaf9d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,18 @@ -xeus-python>=0.17.0 -xeus-python-shell>=0.6.0 -numpy>=1.22 -httpx>=0.25.0 +datalab-platform>=1.1 h5py>=3.0 +httpx>=0.25.0 +jupyter-client>=7.0 matplotlib>=3.5 +myst-nb>=1.0 +numpy>=1.22 +plotly>=5.0 +pydata-sphinx-theme>=0.14 +pytest-cov>=4.0 +pytest>=7.0 +ruff>=0.1.0 sigima>=1.0 +sphinx-copybutton>=0.5 +sphinx-design>=0.5 +sphinx>=7.0 +xeus-python-shell>=0.6.0 +xeus-python>=0.17.0