From d24b6055a516cca29fa412532ef34559ffcbc9d4 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 12 Jun 2026 20:28:49 +0200 Subject: [PATCH 01/28] Python: remove dead Py2 __future__ import from colors.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit colors.py carried `from __future__ import absolute_import, division, print_function`, which is inert on Python 3.10+ (the only Python this project runs on). Remove it. The `from __future__ import annotations` lines in blocks.py/checks.py/extract_projects.py are NOT touched — those are live (deferred annotation evaluation). Part of the py_modules -> python/rst_code_example_pipeline refactor (structural only, no behavior change). Co-Authored-By: Claude Opus 4.8 (1M context) --- frontend/py_modules/code_projects/colors.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/py_modules/code_projects/colors.py b/frontend/py_modules/code_projects/colors.py index cad3789e8..e88cdd207 100644 --- a/frontend/py_modules/code_projects/colors.py +++ b/frontend/py_modules/code_projects/colors.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, division, print_function - from collections.abc import Iterator from contextlib import contextmanager import sys From 3ef0b5630061d92e7384815ee7ad0b8aa9b273aa Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 12 Jun 2026 20:54:31 +0200 Subject: [PATCH 02/28] Python: convert library modules to explicit relative imports Replace bare `import ` with `from . import ` in the three library-only modules (blocks, fmt_utils, toolchain_setup). This is the prerequisite step for turning code_projects into a proper importable package. Bare imports relied on sys.path[0] injection and break as soon as the directory is not at the front of sys.path. Co-Authored-By: Claude Sonnet 4.6 --- frontend/py_modules/code_projects/blocks.py | 4 ++-- frontend/py_modules/code_projects/fmt_utils.py | 2 +- frontend/py_modules/code_projects/toolchain_setup.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/py_modules/code_projects/blocks.py b/frontend/py_modules/code_projects/blocks.py index 724b65113..b618cef12 100644 --- a/frontend/py_modules/code_projects/blocks.py +++ b/frontend/py_modules/code_projects/blocks.py @@ -6,8 +6,8 @@ import json from typing import Any -import colors as C -import toolchain_info +from . import colors as C +from . import toolchain_info class Block(object): @staticmethod diff --git a/frontend/py_modules/code_projects/fmt_utils.py b/frontend/py_modules/code_projects/fmt_utils.py index 24be44bb8..f5caa5f93 100644 --- a/frontend/py_modules/code_projects/fmt_utils.py +++ b/frontend/py_modules/code_projects/fmt_utils.py @@ -1,6 +1,6 @@ #! /usr/bin/env python3 -import colors as C +from . import colors as C def header(strn: str) -> str: return C.col("{}\n{}\n".format(strn, '*' * len(strn)), C.Colors.BLUE) diff --git a/frontend/py_modules/code_projects/toolchain_setup.py b/frontend/py_modules/code_projects/toolchain_setup.py index b707a235d..8e8eaf43b 100644 --- a/frontend/py_modules/code_projects/toolchain_setup.py +++ b/frontend/py_modules/code_projects/toolchain_setup.py @@ -3,8 +3,8 @@ import os import re -import blocks -import toolchain_info as info +from . import blocks +from . import toolchain_info as info def set_toolchain(block: blocks.CodeBlock) -> None: From 5dedc136ac39caa2ec1682f605502d2f1567707b Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 12 Jun 2026 20:54:40 +0200 Subject: [PATCH 03/28] Python: convert CLI modules to explicit relative imports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace bare `import ` with `from . import ` in the three CLI entry-point modules (check_code_block, check_projects, extract_projects). Intentionally excludes the cross-package import `from widget.chop import ...` in extract_projects — that is addressed when sphinx/widget/chop.py is moved into the package. Co-Authored-By: Claude Sonnet 4.6 --- frontend/py_modules/code_projects/check_code_block.py | 8 ++++---- frontend/py_modules/code_projects/check_projects.py | 8 ++++---- frontend/py_modules/code_projects/extract_projects.py | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/frontend/py_modules/code_projects/check_code_block.py b/frontend/py_modules/code_projects/check_code_block.py index 94c5bcf84..36a53277b 100755 --- a/frontend/py_modules/code_projects/check_code_block.py +++ b/frontend/py_modules/code_projects/check_code_block.py @@ -18,10 +18,10 @@ import glob import re -import blocks -import checks -import fmt_utils -import toolchain_setup +from . import blocks +from . import checks +from . import fmt_utils +from . import toolchain_setup LOOK_FOR_PREVIOUS_CHECKS = True diff --git a/frontend/py_modules/code_projects/check_projects.py b/frontend/py_modules/code_projects/check_projects.py index ed638716b..6672b031f 100755 --- a/frontend/py_modules/code_projects/check_projects.py +++ b/frontend/py_modules/code_projects/check_projects.py @@ -8,10 +8,10 @@ import os import glob -import blocks -import check_code_block -import extract_projects -import fmt_utils +from . import blocks +from . import check_code_block +from . import extract_projects +from . import fmt_utils verbose: bool = False all_diagnostics: bool = False diff --git a/frontend/py_modules/code_projects/extract_projects.py b/frontend/py_modules/code_projects/extract_projects.py index 01c1ed922..a9bebe3da 100755 --- a/frontend/py_modules/code_projects/extract_projects.py +++ b/frontend/py_modules/code_projects/extract_projects.py @@ -15,9 +15,9 @@ from widget.chop import manual_chop, real_gnatchop -import blocks -import fmt_utils -import toolchain_setup +from . import blocks +from . import fmt_utils +from . import toolchain_setup current_config = blocks.ConfigBlock( From 6035947826465401cbbb4430b64fa78e4ce3526a Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 12 Jun 2026 20:54:54 +0200 Subject: [PATCH 04/28] Test script: invoke code_projects CLIs via python -m in compile_blocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switch compile_blocks.py from path-based subprocess calls python3 /extract_projects.py ... to module invocations python3 -m code_projects.extract_projects ... python3 -m code_projects.check_projects ... This is the bridge that makes the test script compatible with explicit relative imports: `python3 -m package.module` sets __package__ so relative imports resolve, while PYTHONPATH=…:py_modules still makes the package findable. Remove the now-unused PATH_CODE_PROJECTS variable. Validated: compile_blocks on content/courses/intro-to-ada/ (25 RST files) exits 0 on the epub VM with these changes applied. Co-Authored-By: Claude Sonnet 4.6 --- frontend/tests/compile_blocks.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/frontend/tests/compile_blocks.py b/frontend/tests/compile_blocks.py index fcf32623f..174ccad86 100755 --- a/frontend/tests/compile_blocks.py +++ b/frontend/tests/compile_blocks.py @@ -80,13 +80,8 @@ print("Storing list of project in " + extracted_projects_json) if CALL_SCRIPTS: - PATH_CODE_PROJECTS = \ - os.path.dirname(os.path.realpath(__file__)) + \ - "/../py_modules/code_projects" - if RUN_PROJECT_EXTRACTION: - cmd_extract_projects = PATH_CODE_PROJECTS + \ - "/extract_projects.py" + cmd_extract_projects = "python3 -m code_projects.extract_projects" cmd_extract_projects += " --build-dir " + \ os.path.abspath(args.build_dir) @@ -111,8 +106,7 @@ test_error = ret_value != 0 if RUN_PROJECT_CHECK: - cmd_check_projects = PATH_CODE_PROJECTS + \ - "/check_projects.py" + cmd_check_projects = "python3 -m code_projects.check_projects" cmd_check_projects += " --extracted_projects " + \ extracted_projects_json From 7d466e2df9d30aadb46fb169641a8ce699500243 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 12 Jun 2026 21:04:38 +0200 Subject: [PATCH 05/28] Python: add rst_code_example_pipeline project and move code_projects modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create the new package project at frontend/python/rst_code_example_pipeline/ with src layout and pyproject.toml, and move all 11 modules + toolchain.ini from frontend/py_modules/code_projects/ via git mv (history preserved). - pyproject.toml: name rst-code-example-pipeline, version 0.2.0, requires-python >=3.10, console-script entry points (learn-extract-code / learn-check-code / learn-check-block), setuptools src layout, [tool.pyright] replacing pyrightconfig.json. - __init__.py __title__: code_projects -> rst_code_example_pipeline. - pyrightconfig.json and README.md moved to the project root. - py_modules/code_projects/ is now empty (removed from the tree). Intra-package imports remain `from . import …` (converted in the preceding explicit-imports commit); the widget.chop cross-package import in extract_projects remains (addressed when sphinx/widget/chop.py is moved into the package). Co-Authored-By: Claude Sonnet 4.6 --- frontend/py_modules/code_projects/__init__.py | 2 -- .../rst_code_example_pipeline}/README.md | 0 .../rst_code_example_pipeline/pyproject.toml | 20 +++++++++++++++++++ .../pyrightconfig.json | 0 .../src/rst_code_example_pipeline/__init__.py | 2 ++ .../src/rst_code_example_pipeline}/blocks.py | 0 .../check_code_block.py | 0 .../check_projects.py | 0 .../src/rst_code_example_pipeline}/checks.py | 0 .../src/rst_code_example_pipeline}/colors.py | 0 .../extract_projects.py | 0 .../rst_code_example_pipeline}/fmt_utils.py | 0 .../rst_code_example_pipeline}/toolchain.ini | 0 .../toolchain_info.py | 0 .../toolchain_setup.py | 0 15 files changed, 22 insertions(+), 2 deletions(-) delete mode 100644 frontend/py_modules/code_projects/__init__.py rename frontend/{py_modules/code_projects => python/rst_code_example_pipeline}/README.md (100%) create mode 100644 frontend/python/rst_code_example_pipeline/pyproject.toml rename frontend/{py_modules/code_projects => python/rst_code_example_pipeline}/pyrightconfig.json (100%) create mode 100644 frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/__init__.py rename frontend/{py_modules/code_projects => python/rst_code_example_pipeline/src/rst_code_example_pipeline}/blocks.py (100%) rename frontend/{py_modules/code_projects => python/rst_code_example_pipeline/src/rst_code_example_pipeline}/check_code_block.py (100%) rename frontend/{py_modules/code_projects => python/rst_code_example_pipeline/src/rst_code_example_pipeline}/check_projects.py (100%) rename frontend/{py_modules/code_projects => python/rst_code_example_pipeline/src/rst_code_example_pipeline}/checks.py (100%) rename frontend/{py_modules/code_projects => python/rst_code_example_pipeline/src/rst_code_example_pipeline}/colors.py (100%) rename frontend/{py_modules/code_projects => python/rst_code_example_pipeline/src/rst_code_example_pipeline}/extract_projects.py (100%) rename frontend/{py_modules/code_projects => python/rst_code_example_pipeline/src/rst_code_example_pipeline}/fmt_utils.py (100%) rename frontend/{py_modules/code_projects => python/rst_code_example_pipeline/src/rst_code_example_pipeline}/toolchain.ini (100%) rename frontend/{py_modules/code_projects => python/rst_code_example_pipeline/src/rst_code_example_pipeline}/toolchain_info.py (100%) rename frontend/{py_modules/code_projects => python/rst_code_example_pipeline/src/rst_code_example_pipeline}/toolchain_setup.py (100%) diff --git a/frontend/py_modules/code_projects/__init__.py b/frontend/py_modules/code_projects/__init__.py deleted file mode 100644 index 43f722c4a..000000000 --- a/frontend/py_modules/code_projects/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -__title__ = 'code_projects' -__version__ = '0.2.0' diff --git a/frontend/py_modules/code_projects/README.md b/frontend/python/rst_code_example_pipeline/README.md similarity index 100% rename from frontend/py_modules/code_projects/README.md rename to frontend/python/rst_code_example_pipeline/README.md diff --git a/frontend/python/rst_code_example_pipeline/pyproject.toml b/frontend/python/rst_code_example_pipeline/pyproject.toml new file mode 100644 index 000000000..3a8bdb605 --- /dev/null +++ b/frontend/python/rst_code_example_pipeline/pyproject.toml @@ -0,0 +1,20 @@ +[build-system] +requires = ["setuptools>=64"] +build-backend = "setuptools.backends.legacy:build" + +[project] +name = "rst-code-example-pipeline" +version = "0.2.0" +requires-python = ">=3.10" + +[project.scripts] +learn-extract-code = "rst_code_example_pipeline.cli.extract:main" +learn-check-code = "rst_code_example_pipeline.cli.check:main" +learn-check-block = "rst_code_example_pipeline.cli.check_block:main" + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.pyright] +pythonVersion = "3.10" +extraPaths = ["../../sphinx"] diff --git a/frontend/py_modules/code_projects/pyrightconfig.json b/frontend/python/rst_code_example_pipeline/pyrightconfig.json similarity index 100% rename from frontend/py_modules/code_projects/pyrightconfig.json rename to frontend/python/rst_code_example_pipeline/pyrightconfig.json diff --git a/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/__init__.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/__init__.py new file mode 100644 index 000000000..24131d7f4 --- /dev/null +++ b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/__init__.py @@ -0,0 +1,2 @@ +__title__ = 'rst_code_example_pipeline' +__version__ = '0.2.0' diff --git a/frontend/py_modules/code_projects/blocks.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/blocks.py similarity index 100% rename from frontend/py_modules/code_projects/blocks.py rename to frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/blocks.py diff --git a/frontend/py_modules/code_projects/check_code_block.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/check_code_block.py similarity index 100% rename from frontend/py_modules/code_projects/check_code_block.py rename to frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/check_code_block.py diff --git a/frontend/py_modules/code_projects/check_projects.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/check_projects.py similarity index 100% rename from frontend/py_modules/code_projects/check_projects.py rename to frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/check_projects.py diff --git a/frontend/py_modules/code_projects/checks.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/checks.py similarity index 100% rename from frontend/py_modules/code_projects/checks.py rename to frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/checks.py diff --git a/frontend/py_modules/code_projects/colors.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/colors.py similarity index 100% rename from frontend/py_modules/code_projects/colors.py rename to frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/colors.py diff --git a/frontend/py_modules/code_projects/extract_projects.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/extract_projects.py similarity index 100% rename from frontend/py_modules/code_projects/extract_projects.py rename to frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/extract_projects.py diff --git a/frontend/py_modules/code_projects/fmt_utils.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/fmt_utils.py similarity index 100% rename from frontend/py_modules/code_projects/fmt_utils.py rename to frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/fmt_utils.py diff --git a/frontend/py_modules/code_projects/toolchain.ini b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain.ini similarity index 100% rename from frontend/py_modules/code_projects/toolchain.ini rename to frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain.ini diff --git a/frontend/py_modules/code_projects/toolchain_info.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain_info.py similarity index 100% rename from frontend/py_modules/code_projects/toolchain_info.py rename to frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain_info.py diff --git a/frontend/py_modules/code_projects/toolchain_setup.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain_setup.py similarity index 100% rename from frontend/py_modules/code_projects/toolchain_setup.py rename to frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain_setup.py From da5f0737c3e55f996c4b0228d55ce655fa6a2c4c Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 12 Jun 2026 21:04:59 +0200 Subject: [PATCH 06/28] Python: add cli/ subpackage with console-script main() wrappers Add rst_code_example_pipeline/cli/ with three entry-point modules: cli/extract.py -> learn-extract-code cli/check.py -> learn-check-code cli/check_block.py -> learn-check-block Each wrapper calls runpy.run_module(..., run_name='__main__', alter_sys=True), which triggers the existing if __name__ == '__main__' block in the target module. This avoids touching the module-level global variables those blocks rely on, keeping the change minimal. Co-Authored-By: Claude Sonnet 4.6 --- .../src/rst_code_example_pipeline/cli/__init__.py | 0 .../src/rst_code_example_pipeline/cli/check.py | 6 ++++++ .../src/rst_code_example_pipeline/cli/check_block.py | 6 ++++++ .../src/rst_code_example_pipeline/cli/extract.py | 6 ++++++ 4 files changed, 18 insertions(+) create mode 100644 frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/cli/__init__.py create mode 100644 frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/cli/check.py create mode 100644 frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/cli/check_block.py create mode 100644 frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/cli/extract.py diff --git a/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/cli/__init__.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/cli/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/cli/check.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/cli/check.py new file mode 100644 index 000000000..0776e0647 --- /dev/null +++ b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/cli/check.py @@ -0,0 +1,6 @@ +import runpy + + +def main() -> None: + runpy.run_module('rst_code_example_pipeline.check_projects', + run_name='__main__', alter_sys=True) diff --git a/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/cli/check_block.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/cli/check_block.py new file mode 100644 index 000000000..8840ca1f1 --- /dev/null +++ b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/cli/check_block.py @@ -0,0 +1,6 @@ +import runpy + + +def main() -> None: + runpy.run_module('rst_code_example_pipeline.check_code_block', + run_name='__main__', alter_sys=True) diff --git a/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/cli/extract.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/cli/extract.py new file mode 100644 index 000000000..a2f25bd3d --- /dev/null +++ b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/cli/extract.py @@ -0,0 +1,6 @@ +import runpy + + +def main() -> None: + runpy.run_module('rst_code_example_pipeline.extract_projects', + run_name='__main__', alter_sys=True) From ee3a02a3756ad8e8ee3ce38543840eae86fe6fb7 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 12 Jun 2026 21:05:31 +0200 Subject: [PATCH 07/28] Vagrant: install rst_code_example_pipeline editable in both VMs After the frozen-requirements install, install the pipeline package in editable mode so the console-script entry points (learn-extract-code, learn-check-code, learn-check-block) are available on PATH inside the VM venv. Also update the toolchain.ini file-provision source path for both VMs from the old py_modules/code_projects/ location to the new python/rst_code_example_pipeline/src/rst_code_example_pipeline/ location. Co-Authored-By: Claude Sonnet 4.6 --- Vagrantfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index ea4a2d64b..d6e601dcb 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -71,6 +71,7 @@ $frontend = <<-SHELL python3 -m venv /vagrant/venv source /vagrant/venv/bin/activate pip3 install -r /vagrant/frontend/requirements_frozen.txt + pip3 install -e /vagrant/frontend/python/rst_code_example_pipeline # File system: increase number of user watches # Needed for npm @@ -205,6 +206,7 @@ $epub = <<-SHELL python3 -m venv /vagrant/venv source /vagrant/venv/bin/activate pip3 install -r /vagrant/frontend/requirements_frozen.txt + pip3 install -e /vagrant/frontend/python/rst_code_example_pipeline # File system: increase number of user watches # Needed for npm @@ -232,7 +234,7 @@ Vagrant.configure("2") do |config| web.vm.synced_folder './frontend', '/vagrant/frontend' web.vm.synced_folder './content', '/vagrant/content' - web.vm.provision "file", source: "./frontend/py_modules/code_projects/toolchain.ini", destination: "/home/vagrant/toolchain.ini" + web.vm.provision "file", source: "./frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain.ini", destination: "/home/vagrant/toolchain.ini" web.vm.provision "file", source: "./frontend/vm_apt_web.txt", destination: "/home/vagrant/vm_apt.txt" web.vm.provision :shell, inline: $frontend end @@ -244,7 +246,7 @@ Vagrant.configure("2") do |config| epub.vm.synced_folder './frontend', '/vagrant/frontend' epub.vm.synced_folder './content', '/vagrant/content' - epub.vm.provision "file", source: "./frontend/py_modules/code_projects/toolchain.ini", destination: "/home/vagrant/toolchain.ini" + epub.vm.provision "file", source: "./frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain.ini", destination: "/home/vagrant/toolchain.ini" epub.vm.provision "file", source: "./frontend/vm_apt_epub.txt", destination: "/home/vagrant/vm_apt.txt" epub.vm.provision :shell, inline: $epub end From 7bd5114d9489dfaaa34babce3a42812be7c22bcd Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 12 Jun 2026 21:05:46 +0200 Subject: [PATCH 08/28] Makefile: drop py_modules from PYTHONPATH (editable install replaces it) The rst_code_example_pipeline package is now installed in the VM venv via `pip install -e`, so Python's import system finds it without a manual PYTHONPATH entry. Remove :py_modules from TEST_LOCAL_DRIVER and TEST_LAMBDA_DRIVER. The :sphinx entry remains (sphinx/widget is still a non-installed module imported via PYTHONPATH until sphinx/widget/chop.py is moved into the package). Co-Authored-By: Claude Sonnet 4.6 --- frontend/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/Makefile b/frontend/Makefile index af422ebc3..f01803c42 100644 --- a/frontend/Makefile +++ b/frontend/Makefile @@ -6,9 +6,9 @@ SPHINXCONF = sphinx BUILDDIR = dist SRC_TEST_DIR = $(BUILDDIR)/test_output TEST_LAMBDA ?= 0 -TEST_LOCAL_DRIVER = PYTHONPATH="$PYTHONPATH:sphinx:py_modules" python3 tests/compile_blocks.py --keep_files -B $(SRC_TEST_DIR) +TEST_LOCAL_DRIVER = PYTHONPATH="$PYTHONPATH:sphinx" python3 tests/compile_blocks.py --keep_files -B $(SRC_TEST_DIR) TEST_OPTIONS ?= -TEST_LAMBDA_DRIVER = PYTHONPATH="$PYTHONPATH:sphinx:py_modules" python3 tests/execute_rst_code_blocks.py --halt-on-failure +TEST_LAMBDA_DRIVER = PYTHONPATH="$PYTHONPATH:sphinx" python3 tests/execute_rst_code_blocks.py --halt-on-failure ifeq ($(strip $(TEST_LAMBDA)),1) TEST_DRIVER := $(TEST_LAMBDA_DRIVER) From 11f882796a522bb4eaf82f2ce37a02aa94198d35 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 12 Jun 2026 21:06:13 +0200 Subject: [PATCH 09/28] Test script: use entry points and rst_code_example_pipeline in compile_blocks Three changes: 1. Remove dead `import colors as C` (colors.py is now inside the package; the import was unused in compile_blocks anyway). 2. `import code_projects.fmt_utils` -> `import rst_code_example_pipeline.fmt_utils`. 3. Replace `python3 -m code_projects.{extract,check}_projects` subprocess commands (the temporary `python3 -m code_projects.X` invocation introduced while the package was being set up) with the installed entry points `learn-extract-code` / `learn-check-code`. These are available once the editable install runs in the VM venv. Co-Authored-By: Claude Sonnet 4.6 --- frontend/tests/compile_blocks.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/frontend/tests/compile_blocks.py b/frontend/tests/compile_blocks.py index 174ccad86..6e960dc80 100755 --- a/frontend/tests/compile_blocks.py +++ b/frontend/tests/compile_blocks.py @@ -28,11 +28,10 @@ import argparse import os -import colors as C import shutil from datetime import datetime -import code_projects.fmt_utils as fmt_utils +import rst_code_example_pipeline.fmt_utils as fmt_utils EXTRACTED_PROJECTS_JSON = "extracted_projects_TIMESTAMP.json" USE_TIMESTAMP = True @@ -81,7 +80,7 @@ if CALL_SCRIPTS: if RUN_PROJECT_EXTRACTION: - cmd_extract_projects = "python3 -m code_projects.extract_projects" + cmd_extract_projects = "learn-extract-code" cmd_extract_projects += " --build-dir " + \ os.path.abspath(args.build_dir) @@ -106,7 +105,7 @@ test_error = ret_value != 0 if RUN_PROJECT_CHECK: - cmd_check_projects = "python3 -m code_projects.check_projects" + cmd_check_projects = "learn-check-code" cmd_check_projects += " --extracted_projects " + \ extracted_projects_json From 0dbf100125f5583d15301610ac6ce6ebc898f3a6 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 12 Jun 2026 21:06:34 +0200 Subject: [PATCH 10/28] CI: point type-check workflow at frontend/python/rst_code_example_pipeline Update the code_projects Type Check workflow: - Both push/pull_request paths: triggers now watch frontend/python/rst_code_example_pipeline/** instead of the old frontend/py_modules/code_projects/**. - working-directory updated accordingly so pyright finds pyproject.toml (which now carries [tool.pyright] in place of the old pyrightconfig.json). The editable-install step before pyright will be added in a follow-up commit. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/code-projects-type-check.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/code-projects-type-check.yml b/.github/workflows/code-projects-type-check.yml index 832f4b4bf..7399159d2 100644 --- a/.github/workflows/code-projects-type-check.yml +++ b/.github/workflows/code-projects-type-check.yml @@ -3,12 +3,12 @@ name: code_projects Type Check on: push: paths: - - 'frontend/py_modules/code_projects/**' + - 'frontend/python/rst_code_example_pipeline/**' pull_request: branches: - main paths: - - 'frontend/py_modules/code_projects/**' + - 'frontend/python/rst_code_example_pipeline/**' jobs: pyright: @@ -27,6 +27,6 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install pyright run: pip install pyright - - name: Run pyright on code_projects - working-directory: frontend/py_modules/code_projects + - name: Run pyright on rst_code_example_pipeline + working-directory: frontend/python/rst_code_example_pipeline run: pyright . From e2a2e8ca57dcf0a567ba3c36f0233ad40a38ac02 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Fri, 12 Jun 2026 23:13:19 +0200 Subject: [PATCH 11/28] Python: use setuptools.build_meta backend (compatible with older setuptools) setuptools.backends.legacy:build was added in setuptools 67.8; the VM's venv has an older version. Switch to setuptools.build_meta which is available from setuptools 40.8 onwards. Co-Authored-By: Claude Sonnet 4.6 --- frontend/python/rst_code_example_pipeline/pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/python/rst_code_example_pipeline/pyproject.toml b/frontend/python/rst_code_example_pipeline/pyproject.toml index 3a8bdb605..a16f7af1b 100644 --- a/frontend/python/rst_code_example_pipeline/pyproject.toml +++ b/frontend/python/rst_code_example_pipeline/pyproject.toml @@ -1,6 +1,6 @@ [build-system] -requires = ["setuptools>=64"] -build-backend = "setuptools.backends.legacy:build" +requires = ["setuptools>=42"] +build-backend = "setuptools.build_meta" [project] name = "rst-code-example-pipeline" From 8b28a451f91ddbb378fae5fe3a40f73a8202b4b2 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 13 Jun 2026 01:18:35 +0200 Subject: [PATCH 12/28] Test script: add import and entry-point smoke tests for the package Add rst_code_example_pipeline/tests/test_smoke.py (unittest, 14 tests): - TestPackageMetadata: __title__ and __version__ assertions. - TestModuleImports: each of the 9 package modules is importable; extract_projects and check_projects are skipped when widget.chop is not on PYTHONPATH (sphinx/widget/chop.py has not yet been moved into the package), all others run unconditionally. - TestEntryPoints: each cli/main() accepts --help and exits 0; extract and check are similarly skipped when widget.chop is not importable. Run: python -m unittest discover -s tests/ (from frontend/python/rst_code_example_pipeline/, with venv active; add PYTHONPATH=../../sphinx to enable tests that import extract_projects). Verified: 14/14 pass on epub VM with PYTHONPATH=sphinx. Co-Authored-By: Claude Sonnet 4.6 --- .../tests/__init__.py | 0 .../tests/test_smoke.py | 96 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 frontend/python/rst_code_example_pipeline/tests/__init__.py create mode 100644 frontend/python/rst_code_example_pipeline/tests/test_smoke.py diff --git a/frontend/python/rst_code_example_pipeline/tests/__init__.py b/frontend/python/rst_code_example_pipeline/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/frontend/python/rst_code_example_pipeline/tests/test_smoke.py b/frontend/python/rst_code_example_pipeline/tests/test_smoke.py new file mode 100644 index 000000000..58ef91b4f --- /dev/null +++ b/frontend/python/rst_code_example_pipeline/tests/test_smoke.py @@ -0,0 +1,96 @@ +""" +Smoke tests for rst_code_example_pipeline. + +Run with: + python -m unittest discover -s tests/ +or (from the project root): + python -m unittest rst_code_example_pipeline.tests.test_smoke + +Note: tests that import extract_projects / check_projects require +`sphinx/` on PYTHONPATH (for widget.chop), as sphinx/widget/chop.py has +not yet been moved into the package. Those tests are skipped automatically +when widget is absent. +""" +import sys +import unittest +from unittest.mock import patch + +import rst_code_example_pipeline + + +def _widget_available() -> bool: + try: + import widget.chop # noqa: F401 + return True + except ImportError: + return False + + +class TestPackageMetadata(unittest.TestCase): + def test_title(self) -> None: + self.assertEqual(rst_code_example_pipeline.__title__, + 'rst_code_example_pipeline') + + def test_version(self) -> None: + self.assertRegex(rst_code_example_pipeline.__version__, + r'^\d+\.\d+\.\d+$') + + +class TestModuleImports(unittest.TestCase): + """Each module must be importable without side-effects.""" + + def test_import_colors(self) -> None: + from rst_code_example_pipeline import colors # noqa: F401 + + def test_import_fmt_utils(self) -> None: + from rst_code_example_pipeline import fmt_utils # noqa: F401 + + def test_import_checks(self) -> None: + from rst_code_example_pipeline import checks # noqa: F401 + + def test_import_blocks(self) -> None: + from rst_code_example_pipeline import blocks # noqa: F401 + + def test_import_toolchain_info(self) -> None: + from rst_code_example_pipeline import toolchain_info # noqa: F401 + + def test_import_toolchain_setup(self) -> None: + from rst_code_example_pipeline import toolchain_setup # noqa: F401 + + def test_import_check_code_block(self) -> None: + from rst_code_example_pipeline import check_code_block # noqa: F401 + + @unittest.skipUnless(_widget_available(), 'widget.chop not on PYTHONPATH (sphinx/widget/chop.py not yet moved into the package)') + def test_import_extract_projects(self) -> None: + from rst_code_example_pipeline import extract_projects # noqa: F401 + + @unittest.skipUnless(_widget_available(), 'widget.chop not on PYTHONPATH (sphinx/widget/chop.py not yet moved into the package)') + def test_import_check_projects(self) -> None: + from rst_code_example_pipeline import check_projects # noqa: F401 + + +class TestEntryPoints(unittest.TestCase): + """Entry-point main() functions must accept --help (exit 0).""" + + def _assert_help_exits_zero(self, entry: str) -> None: + from importlib import import_module + mod = import_module(f'rst_code_example_pipeline.cli.{entry}') + with patch('sys.argv', [entry, '--help']): + with self.assertRaises(SystemExit) as ctx: + mod.main() + self.assertEqual(ctx.exception.code, 0) + + def test_check_block_help(self) -> None: + self._assert_help_exits_zero('check_block') + + @unittest.skipUnless(_widget_available(), 'widget.chop not on PYTHONPATH (sphinx/widget/chop.py not yet moved into the package)') + def test_extract_help(self) -> None: + self._assert_help_exits_zero('extract') + + @unittest.skipUnless(_widget_available(), 'widget.chop not on PYTHONPATH (sphinx/widget/chop.py not yet moved into the package)') + def test_check_help(self) -> None: + self._assert_help_exits_zero('check') + + +if __name__ == '__main__': + unittest.main() From da77b9a7c26fab0de68cba21c0dfda30fb7a553f Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 13 Jun 2026 01:57:08 +0200 Subject: [PATCH 13/28] Python: move chop + resource into rst_code_example_pipeline (git mv) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move sphinx/widget/chop.py and sphinx/widget/resource.py into the package via git mv (history preserved): frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/ chop.py's `from .resource import Resource` is already a relative import and continues to work in its new location within the package. Update extract_projects.py: `from widget.chop import …` → `from .chop import …` — the cross-package import is now an intra-package relative import. Drop `extraPaths = ["../../sphinx"]` from [tool.pyright] in pyproject.toml; the package no longer has any external dependency on sphinx/. Co-Authored-By: Claude Sonnet 4.6 --- frontend/python/rst_code_example_pipeline/pyproject.toml | 1 - .../src/rst_code_example_pipeline}/chop.py | 0 .../src/rst_code_example_pipeline/extract_projects.py | 2 +- .../src/rst_code_example_pipeline}/resource.py | 0 4 files changed, 1 insertion(+), 2 deletions(-) rename frontend/{sphinx/widget => python/rst_code_example_pipeline/src/rst_code_example_pipeline}/chop.py (100%) rename frontend/{sphinx/widget => python/rst_code_example_pipeline/src/rst_code_example_pipeline}/resource.py (100%) diff --git a/frontend/python/rst_code_example_pipeline/pyproject.toml b/frontend/python/rst_code_example_pipeline/pyproject.toml index a16f7af1b..2192c5af0 100644 --- a/frontend/python/rst_code_example_pipeline/pyproject.toml +++ b/frontend/python/rst_code_example_pipeline/pyproject.toml @@ -17,4 +17,3 @@ where = ["src"] [tool.pyright] pythonVersion = "3.10" -extraPaths = ["../../sphinx"] diff --git a/frontend/sphinx/widget/chop.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/chop.py similarity index 100% rename from frontend/sphinx/widget/chop.py rename to frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/chop.py diff --git a/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/extract_projects.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/extract_projects.py index a9bebe3da..78b2b0885 100755 --- a/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/extract_projects.py +++ b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/extract_projects.py @@ -13,7 +13,7 @@ import re import json -from widget.chop import manual_chop, real_gnatchop +from .chop import manual_chop, real_gnatchop from . import blocks from . import fmt_utils diff --git a/frontend/sphinx/widget/resource.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/resource.py similarity index 100% rename from frontend/sphinx/widget/resource.py rename to frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/resource.py From 745f88b1006b33ecf980bc715bb2dd477f7c23af Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 13 Jun 2026 01:57:22 +0200 Subject: [PATCH 14/28] Sphinx: import chop/resource from rst_code_example_pipeline in widget Update sphinx/widget/widget.py to import ChopStrategy, manual_chop, cheapo_gnatchop, real_gnatchop, and Resource from the package rather than from sibling modules within sphinx/widget/ (which no longer exist). This inverts the dependency direction: sphinx/widget/ now depends on the library instead of the other way around. Co-Authored-By: Claude Sonnet 4.6 --- frontend/sphinx/widget/widget.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/sphinx/widget/widget.py b/frontend/sphinx/widget/widget.py index 8544de797..58e60e2d7 100644 --- a/frontend/sphinx/widget/widget.py +++ b/frontend/sphinx/widget/widget.py @@ -3,8 +3,8 @@ from typing import List, Match, Dict, Optional from .button import Button -from .chop import manual_chop, cheapo_gnatchop, real_gnatchop, ChopStrategy -from .resource import Resource +from rst_code_example_pipeline.chop import manual_chop, cheapo_gnatchop, real_gnatchop, ChopStrategy +from rst_code_example_pipeline.resource import Resource class ButtonException(Exception): pass From 376bd34425baedd10614f9fc9791435fcc9f18a1 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 13 Jun 2026 01:57:35 +0200 Subject: [PATCH 15/28] Test script: update execute_rst_code_blocks chop import chop.py is no longer in sphinx/widget/; update the import to rst_code_example_pipeline.chop. Co-Authored-By: Claude Sonnet 4.6 --- frontend/tests/execute_rst_code_blocks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/tests/execute_rst_code_blocks.py b/frontend/tests/execute_rst_code_blocks.py index b93f4daf4..46476059f 100755 --- a/frontend/tests/execute_rst_code_blocks.py +++ b/frontend/tests/execute_rst_code_blocks.py @@ -16,7 +16,7 @@ SPHINX_PATH = (Path(__file__).parent.parent / 'sphinx').resolve() sys.path.append(str(SPHINX_PATH)) -from widget.chop import manual_chop, real_gnatchop +from rst_code_example_pipeline.chop import manual_chop, real_gnatchop from code_block import CodeBlock, get_blocks From 83e706e3740f0677fb32f765732f1267f61c3b12 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 13 Jun 2026 01:57:54 +0200 Subject: [PATCH 16/28] Sphinx: update widget chop/resource tests to new import path test_chop.py and test_resource.py imported from widget.chop / widget.resource; both modules now live in rst_code_example_pipeline. Co-Authored-By: Claude Sonnet 4.6 --- frontend/sphinx/tests/test_chop.py | 4 ++-- frontend/sphinx/tests/test_resource.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/sphinx/tests/test_chop.py b/frontend/sphinx/tests/test_chop.py index aeab04dd3..136e77579 100644 --- a/frontend/sphinx/tests/test_chop.py +++ b/frontend/sphinx/tests/test_chop.py @@ -1,7 +1,7 @@ import unittest -from widget.chop import manual_chop, cheapo_gnatchop, real_gnatchop -from widget.resource import Resource +from rst_code_example_pipeline.chop import manual_chop, cheapo_gnatchop, real_gnatchop +from rst_code_example_pipeline.resource import Resource class TestManual_Chop(unittest.TestCase): diff --git a/frontend/sphinx/tests/test_resource.py b/frontend/sphinx/tests/test_resource.py index c20f95d41..2f00216a9 100644 --- a/frontend/sphinx/tests/test_resource.py +++ b/frontend/sphinx/tests/test_resource.py @@ -1,6 +1,6 @@ import unittest -from widget.resource import Resource +from rst_code_example_pipeline.resource import Resource class TestResource(unittest.TestCase): From 2db06742e71271665d769aa77f498c1d21b15672 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 13 Jun 2026 01:58:52 +0200 Subject: [PATCH 17/28] Test: drop widget.chop import guard from smoke tests (chop now in package) chop.py and resource.py are now inside rst_code_example_pipeline, so extract_projects.py uses an intra-package import. The four @unittest.skipUnless decorators that guarded tests requiring widget.chop on PYTHONPATH are no longer needed; all 14 tests now run unconditionally. Remove _widget_available(), the unused `sys` import, and the now-stale docstring note about sphinx/ PYTHONPATH. Co-Authored-By: Claude Sonnet 4.6 --- .../tests/test_smoke.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/frontend/python/rst_code_example_pipeline/tests/test_smoke.py b/frontend/python/rst_code_example_pipeline/tests/test_smoke.py index 58ef91b4f..c0d727c3b 100644 --- a/frontend/python/rst_code_example_pipeline/tests/test_smoke.py +++ b/frontend/python/rst_code_example_pipeline/tests/test_smoke.py @@ -5,27 +5,13 @@ python -m unittest discover -s tests/ or (from the project root): python -m unittest rst_code_example_pipeline.tests.test_smoke - -Note: tests that import extract_projects / check_projects require -`sphinx/` on PYTHONPATH (for widget.chop), as sphinx/widget/chop.py has -not yet been moved into the package. Those tests are skipped automatically -when widget is absent. """ -import sys import unittest from unittest.mock import patch import rst_code_example_pipeline -def _widget_available() -> bool: - try: - import widget.chop # noqa: F401 - return True - except ImportError: - return False - - class TestPackageMetadata(unittest.TestCase): def test_title(self) -> None: self.assertEqual(rst_code_example_pipeline.__title__, @@ -60,11 +46,9 @@ def test_import_toolchain_setup(self) -> None: def test_import_check_code_block(self) -> None: from rst_code_example_pipeline import check_code_block # noqa: F401 - @unittest.skipUnless(_widget_available(), 'widget.chop not on PYTHONPATH (sphinx/widget/chop.py not yet moved into the package)') def test_import_extract_projects(self) -> None: from rst_code_example_pipeline import extract_projects # noqa: F401 - @unittest.skipUnless(_widget_available(), 'widget.chop not on PYTHONPATH (sphinx/widget/chop.py not yet moved into the package)') def test_import_check_projects(self) -> None: from rst_code_example_pipeline import check_projects # noqa: F401 @@ -83,11 +67,9 @@ def _assert_help_exits_zero(self, entry: str) -> None: def test_check_block_help(self) -> None: self._assert_help_exits_zero('check_block') - @unittest.skipUnless(_widget_available(), 'widget.chop not on PYTHONPATH (sphinx/widget/chop.py not yet moved into the package)') def test_extract_help(self) -> None: self._assert_help_exits_zero('extract') - @unittest.skipUnless(_widget_available(), 'widget.chop not on PYTHONPATH (sphinx/widget/chop.py not yet moved into the package)') def test_check_help(self) -> None: self._assert_help_exits_zero('check') From ef4e1017a148a524a91c297f820084cf8ed0bdde Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 13 Jun 2026 02:23:03 +0200 Subject: [PATCH 18/28] Python: move toolchain.ini into data/ subdirectory (git mv) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Relocate the configuration file: src/rst_code_example_pipeline/toolchain.ini → src/rst_code_example_pipeline/data/toolchain.ini Co-Authored-By: Claude Sonnet 4.6 --- .../src/rst_code_example_pipeline/{ => data}/toolchain.ini | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/{ => data}/toolchain.ini (100%) diff --git a/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain.ini b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/data/toolchain.ini similarity index 100% rename from frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain.ini rename to frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/data/toolchain.ini From 7ca089f02108a22bbed54b3994784108040c8ee8 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 13 Jun 2026 02:26:41 +0200 Subject: [PATCH 19/28] Python: load toolchain.ini via importlib.resources; declare as package data Switch toolchain_info.py from os.path-based file discovery to importlib.resources.files(), which is the idiomatic Python 3.10+ way to locate data files bundled inside a package. The config is now read with files('rst_code_example_pipeline').joinpath('data/toolchain.ini').read_text() instead of constructing an absolute path relative to __file__. Add [tool.setuptools.package-data] to pyproject.toml so the .ini file under src/rst_code_example_pipeline/data/ is included in the installed distribution. Co-Authored-By: Claude Sonnet 4.6 --- frontend/python/rst_code_example_pipeline/pyproject.toml | 3 +++ .../src/rst_code_example_pipeline/toolchain_info.py | 9 ++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/python/rst_code_example_pipeline/pyproject.toml b/frontend/python/rst_code_example_pipeline/pyproject.toml index 2192c5af0..29be792ae 100644 --- a/frontend/python/rst_code_example_pipeline/pyproject.toml +++ b/frontend/python/rst_code_example_pipeline/pyproject.toml @@ -15,5 +15,8 @@ learn-check-block = "rst_code_example_pipeline.cli.check_block:main" [tool.setuptools.packages.find] where = ["src"] +[tool.setuptools.package-data] +rst_code_example_pipeline = ["data/*.ini"] + [tool.pyright] pythonVersion = "3.10" diff --git a/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain_info.py b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain_info.py index bdae8c293..cbcb57a3d 100644 --- a/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain_info.py +++ b/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain_info.py @@ -1,10 +1,8 @@ #! /usr/bin/env python3 -import os import re import configparser - -TOOLCHAIN_CONFIG = os.path.dirname(os.path.realpath(__file__)) + "/" + "toolchain.ini" +from importlib.resources import files TOOLCHAIN_PATH: dict[str, str] = {} TOOLCHAINS: dict[str, list[str]] = {} @@ -12,8 +10,9 @@ def init_toolchain_info() -> None: config = configparser.ConfigParser() - - config.read(TOOLCHAIN_CONFIG) + config.read_string( + files('rst_code_example_pipeline').joinpath('data/toolchain.ini').read_text() + ) DEFAULT_VERSION['gnat'] = config['default_version']['gnat'] DEFAULT_VERSION['gnatprove'] = config['default_version']['gnatprove'] From 324596e049887bed5d205be29e6b1121d4bf83c0 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 13 Jun 2026 02:27:05 +0200 Subject: [PATCH 20/28] Vagrant: update toolchain.ini path after data/ subdirectory move The file was moved from src/rst_code_example_pipeline/toolchain.ini to src/rst_code_example_pipeline/data/toolchain.ini. Update the provision source path for both the web and epub VMs. Co-Authored-By: Claude Sonnet 4.6 --- Vagrantfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index d6e601dcb..5ad06e6a0 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -234,7 +234,7 @@ Vagrant.configure("2") do |config| web.vm.synced_folder './frontend', '/vagrant/frontend' web.vm.synced_folder './content', '/vagrant/content' - web.vm.provision "file", source: "./frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain.ini", destination: "/home/vagrant/toolchain.ini" + web.vm.provision "file", source: "./frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/data/toolchain.ini", destination: "/home/vagrant/toolchain.ini" web.vm.provision "file", source: "./frontend/vm_apt_web.txt", destination: "/home/vagrant/vm_apt.txt" web.vm.provision :shell, inline: $frontend end @@ -246,7 +246,7 @@ Vagrant.configure("2") do |config| epub.vm.synced_folder './frontend', '/vagrant/frontend' epub.vm.synced_folder './content', '/vagrant/content' - epub.vm.provision "file", source: "./frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/toolchain.ini", destination: "/home/vagrant/toolchain.ini" + epub.vm.provision "file", source: "./frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/data/toolchain.ini", destination: "/home/vagrant/toolchain.ini" epub.vm.provision "file", source: "./frontend/vm_apt_epub.txt", destination: "/home/vagrant/vm_apt.txt" epub.vm.provision :shell, inline: $epub end From a9e00c018ef88bbfc49e91179f0fabbb8ff47586 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 13 Jun 2026 02:27:15 +0200 Subject: [PATCH 21/28] CI: update toolchain.ini path in install_toolchain.sh Point TOOLCHAIN_CONFIG at the new location under the Python package after the file was moved into the data/ subdirectory and the package renamed from py_modules/code_projects to python/rst_code_example_pipeline. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/install_toolchain.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/install_toolchain.sh b/.github/workflows/install_toolchain.sh index 599639378..9f60a8595 100755 --- a/.github/workflows/install_toolchain.sh +++ b/.github/workflows/install_toolchain.sh @@ -2,7 +2,7 @@ GNAT_FSF_BUILDS=https://github.com/alire-project/GNAT-FSF-builds/releases/download -TOOLCHAIN_CONFIG=${GITHUB_WORKSPACE}/frontend/py_modules/code_projects/toolchain.ini +TOOLCHAIN_CONFIG=${GITHUB_WORKSPACE}/frontend/python/rst_code_example_pipeline/src/rst_code_example_pipeline/data/toolchain.ini INSTALL_GNATPROVE=NO INSTALL_GNAT=NO From 1450e020913f42cfd6d7a32269dc76664a2063ff Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 13 Jun 2026 02:27:21 +0200 Subject: [PATCH 22/28] Python: remove pyrightconfig.json (superseded by pyproject.toml) [tool.pyright] in pyproject.toml now carries the pyright configuration. The standalone pyrightconfig.json is redundant and was carrying a stale extraPaths entry that no longer applies. Co-Authored-By: Claude Sonnet 4.6 --- .../python/rst_code_example_pipeline/pyrightconfig.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 frontend/python/rst_code_example_pipeline/pyrightconfig.json diff --git a/frontend/python/rst_code_example_pipeline/pyrightconfig.json b/frontend/python/rst_code_example_pipeline/pyrightconfig.json deleted file mode 100644 index 78155394b..000000000 --- a/frontend/python/rst_code_example_pipeline/pyrightconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pythonVersion": "3.10", - "extraPaths": [ - "../../sphinx" - ] -} From 8eab0c3857db64da65100cc9df8c7f0af9c5ede3 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 13 Jun 2026 02:27:57 +0200 Subject: [PATCH 23/28] Docs: refresh package README with entry-point commands Update all script invocations from python3 py_modules/code_projects/