Skip to main content

pypi-mirror-check

检查某个 PyPI 包 / 版本是否已同步到全球镜像;也能顺手列出各镜像站当前的最新版本。 纯标准库、零依赖,适合放进发版流水线里卡「PyPI 有了但镜像还没跟上」。

pipx run pypi-mirror-check hubrelay 0.9.5
# 或
pip install pypi-mirror-check
pypi-mirror-check hubrelay

用法

pypi-mirror-check <package> [version] [options]
参数 说明
version 省略 以官方最新版作为目标版本
--wait --interval 30 --timeout 900 发版后轮询,直到全部镜像同步或超时
--json 机读输出(含每个镜像的 latest / version_count)
--all-versions 列出各镜像上的全部版本(查各站版本号)
--only tuna,aliyun 只查指定镜像(key 见 --list-mirrors)
--require-hash 镜像页没给 sha256 也算未同步
--config FILE 自定义镜像清单(默认读包内 mirrors.json;也可用环境变量 PYPI_MIRROR_CHECK_CONFIG)
--mirror KEY=LABEL=URL 临时追加/覆盖一个镜像(可重复,URL 需含 {name})
--official URL 覆盖官方 JSON 基址
--list-mirrors 打印当前配置来源与镜像表
--version 打印版本(从 pyproject / 包元数据探测)

输出

包 hubrelay · 目标 0.9.5 · 期望 2 个文件
镜像            站点最新  状态    延迟     备注
PyPI 官方       0.9.5     已同步  312ms
清华 TUNA       0.9.5     已同步  180ms
阿里云          0.9.3     缺失    -       缺 hubrelay-0.9.5.tar.gz, hubrelay-0.9.5-py3-none-any.whl

判定逻辑

不看「有没有这个版本号」就完事,而是比对文件名 + sha256:

  • 目标版本的每个文件都必须在该镜像的 simple 页出现;
  • 页面里带 #sha256= 时逐个比对(截断/换源会被抓出来);
  • 镜像不给 hash 时退化为「文件名存在」,除非 --require-hash。
  • 镜像返回 404 时再探一次根索引:根索引可达 → 判「无此包」(missing); 根索引也失败 → 判「镜像不可用 / 路径不对」(error),不会把坏源误报成包缺失。

站点最新 是从 simple 页的文件名里解析出的最大版本(支持 a/b/rc/post/dev 排序)。

镜像配置(不写死在代码里)

默认读包内 mirrors.json,格式:

{
  "official_json": "https://pypi.org/pypi",
  "mirrors": [
    { "key": "pypi", "label": "PyPI 官方", "simple": "https://pypi.org/simple/{name}/" },
    { "key": "tuna", "label": "清华 TUNA", "simple": "https://pypi.tuna.tsinghua.edu.cn/simple/{name}/" }
  ]
}

想加内网/自建源,复制一份改 JSON,用 --config 指过去即可,无需改代码。

退出码

码 含义
0 所有镜像都已同步
1 有镜像缺失 / 不完整 / sha256 不一致
2 参数错误,或官方源不可用
3 --wait 超时仍有镜像未同步

CI 用法

- run: pipx run pypi-mirror-check "${{ env.PKG }}" "${{ env.VER }}" --wait --timeout 600

English

pypi-mirror-check checks whether a given PyPI package/version has propagated to global mirrors, and shows each mirror's current latest version. Stdlib-only.

It compares filenames + sha256 (not just "version exists"), supports --wait polling for post-release sync, --json, --all-versions, and a config-file mirror list (--config / PYPI_MIRROR_CHECK_CONFIG) so mirrors are data, not code.

Exit codes: 0 all synced · 1 missing/mismatched · 2 bad args or official unreachable · 3 --wait timeout.

License

MIT

Metadata

Release files for pypi-mirror-check 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pypi-mirror-check 0.1.3
File Size Uploaded Provenance Actions
pypi_mirror_check-0.1.3.tar.gz 18.6 kB Without provenance Details for pypi_mirror_check-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pypi-mirror-check 0.1.3
File Interpreter ABI Platform Actions
pypi_mirror_check-0.1.3-py3-none-any.whl Python 3 none any Details for pypi_mirror_check-0.1.3-py3-none-any.whl

Total release size: 33.2 kB

Release files / pypi_mirror_check-0.1.3.tar.gz

Download URL pypi_mirror_check-0.1.3.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1fdf7458a01476339779be1fa611b158cdfe1e1d169c27dda4c1ace15a0ebc9e
BLAKE2b-256 checksum
How to use checksums
ecd69a9b5b831982d0027fb43d5d7be4af66c092283e6db46cf311d05bebc162
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / pypi_mirror_check-0.1.3-py3-none-any.whl

Download URL pypi_mirror_check-0.1.3-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a6079e409a0486062a3162ec2ae672f2ff2c03fdb7ba6749c524eebe8f9f7a1
BLAKE2b-256 checksum
How to use checksums
105a0cc609d60c22778da7017fafe3c5eb4a0d3e12f1597bc829abaaded592fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for pypi-mirror-check 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page