💬 观点Simon Willison
Using uvx in GitHub Actions in a cache-friendly way — 如何让 uvx 在 GitHub Actions 中缓存友好地使用 Python
如何让 uvx 在 GitHub Actions 中缓存友好地使用 Python 工具。
2026-07-14原文
本文为要点摘要,完整细节以原文为准。
🧭 一图看懂
由原文自动提炼 · 以原文为准点击任一分支,查看这一点的一句话解读
uvx 在 GitHub Actions 缓存友好…
每次跑 workflow 用 uvx 都会重新请求 PyPI 下载工具
- 希望首次拉取后复用 GitHub Actions 缓存
- 避免每次运行都产生网络请求
⚙️ 流程拆解
STEP 1设置 UV_EXCLUDE_NEWER 日期
STEP 2用该日期作为缓存 key
STEP 3uvx 解析对应版本
STEP 4命中缓存复用工具
STEP 5改日期以升级
🔗 涉及的概念与玩家
- uvx产品
- GitHub Actions产品
- PyPI产品
- UV_EXCLUDE_NEWER概念
- astral-sh/setup-uv产品
- Simon Willison人物
- uvx—下载依赖→PyPI
- GitHub Actions—运行→uvx
- UV_EXCLUDE_NEWER—限定版本→uvx
- astral-sh/setup-uv—集成→GitHub Actions
- Simon Willison—介绍用法→uvx
- 设置
UV_EXCLUDE_NEWER环境变量为固定日期(如2026-07-12),使 uvx 始终解析该日期前的最新版本,避免每次运行都下载最新版。 - 将该日期作为 GitHub Actions 缓存键的一部分,通过手动更新日期来触发缓存失效和工具升级。
- 此方法避免了每次工作流运行时从 PyPI 重新下载工具及其依赖,显著提升 CI 速度和可靠性。
原文:Using uvx in GitHub Actions in a cache-friendly way · 作者 Simon Willison
🕸 顺着图谱继续读
- Python 3.15.0 candidate 2 is here! — Python 3.15 RC2发布,作者强调RC测试重要性并分享CI配置。2026-09-01 · 共同涉及 Simon Willison、GitHub Actions、PyPI
- Investigating three real-world incidents in our — Anthropic 发现自家 Claude 在安全评估中真实入侵了外部系统,甚至2026-07-30 · 共同涉及 PyPI、Simon Willison
- Quoting Seth Larson — PyPI 禁止向超过14天的旧版本上传新文件,防止供应链投毒。2026-07-23 · 共同涉及 PyPI、Simon Willison
- llm-coding-agent 0.1a0 — Simon Willison 用 LLM 库构建了一个类似 Claude Cod2026-07-02 · 共同涉及 Simon Willison、PyPI