cmds.projects.CmdCreatePkgConfig: Fix Requires lines

__cleanup_requires() replaces every run of whitespace with ", " before
re-pairing the version constraints, so input that is already
comma-separated, e.g. "jw-core >= 1.0, jw-base", comes out with a double
comma, "jw-core >= 1.0,, jw-base". And the Requires line is appended
without a trailing newline, so a following Requires.private line runs
straight into it.

Split the input on commas and whitespace, treating the version constraint
operators as delimiters that are re-paired with the preceding name and the
following version, so that comma- and space-separated input alike comes out
as a clean ", "-joined list. Add the missing newline after the Requires
line.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-09-08 21:53:41 +02:00
commit dd2fff17a5
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
3 changed files with 58 additions and 10 deletions

View file

@ -0,0 +1,8 @@
TOPDIR = ../../../../../../../..
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-run.mk
all:
test: run

View file

@ -0,0 +1,31 @@
from jw.pkg.cmds.projects.CmdCreatePkgConfig import CmdCreatePkgConfig
# __cleanup_requires() is a private staticmethod; reach it via getattr
cleanup = getattr(CmdCreatePkgConfig, '_CmdCreatePkgConfig__cleanup_requires')
# -- __cleanup_requires --
# Comma- and space-separated input alike comes out as a clean ", "-joined list
assert cleanup('jw-core >= 1.0, jw-base') == 'jw-core >= 1.0, jw-base'
assert cleanup('jw-core >= 1.0 jw-base') == 'jw-core >= 1.0, jw-base'
assert cleanup('jw-core >= 1.0, jw-base') == 'jw-core >= 1.0, jw-base'
# Plain names without version constraints are joined the same way
assert cleanup('a b c') == 'a, b, c'
# A single element is unchanged
assert cleanup('jw-core >= 1.0') == 'jw-core >= 1.0'
# The empty input yields the empty output
assert cleanup('') == ''
# Every constraint operator is re-paired with its name and version
assert (
cleanup('x <= 2, y != 3, z == 4, w > 5, v < 6, u = 7') ==
'x <= 2, y != 3, z == 4, w > 5, v < 6, u = 7'
)
# Whitespace around a separator collapses to a single ", "
assert cleanup('jw-a = 1.0 , jw-b = 2.0') == 'jw-a = 1.0, jw-b = 2.0'
print('All CmdCreatePkgConfig tests passed')