From c24fdf38a3ab9efbbcf15c7de6e3637938161ec4 Mon Sep 17 00:00:00 2001 From: KiriAky 107 Date: Sun, 13 Sep 2026 11:29:48 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E6=8C=89=E9=94=81=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=9B=BD=E5=86=85=20Python=20=E9=95=9C?= =?UTF-8?q?=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci.yml | 6 ++++++ scripts/prepare-ci-uv-mirror.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 scripts/prepare-ci-uv-mirror.py diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 543ddd9..d491dfb 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -26,6 +26,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: 切换 Python 锁文件下载源 + run: python3 scripts/prepare-ci-uv-mirror.py - name: 安装 Rust 工具链 run: | curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal @@ -46,6 +48,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: 切换 Python 锁文件下载源 + run: python3 scripts/prepare-ci-uv-mirror.py - run: corepack enable && corepack prepare pnpm@10.28.0 --activate - run: pnpm install --frozen-lockfile && pnpm build working-directory: server sync/console @@ -76,6 +80,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: 切换 Python 锁文件下载源 + run: python3 scripts/prepare-ci-uv-mirror.py - name: 安装 Rust 工具链 run: | curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal --component rustfmt,clippy diff --git a/scripts/prepare-ci-uv-mirror.py b/scripts/prepare-ci-uv-mirror.py new file mode 100644 index 0000000..32c7997 --- /dev/null +++ b/scripts/prepare-ci-uv-mirror.py @@ -0,0 +1,28 @@ +from pathlib import Path + + +LOCK_FILES = ( + Path("backend/uv.lock"), + Path("server sync/uv.lock"), + Path("community-server/uv.lock"), +) + +REPLACEMENTS = { + "https://pypi.org/simple": "https://mirrors.aliyun.com/pypi/simple", + "https://files.pythonhosted.org/packages/": "https://mirrors.aliyun.com/pypi/packages/", +} + + +def main() -> None: + for path in LOCK_FILES: + if not path.is_file(): + continue + content = path.read_text(encoding="utf-8") + for source, mirror in REPLACEMENTS.items(): + content = content.replace(source, mirror) + path.write_text(content, encoding="utf-8", newline="\n") + print(f"已切换锁文件下载源:{path}") + + +if __name__ == "__main__": + main()