Improve CmdPythonpath / mypy_path generation #10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "jan/feature/20260611-feature/20260611-better-mypy-path"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Improve CmdPythonpath / mypy_path generation
This PR presents a series of commits making the generation of mypy_path for pyproject.toml a little less involved. It does so via enhancing infrastructure support in App and CmdPythonpath. The changes to Pythonpath make it gravitate towards a more generic CmdSubpath command. Could be useful for unifiying it with other commands like CmdLdlibpath, CmdExepath.
App: Support --topdir-format "relative"
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.
cmds.projects.CmdPythonpath: Opts subdir, delimiter, prefix
Support additional options:
--subdir makes the command look for these existing subdirectories. Can be specified multiple times.
--delimiter Does the obvious and defaults to ":"
--prefix A string to prepend verbatim before each path component
py-topdir.mk: Use pythonpath --prefix for mypy_path
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.
build.cmds.CmdPythonpathOrig: Remove
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.
build.cmds.CmdPythonpathOrig: Removeto Improve CmdPythonpath / mypy_path generation