uv pixi 镜像加速

uv

网上的都没用,在GITHUB[增强高速镜像下载]里找镜像源即可:

uv python install 3.13 -v --mirror https://gh.chjina.com/https://github.com/astral-sh/python-build-standalone/releases/download/

pixi

~/.config/pixi/config.toml

在设置该config.toml后,新建项目才会将pypi镜像加入到项目内的pyproject.toml/pixi.toml

# [concurrency]
# downloads = 12

[pypi-config]
extra-index-urls = [
  "https://pypi.tuna.tsinghua.edu.cn/simple",
  "https://pypi.org/simple",
]
index-url = "https://mirrors.aliyun.com/pypi/simple"
# can be "subprocess" or "disabled"
# keyring-provider = "subprocess"

[mirrors]
"https://conda.anaconda.org/bioconda" = [
  "https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda",
]
"https://conda.anaconda.org/conda-forge" = [
  "https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge",
]
"https://conda.anaconda.org/pytorch" = [
  "https://mirrors.ustc.edu.cn/anaconda/cloud/pytorch",
]
"https://repo.anaconda.com/pkgs/main" = [
  "https://mirrors.ustc.edu.cn/anaconda/pkgs/main",
]
"https://repo.anaconda.com/pkgs/msys2" = [
  "https://mirrors.ustc.edu.cn/anaconda/pkgs/msys2",
]
"https://repo.anaconda.com/pkgs/r" = [
  "https://mirrors.ustc.edu.cn/anaconda/pkgs/r",
]

项目内 pyproject.toml

[tool.pixi.pypi-options]
extra-index-urls = [
  "https://pypi.tuna.tsinghua.edu.cn/simple",
  "https://pypi.org/simple",
]
index-url = "https://mirrors.aliyun.com/pypi/simple"
#no-build-isolation = ["chumpy"]

全局包管理器

不想把系统自带的python环境搞坏,用uv .venv做全局环境,pixi做项目多环境:

uv python install 3.13
uv venv --python 3.13 ~/.venv/

然后在 ~/.zshrc 加入:

export UV_DEFAULT_INDEX="https://mirrors.aliyun.com/pypi/simple"
export UV_INDEX="https://pypi.tuna.tsinghua.edu.cn/simple https://pypi.org/simple"
export PATH="$HOME/.pixi/bin:$PATH"
. ~/.venv/bin/activate # source可简写为一个点

# zsh, default on macOS
fpath+=(~/.pixi/completions/zsh)
autoload -Uz compinit
compinit

~/.bashrc 的 pixi 见此: https://pixi.sh/dev/global_tools/introduction/#shell-completions

posted @ 2025-06-08 20:37  Nolca  阅读(828)  评论(0)    收藏  举报