Created attachment 273377 [details] patch spatch from coccinelle 1.3.1 dies on any semantic patch with a @script:python@ rule: Py.find_library_path: unable to parse the output of pkg-config '-L/usr/local/lib' exit: 255 Cause: bundled pyml (bundles/pyml/pyml-current/py.ml) probes pkg-config --libs python-3.12 to find libpython. That module has an empty Libs: (it's for building extensions). The -lpython lives in the sibling -embed module, same package: $ pkg-config --libs python-3.12 # -L/usr/local/lib $ pkg-config --libs python-3.12-embed # -L/usr/local/lib -lpython3.12 pyml finds no -l, raises, and spatch aborts. Fix: query the -embed module. One-line patch, no new dependency (the .pc ships in the same pythonXY package). Reproduce / verify: cat > /tmp/mini.cocci <<'EOF' @r@ identifier f; position p; @@ f@p(...) @script:python@ p << r.p; @@ print("hit: %s:%s" % (p[0].file, p[0].line)) EOF printf 'void foo(void) { bar(1); }\n' > /tmp/mini.c spatch --very-quiet --sp-file /tmp/mini.cocci /tmp/mini.c; echo "exit: $?" Before the patch: unable to parse... / exit 255. After the patch: hit: /tmp/mini.c:1 / exit 0.
(In reply to Olivier Cochard from comment #0) Nice one, thank you! Feel free to take over maintenance if you wish so.
BTW, I'm not sure why you woould want to use the post-test target (I'd assume do-test is fine) but either way that works for you is good. The upstream test suite could be hooked up also, while at it.
Also please use the cannonical ${SETENVI} ${WRK_ENV} ${TEST_ENV} for running the test(s). Thank you.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=bdc565d085e3379eb5f5d6b005a2690878c68d6a commit bdc565d085e3379eb5f5d6b005a2690878c68d6a Author: Olivier Cochard <olivier@FreeBSD.org> AuthorDate: 2026-08-04 10:01:40 +0000 Commit: Olivier Cochard <olivier@FreeBSD.org> CommitDate: 2026-08-04 12:15:56 +0000 devel/coccinelle: Fix python scripting spatch could not load libpython, so all Python scripting failed silently. PR: 297217 Approved by: Benjamin Jacobs <freebsd@dev.thsi.be> (maintainer) Sponsored by: Netflix devel/coccinelle/Makefile | 28 +++++++++++++++++++++- .../patch-bundles_pyml_pyml-current_py.ml (new) | 16 +++++++++++++ devel/coccinelle/files/regress-python.c (new) | 1 + devel/coccinelle/files/regress-python.cocci (new) | 10 ++++++++ 4 files changed, 54 insertions(+), 1 deletion(-)
I don’t think I’m expert enough in coccinelle to take maintainership.