Skip to main content
 首页 » 编程设计

python 轮 : same source code but different md5sum

2025年05月04日11pander-it

我们需要检查自制 python 包的 md5sum,实际上是从生成的 *.whl 文件中获取的。问题是 md5sum 在每次构建时都会发生变化,即使源代码没有变化。我们还在第三方包(即 django-celery)上对此进行了测试,并获得了相同的行为。

所以问题是:

  1. 如果我们不更改源代码,有什么不同?
  2. 是否可以为相同的 python 构建获得相同的 md5sum?

更新。

为了说明这个问题,我收到了关于两个 django-celery 构建的两份报告。 构建内容校验和完全相同(第 4 列),但 *.whl 文件本身的校验和不同。

报告链接:

https://www.dropbox.com/s/0kkbhwd2fgopg67/django_celery-3.1.17-py2-none-any2.htm?dl=0 https://www.dropbox.com/s/vecrq587jjrjh2r/django_celery-3.1.17-py2-none-any1.htm?dl=0

请您参考如下方法:

引用 the relevant PEP :

A wheel is a ZIP-format archive with a specially formatted file name and the .whl extension.

ZIP 存档保留每个文件的修改时间。

Wheel 文件不仅包含源代码,还包含 other files and directories在创建存档时即时生成。因此,即使您不接触 Python 源代码,轮子仍将包含具有不同修改时间的内容。


解决此问题的一种方法是解压缩轮子并计算内容的校验和。