Python coverage 在 python 3.8 下的 Windows 上安装时没有 C 扩展名,但在 python 3.7 下没有安装,我如何强制使用 C 扩展名版本?

Python coverage is installing without C extension on Windows under python 3.8, but not under python 3.7, how do I force the C extension version?

我在同一台 windows 10 机器上安装了 python 3.7.5 和 Python 3.8。它们都是从 python.org/downloads 安装的。当我 运行 pip install coverage(使用最新版本的 pip)时,它会在 3.7.5 下安装带有 c 扩展的覆盖,而在 3.8.2 下不带 c 扩展。

我如何强制使用 c 扩展安装 coverage,因为没有它们性能很差?

出现3.7.5下载: https://files.pythonhosted.org/packages/4b/c7/6b1af1c8806fa047469b19861a3438f9ce785aa41c831c15d676ccaaa726/coverage-5.0.3-cp37-cp37m-win32.whl

其中 3.8.2 下载: coverage-5.0.3.tar.gz

后者是"without c extensions"

目前 Windows 和 Python 3.8 没有有效的 coverage 轮子。

5.0.3 wheels on PyPI 被标记为与 cp38-cp38m-win_amd64 兼容,因此 CPython 3.8,具有 cp38m ABI 变体,适用于 64 位 Windows .

但是,已经没有这样的 ABI 变体了。 Python 3.8 不再有 m (--with-pymalloc) 二进制变体,因为 builds with or without --with-pymalloc are now ABI compatible.

Pip 也效仿 stopped adding the m flag when looking for wheels, and the wheel project, which creates these distribution files also dropped the m flag

但是,coverage.py 使用的是 older release of wheel to build the distributions, they are using 0.33.1, while the above changes landed in version 0.33.5. You already filed a bug report with the project,我也在那里添加了我的发现。

幸运的是,旗帜是肤浅的。您可以直接从 PyPI 下载 wheel 文件,重命名 文件(从 cp38m 中删除 m)然后使用 pip install path/to/renamed/coverage-5.0.3-cp38-cp38m-win_amd64.whl.

注意:同样的问题也适用于 3.9 车轮。