uv run
Run a command or script.
デフォルトでは環境内の依存を最新化してコマンド実行
When used with a file ending in .py, the file will be treated as a script and run with a Python interpreter, i.e., uv run file.py is equivalent to uv run python file.py.
If the script contains inline dependency metadata, it will be installed into an isolated, ephemeral environment.
IMO:inline script metadataが書かれたスクリプトの場合は隔離した一時的な仮想環境、それ以外はpyproject.tomlに宣言された仮想環境(と理解した)
実行するコマンドとuv runのオプションを分ける書き方の例(--)
uv run --python 3.12 -- python
--frozen
Run without updating the uv.lock file.
--no-sync
Avoid syncing the virtual environment.
Implies --frozen, as the project dependencies will be ignored (i.e., the lockfile will not be updated, since the environment will not be synced regardless).
--no-project
Avoid discovering the project or workspace.
Instead of searching for projects in the current directory and parent directories, run in an isolated, ephemeral environment populated by the --with requirements.
If a virtual environment is active or found in a current or parent directory, it will be used as if there was no project or workspace.
--python
The Python interpreter to use for the run environment.
If the interpreter request is satisfied by a discovered environment, the environment will be used.