Python build always reinstall setuptools

Python build always reinstall setuptools

我在 conda 中使用 Python 3.8,并使用 build 来创建包。虽然在我的 Conda 环境中我已经有了 setuptools 51.0 和 wheel 0.36,但每次我 运行 python -m build --wheel 我都会看到以下消息:

Found existing installation: setuptools 49.2.1
Uninstalling setuptools-49.2.1:
  Successfully uninstalled setuptools-49.2.1
Collecting wheel
  Using cached wheel-0.37.0-py2.py3-none-any.whl (35 kB)
Collecting setuptools>=51
  Using cached setuptools-58.3.0-py3-none-any.whl (946 kB)
Installing collected packages: wheel, setuptools
Successfully installed setuptools-58.3.0 wheel-0.37.0

这里现有的包甚至不匹配我在 Conda 中的包,我认为我也不需要最新的包。谁能解释为什么会这样?

参考这个话题https://pypa-build.readthedocs.io/en/latest/#python--m-build-optional-arguments

By default build will build the package in an isolated environment, but this behavior can be disabled with --no-isolation.

因此您可能需要添加 --no-isolation 标志以强制使用项目的虚拟环境,如下所示:

python -m build --wheel --no-isolation