Letting python-tools.sh rewrite symbols is more robust than rewriting an entire __init__.py with PY_INIT_FILTER in the including Makefile. The latter can break in non-obvious ways if python-tools.sh changes __init__.py's format.
Make python-tools.sh support --symbol-filter to remedy that. The option takes an sed script which should expect a string of two non-whitespace tokens: The module from which the symbol is imported, and the name of the symbol in that module. It's output will then be used as the symbol to be exported from __init__.py.
Also, support the PY_SYMBOL_FILTER variable in py-mod.mk. If it's defined, it is used for --symbol-filter.
Make the log delimiter look more consistent: Whether a CallContext was constructed with a title parameter or without, prefix its .log_delimiter property with a "----".
Remove CmdPythonpathOrig. Its only purpose has ever been to document and try out how cmd_pythonpath_orig() had worked in an ancient application version, that purpose is now served.
Make use of the newly introduced --prefix option to the pythonpath command, and generate what's subseqently used to fill in mypy_path in pyproject.toml.
By decoupling it from PYTHONPATH, this commit makes the creation of mypy_path less involved and easier to understand. It also obviates the need replace the relatively heavy ldlibpath.mk by the relatively lightweight projects.mk, thereby enhancing performance.
The global --topdir-format option governs how a project's root directory is represented in paths output by various queries. "absolute" means as absolute path, "unaltered" means verbatim as specified via --topdir, make:xyz means replaced by the string $(xyz), for later expansion in a makefile variable.
This commit adds another variant: "relative" yields the shortest possible output format of the output path in question relative to --topdir, with "shortest possible" in this context meaning canonicalized and leading "./" stripped.
Ignore newline at the end of Result.stdout_str if only one line of output is wanted from an executed shell command. The output of both uname and mktemp are used wrongly in that regard.
Add a [tool.mypy] section to pyproject.toml with a {mypypath} template variable. The already existing template generation mechanism in py-topdir.mk should fill that in with a path pointing to all Python modules managed by jw-pkg:
pyproject.toml is currently copied unchanged from conf/topdir to the toplevel directory. Set up machinery in py-topdir.mk to render it from a template in conf/templates instead, replacing {mypypath} in the process.
- Add an additional, more generic value that --format understands:
"tmpl". If chosen, the template selected by the new option
--template-name is rendered by replacing --field key=value pairs.
- This commit also adds the option --quote, which makes the
renderer enclose the rendered variable values in double quotes.
Add --search-path to the list of CmdCreateFile's supported options. Its value is split by ":" and subsequently passed to the tmpl_render()'s search_path argument.
tmpl_render()'s "values" argument currently understands dict[str,str|list[str]]. Enhance that to understand the broader RenderValues type, which also includes Iterable[tuple[str, str]], as produced by argparse.add_argument(action='append').
This commit also adds proper type-checking for the values argument. Before, its type had gone unchecked entirely.
Add an additional keyword-argument search_path to templates.tmpl_render(). It allows to specifiy a list of directory paths in which a template of a given name can be found. It defaults to [], in which case only the built-in templates are considered. Otherwise file locations are tried first, then the built-in templates.
In order to allow Pyright to check the types provided by dependant repositories without installing them, pyrightconfig.json contains a list of paths to their root directories in "extraPaths". These paths are unusable for Pyright, though: For type checking to work, it needs to be pointed to the "jw" namespace package paths within those repos. This commit achieves that by appending the subdirs src/python and tools/python to them, provided they exist.
TODO: This fix hardcodes the current project directory structure. Better would be a way to customize that via makefiles, where the paths can be more easily customized.
Replace variable PY_SRC_ROOT by PY_CHECK_ROOTS. The name PY_SRC_ROOT was a bad choice, given that it isn't immediately obvious that it a) can contain multiple root locations to be checked, and that it b) specifically concerns static type checking.
As of this commit, it's possible to limit the type checking scope with PY_CHECK_ROOTS as in
PY_CHECK_ROOTS="src/python/jw/pkg/CmdBase.py src/python/jw/lib" \
make check
App.get_projects_refs() is a versatile tool, but what it does isn't obvious. Use the simpler method .get_value() instead for get_libname(), and return None if a project doesn't provide a linkable library.
- Rename variable dep and deps to val and vals, respectively,
because that's more what they are values of key-value pairs. In
some cases that can represent dependencies, in some case other
things.
- Make a scope case distinction a little clearer by mentioning all
possible cases in a match / case block
Add enable-email-notifications: true. This seems to be needed for sending information about failed runs. Apparently it doesn't make it difference if I add it to ci/workflows/.github/workflows/test-packaging.yaml.
In another attempt at making CI workflow naming more concise:
- Rename standard-tests.yaml to ci.yaml
Currently the contents of this file covers everything CI-related
that happens in the context workflows, so for the time being,
naming it ci.yaml is just fitting. And it's going to be shorter
in commit message summaries. Should a real need arise, we can
always split the file up again.
- Shorten names again, otherwise they don't fit into Forgejo's
check-mark-popup. That should be self-explanatory in context:
name:
Default CI -> CI
jobs.CI.name:
Packaging test - All supported platforms -> Packaging test
Running pyright in a minimal docker container gives this error:
$ pyright
/usr/bin/npm-default: No such file or directory
Traceback (most recent call last):
File "/usr/bin/pyright-3.13", line 6, in <module>
sys.exit(entrypoint())
~~~~~~~~~~^^
File "/usr/lib/python3.13/site-packages/pyright/cli.py", line 31, in entrypoint
sys.exit(main(sys.argv[1:]))
~~~~^^^^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/pyright/cli.py", line 18, in main
return run(*args, **kwargs).returncode
~~~^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/pyright/cli.py", line 22, in run
pkg_dir = install_pyright(args, quiet=None)
File "/usr/lib/python3.13/site-packages/pyright/_utils.py", line 69, in install_pyright
node.run(
~~~~~~~~^
'npm',
^^^^^^
...<5 lines>...
stderr=subprocess.PIPE if silent else sys.stderr,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/lib/python3.13/site-packages/pyright/node.py", line 144, in run
subprocess.run(node_args, **kwargs),
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.13/subprocess.py", line 577, in run
raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/bin/npm', 'install', \
'pyright@1.1.409']' returned non-zero exit status 255.
This means that on openSUSE, python3-pyright tries to pull in packages from the NPM registry. This increases the CI supply chain attack surface inacceptably, so remove pyright from the release prerequisites. That should be enough to remove it from the prerequisites of target check as well and allow it to succeed.
The pyright check machinery itself remains useful, so keep it in place for developers who install python3-pyright manually.
By the time projects-dir.mk is used during onboarding, it's already cloned, and so is jw-pkg in all its glory. So better use a ssh-wrapper.sh directly under jw-pkg's version control instead of plainly generating one with echo some-script-logic > ssh-wrapper.sh.
This has the main benefit of allowing a more elaborate script. The one added by this commit removes "-l user" from remotes which have a standard-user@gitserver form, typically because they differentiate users via their SSH pubkeys only, and which would deny access if both -l user and standard-user@ were specified.
ssh-wrapper.sh still needs to be a target which is updated by a recipe, because the version found in jw-pkg can't be trusted to be executable during bootstrapping, because "make all" has not run, yet.
After release, pkg.sh pushes the changes to VERSION and HASH upstream. Failures are masked, though, propagate them.
Unclear what motivated masking the error. Tracking that down with git blame leads to build-package.sh, which was inherited from ytools, where the change was introduced 2014 with the trust-inspiring comment:
attempted fix for error during commit of version files in build-package.sh