#### Other tools - [`pdm run`](https://pdm-project.org/en/latest/reference/cli/#run) - [`poetry run`](https://python-poetry.org/docs/cli/#run) - [`hatch run`](https://hatch.pypa.io/latest/cli/reference/#hatch-run) - [`uv run`](https://docs.astral.sh/uv/reference/cli/#uv-run) - [`pipx run`](https://pipx.pypa.io/latest/docs/#pipx-run) #### Purpose For simplest way to execute code in an implicit virtual environment (i.e. the Python interpreter is an implementation detail). #### Notes Need to consider [[Caching app files while being ignored by backup apps]] for the implicit virtual environments. - `--group`/`--with`: Specifies the dependency group to use (only applicable when a directory path is specified, maybe zip file if it ships with a `pyproject.toml`) - Care about extras, e.g. `--extra` or implicitly specified via `--group`/`--with`? - `uv` uses `--extra` - Making it the same name as for dependency groups helps transition from an extra to a group when a project makes such a move - If a file path is specified: - If the file is a zip file, do anything special like look for inline script metadata in `__main__.py`? A lock file? - If [inline script metadata](https://packaging.python.org/en/latest/specifications/inline-script-metadata/) is specified, use that - Otherwise assume metadata of no dependencies and any Python version - If a directory path is specified: - For convenience when a [directory contains a `__main__.py` file](https://docs.python.org/3/using/cmdline.html) - Use inline script metadata, `pyproject.toml`, or `pylock.toml`? - Provide a way to specify whether `launch` or `run` are the default when no subcommand specified? - Don't read the shebang; only rely on the metadata to limit the Python version - Execute what's in `bin/` for the virtual environment if command name is specified? - Fall back to `-m` if nothing found in `bin/` matching the name (and it wasn't a valid path)?