uv,Rust编写的Python包、项目管理工具

安装

Install uv with our standalone installers:

1
2
# On macOS and Linux.
curl -LsSf https://astral.sh/uv/install.sh | sh
1
2
# On Windows.
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Or, from PyPI:

1
2
# With pip.
pip install uv
1
2
# Or pipx.
pipx install uv

If installed via the standalone installer, uv can update itself to the latest version:

1
uv self update

使用

初始化项目

1
uv init

创建虚拟环境

1
uv venv

小提示

UV_DEFAULT_INDEX(替代UV_INDEX_URL):设置PyPI源(默认的 python 第三方包来源地址),可以用来加快 python 第三方包的下载速度

比如清华源:

1
https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/

也可以通过设置 pyporject.toml 或者 uv.toml来指定项目级别的第三方包下载地址,设置方法:

pyproejct.toml

1
2
3
[[tool.uv.index]]
url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/"
default = true

uv.toml

1
2
3
[[index]]
url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/"
default = true

uv.toml的优先级比pyproject.toml

详细请参考:configuration

附录

中文文档:https://hellowac.github.io/uv-zh-cn/

网站总访客数:Loading
网站总访问量:Loading
使用 Hugo 构建
主题 StackJimmy 设计
-->