pyrightconfig.json as generated by CmdCreateFile, doesn't contain the
repository's own Python source location in "extra_paths", fix that.
Signed-off-by: Jan Lindemann <jan@janware.com>
An Uri instance constructed from "~/some/path" returns
"file://~/some/path" as the .full property, i.e. with the "~" in the
authority part. That's not accurate and doesn't make the intended
sense in an URL context, see RFC 8089:
Common UNIX shells such as the Bourne-Again SHell (bash) and Z
SHell (zsh) provide a function known as "tilde expansion"
[Bash-Tilde] or "filename expansion" [Zsh-Tilde], where a path
that begins with a tilde character "~" can be expanded out to a
special directory name. No such facility exists using the file
URI scheme; a tilde in a file URI is always just a tilde.
The "fix" introduced by this commit makes .full return the path
without file:// prepended. That's conservative. It could also chose
to expand the tilde, which is arguably cleaner. To be introduced by a
later change after this commit has seen more coverage.
Signed-off-by: Jan Lindemann <jan@janware.com>
In non-interactive mode, "zypper dup" runs with the options
--force-resolution and --auto-agree-with-licenses duplicated, fix
that.
Signed-off-by: Jan Lindemann <jan@janware.com>
subpackages = "run, devel" is not tolerated by create-mkspec.sh. It
expects "run devel", which goes against the grain of the other
metadata, so make it at least tolerate the more common
comma-separated variant.
Signed-off-by: Jan Lindemann <jan@janware.com>
Mypy scans both src/python/ and test/ under the same jw namespace,
and finds three test files named test.py. Without a package root at
the test/ level, mypy resolves all of them to the bare module name
test, and rejects them as duplicates.
Add __init__.py at test/ marks it as a package root, so each test.py
resolves to a unique full path, e.g.
test.unit.python.jw.pkg.lib.Result.test
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>
Yapf complains about spacing inconsistencies around assignment operators
in function calls, fix that.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>
The _load() helper in test/unit/python/jw/pkg/lib/ProjectConf/test.py
uses tempfile.NamedTemporaryFile(..., delete=False) but never removes
the created files. Each test call leaked a .conf file in /tmp.
Track all created paths in a _tmpfiles list and call _cleanup() at the
end of the test to unlink them.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>
Two error messages in Distro.__init__() contain the typo 'instaniate'
instead of 'instantiate'. Fix the spelling.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>
Remove unused helper functions from install():
_matches_host_prefix(), _crop_host_prefix(), _crop_default_prefix(),
and _matches_default_prefix().
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>
log() uses a regular string instead of an f-string, fix that.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>
The scheme property returns 'file://' for local paths instead of
'file', causing scheme_plus_authority to produce 'file://://' with a
triple slash.
Also fix the test to expect 'file' instead of 'file://'.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>
The CopyContext._run() calls await self._run(), which would create
infinite recursion raising RecursionError at runtime. Make it a pure
virtual.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.80.2
Signed-off-by: Jan Lindemann <jan@janware.com>
Generate a standard conftest.py, mostly for customizing pytest's
bombastic test header, which otherwise lets the more informative make
output look too pale in comparison.
Signed-off-by: Jan Lindemann <jan@janware.com>
Add a dedicated py-test.mk for running tests with pytest instead of
python.
The commit introduces a new variable PYTHON_RUNNER, which is then
used by py-run.mk to do it's usual thing. Running pytest is similar
enough to running Python programs to keep the rest of the machinery
and prevent redundancy from creeping in.
Signed-off-by: Jan Lindemann <jan@janware.com>
Every directory should have a test target, and the test target should
depend on all so that all files are generated that might be needed
for testing. This commit fixes some missing targets, and adds some
missing dependencies.
Signed-off-by: Jan Lindemann <jan@janware.com>
get_values() splits comma-separated values and strips whitespace but
does not filter out empty strings. A value like "a, b, " produces
['a', 'b', ''], with an empty string at the end. This empty string
propagates to callers like CmdRequiredOsPkg.py and pollutes output.
Add a filter for non-empty stripped values.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>
The refactored __get_project_conf() raises FileNotFoundError when
project.conf does not exist, whereas the original read_value()
returns None. This causes get_value() to crash for projects with
missing or incomplete project.conf files.
Catch FileNotFoundError in __get_project_conf() and return None to
restore original behavior. Remove redundant @cache from
__read_project_conf() since __get_project_conf() already provides
caching.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>
The __find_circular_deps() and find_circular_deps() methods now
return list[str] instead of bool. On a cycle, the path builds up the
dependency chain in __find_circular_deps_recursive(), and
__find_circular_deps() appends the closing project to complete the
cycle. An empty list means no cycle found.
CmdDep prints the cycle as 'a -> b -> c -> a' instead of a generic
message.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>
The fd.close() call inside the `with open(...) as fd:` block is
redundant because the file handle is managed by the context manager.
Remove it.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>
Replace the hardcoded /opt in __proj_dir() with a configurable ___opt_root
member, consistent with how __projs_root is configured.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>
Mutable default arguments (list) cause unexpected shared state
between calls. Use None as default and initialise to [] inside the
function body.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>
get_project_refs() always returns a list[str], never None. The `if
deps is None: continue` check in __read_dep_graph() is dead code,
remove it.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>
The __flip_dep_graph(graph) call sits inside the while loop and
performs redundant graph flipping on every iteration. Hoist it
outside to compute once and reuse the result.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>
Remove App.get_section() which parses raw file sections by scanning for
section headers and accumulating lines. This method is no longer needed
since ProjectConf now handles all config file parsing.
Signed-off-by: Jan Lindemann <jan@janware.com>
Refactor App to use the new ProjectConf module for parsing
make/project.conf files.
This commit
- removes the inline ad-hoc read_value() method and its nested
helper functions, replacing them with ProjectConf's
get_str_or_none() API.
- introduces two cached helper methods (__read_project_conf() and
__get_project_conf()) to read and cache ProjectConf instances per
project.
- updates get_value() to delegate to ProjectConf and moves the
proj_dir lookup to only run in the version branch where it is
needed.
- updates the topdir init to use __read_project_conf() with a
FileNotFoundError catch for optional config files.
Signed-off-by: Jan Lindemann <jan@janware.com>
Add unit tests for the new ProjectConf module covering:
- Basic string and list value retrieval (get_str(), get_str_or_none(),
get_list(), get_list_or_none())
- Quoted values with preserved spaces and comment delimiters
- Inline comments outside quotes
- Comma-separated lists with quoted commas
- Line continuations
- Multiple sections
- Error cases: empty key, missing key/section, malformed sections,
unfinished continuations, unclosed quotes
- Error class is a subclass of ValueError
Also include a Makefile for running tests via `make test`.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>
Introduce ProjectConf module to cleanly parse make/project.conf ini-like
configuration files. The new class supports:
- ini-style sections with header comments
- Key-value pairs with backslash line continuation
- Quoted values preserving spaces and comment delimiters (#) inside
- Inline comments outside of quotes
- Comma-separated list values with quoted commas
- Cached section parsing to avoid re-parsing the same section
- .get_section() to return an entire section unparsed
Signed-off-by: Jan Lindemann <jan@janware.com>
Replace the @functools.lru_cache(maxsize=None) decorator with
@functools.cache throughout App. functools.cache is a shorthand for
functools.lru_cache(maxsize=None) introduced in Python 3.9 and is
more concise and readable with identical behaviour.
Signed-off-by: Jan Lindemann <jan@janware.com>
Fix shellcheck SC2068 (unquoted array expansions), SC2145 (mixed
string/array arguments), SC2328 (redirection in command
substitution), SC2173 (untrapable signals), and SC2148 (missing
shebang) errors across 14 script files.
Also configure scripts/Makefile with --severity=error so that only
errors (not warnings or notes) cause check failures. To be tightened
by follow-up commits.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>
Add a unit test for the Result class covering:
- stdout/stderr property access with various status values
- None output handling and exception behavior
- Encoding and strip_output property setters
- cmd and wd setters
- summary, summarize, and __repr__ behavior
- matches_error pattern matching
Signed-off-by: Jan Lindemann <jan@janware.com>
Move the unit test hierarchy to below test/unit/python/jw/pkg.
Nesting the subdirectories so deeply might be overly careful, but it
may as well be not - maybe in the future installable test packages
are going to be generated and need simple ways to install without
stepping onto each other's toes. If not, it's easier to cut two
directory components out than having to reorganize possibly
incoherent paths grown over multiple packages.
Signed-off-by: Jan Lindemann <jan@janware.com>
The Uri class provides URL parsing and manipulation utilities used
throughout jw-pkg. Add a unit test covering URL parsing, credential
handling, path manipulation, and safe string formatting.
Signed-off-by: Jan Lindemann <jan@janware.com>
After a pipeline change, CI now runs "make all" in a repo's root,
which uncovers two problems:
1. The help integration test only succeeded as long CI didn't run
"make all" before "make test". That way, the checked out
repository lacked the generated __init__.py files needed for some
modular subcommands to be fully loaded, and hence, the test should
have failed. The entire machinery only worked because the
subcommands in question are not not essential to building jw-pkg
itself: "secrets" and "posix". So, this commit adapts the help
integration test to the new reality.
2. Regarding python-tools.sh: Commit 55060486 satisfies yapf in some
places of the source code, but in others not anylonger. So patch
python-tools.sh's newline handling again.
While not thematically similar, both fixes get baked into one commit
to satisfy the requirement that every single commit needs to pass
"make clean all check test" individually.
Signed-off-by: Jan Lindemann <jan@janware.com>