Open rkern opened 1 week ago
Thanks for the detailed write-up!
This feels like a pretty weird pattern, i.e., I don't think this is an intended use of PEP 723. I see how it's helpful, but I'm not sure if we should support it or if there's another pattern we can recommend.
It seems to me that the PEP 723 section on "Why not just set up a Python project with a pyproject.toml
?" applies to the most obvious alternative pattern. This is an internal script not for redistribution (packaging in a bdist). It's just local stuff. It happens to be organized in small package with a __main__.py
instead of a script because it happens to have multiple files.
uv run -m
will not respond to PEP 723 inline script metadata that is included in the script module. My motivating use case is that I typically have some developer and CI conveniences wrapped up in aclick
script with lots of subcommands. I want it to run in an isolated Python venv which only needsclick
installed, not the project's venv. The inline script metadata withuv run
works great for this. However, I usually implement this in a package with a__main__.py
script (I factor some things out like configuration into a separate module and might have some data files; a package works great to isolate all of this to keep it tidy from the rest of the project).uv run -m
does not seem to read the inline script metadata implemented in the__main__.py
(or other modules run via-m
).It's entirely possible that this is not possible if you need the Python env already set up to dereference the
package.module
name to find the actual file. If that is the case, this limitation would be good to document.Thank you!