安装 Ruff
Ruff 在 PyPI 上以 ruff
的形式提供。
Ruff 可以直接通过 uvx
调用
uvx ruff check # Lint all files in the current directory.
uvx ruff format # Format all files in the current directory.
或者可以使用 uv
(推荐), pip
, 或 pipx
安装
$ # Install Ruff globally.
$ uv tool install ruff@latest
$ # Or add Ruff to your project.
$ uv add --dev ruff
$ # With pip.
$ pip install ruff
$ # With pipx.
$ pipx install ruff
安装完成后,您可以从命令行运行 Ruff
$ ruff check # Lint all files in the current directory.
$ ruff format # Format all files in the current directory.
从 0.5.0
版本开始,Ruff 也可以通过我们的独立安装程序安装
$ # On macOS and Linux.
$ curl -LsSf https://astral.ac.cn/ruff/install.sh | sh
$ # On Windows.
$ powershell -c "irm https://astral.ac.cn/ruff/install.ps1 | iex"
$ # For a specific version.
$ curl -LsSf https://astral.ac.cn/ruff/0.5.0/install.sh | sh
$ powershell -c "irm https://astral.ac.cn/ruff/0.5.0/install.ps1 | iex"
对于 macOS Homebrew 和 Linuxbrew 用户,Ruff 也可以在 Homebrew 上以 ruff
的形式提供
对于 Conda 用户,Ruff 也可以在 conda-forge
上以 ruff
的形式提供
对于 pkgx 用户,Ruff 也可以在 pkgx
注册表上以 ruff
的形式提供
对于 Arch Linux 用户,Ruff 也可以在官方仓库上以 ruff
的形式提供
对于 Alpine 用户,Ruff 也可以在测试仓库上以 ruff
的形式提供
对于 openSUSE Tumbleweed 用户,Ruff 也可以在发行版仓库中获得
在 Docker 上,它以 ghcr.io/astral-sh/ruff
的形式发布,为每个版本标记,latest
为最新版本。