From 7c76abed3365f4e1ebc74cf51f3344790873fea3 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sun, 6 Sep 2026 17:18:32 +0200 Subject: [PATCH] App.find_dir(): Allow restricting the project roots find_dir() and its helpers resolve a project name against the workspace root and /opt. The build iteration needs to resolve a module against the workspace only, to tell buildable projects apart from installed ones. Add a projs_roots parameter to find_dir(), __find_dir() and __proj_dir() that restricts the search to the given roots. With the parameter omitted the previous behavior is unchanged. Signed-off-by: Jan Lindemann Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2 --- src/python/jw/pkg/App.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/python/jw/pkg/App.py b/src/python/jw/pkg/App.py index fe93c585..a9ab6eb6 100644 --- a/src/python/jw/pkg/App.py +++ b/src/python/jw/pkg/App.py @@ -21,7 +21,7 @@ if TYPE_CHECKING: import argparse from argparse import ArgumentParser - from typing import TypeAlias + from typing import Iterable, TypeAlias from .lib.PackageFilter import PackageFilter @@ -77,12 +77,17 @@ class App(Base): raise Exception('Tried to access undefined pretty top directory') return self.___pretty_topdir - def __proj_dir(self, name: str, pretty: bool) -> str | None: + def __proj_dir( + self, + name: str, + pretty: bool, + projs_roots: Iterable[str | None] | None = None, + ) -> str | None: if name == self.__top_name: if pretty: return self.__pretty_topdir return self.__topdir - for d in [self.__projs_root, self.___opt_root]: + for d in projs_roots or [self.__projs_root, self.___opt_root]: if d is None: continue ret = d + '/' + name @@ -99,6 +104,7 @@ class App(Base): search_subdirs: list[str] | None = None, search_absdirs: list[str] | None = None, pretty: bool = True, + projs_roots: Iterable[str | None] | None = None, ) -> str | None: if search_subdirs is None: search_subdirs = [] @@ -134,7 +140,7 @@ class App(Base): f'Tried to pretty-format directory {pd}, not implemented' ) - pd = self.__proj_dir(name, False) + pd = self.__proj_dir(name, pretty = False, projs_roots = projs_roots) if pd is None: return None if not search_subdirs and not search_absdirs: @@ -405,8 +411,9 @@ class App(Base): search_absdirs: list[str] | None = None, pretty: bool = True, throw: bool = False, + projs_roots: Iterable[str | None] | None = None, ) -> str | None: - ret = self.__find_dir(name, search_subdirs, search_absdirs, pretty) + ret = self.__find_dir(name, search_subdirs, search_absdirs, pretty, projs_roots) if ret is not None: return ret if not throw: