App.__get_project_refs(): Fix broken detection of missing build dependencies #94

Merged
Jan Lindemann merged 4 commits from jan/fix/20260910-broken-detection-of-missing-build-dependencies into master 2026-09-10 13:15:30 +02:00 AGit
Showing only changes of commit 2ae101d93b - Show all commits

App.__get_project_refs(): Fix recursion stop conditions
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m30s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m37s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 4m10s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m34s
CI / Packaging test (push) Successful in 0s

App.__get_project_refs() recurses into the package dependency graph, but
the recursion end conditions only work well if all required packages are
present. Whether a required package is installed or not is decided upon a
wrong condition, however - existence of the project's project directory,
which may or may not be misleading for both the -devel and the -run
requirements. This can lead to various unwanted outcomes: Missing packages
happily inserted into the recursion buffer, process termination instead of
recursion stop, path lookup errors instead of a clearer "unmet dependency"
message (No project path found for module xyz, Failed to find directory of
project foo).

This commit cleanly detects if -run or -devel are installed and makes the
walk stop or raise under the appropriate conditions:

1. -run missing but required, raises unmet dependency
2. -devel missing but required, raises unmet dependency
3. -run present, no -devel required, stop recursing

Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.85.1
Jan Lindemann 2026-09-09 21:15:39 +02:00
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -210,6 +210,7 @@ class App(Base):
names_only: bool,
) -> None:
name = self.strip_module_from_spec(spec)
mod = re.split('([=><]+)', spec)[0].strip()
if names_only:
spec = name
if spec in buf:
@ -219,6 +220,15 @@ class App(Base):
buf.append(spec)
return
visited.add(spec)
needed_subpackage = 'devel' if mod.endswith(('-dev', '-devel')) else 'run'
if not self.is_installed(name, devel = True):
if not mod.endswith(('-dev', '-devel')):
if self.is_installed(name, devel = False):
return
raise Exception(
f'Unmet dependency on {mod}: the -{needed_subpackage} package '
f'of project {name} is not installed'
)
vals = self.get_value(name, section, key)
log(
DEBUG,