【问题标题】:Python build always reinstall setuptoolsPython 构建总是重新安装 setuptools
【发布时间】:2021-10-29 20:49:24
【问题描述】:

我在 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 中的包,我认为我也不需要最新的包。谁能解释为什么会这样?

【问题讨论】:

  • build 为每个构建使用新的干净虚拟环境。为什么你认为你不需要最新的setuptools
  • 没有具体原因,就是觉得现有的包都还好。那么 build 每次都会在新的 venv 中安装最新的软件包是否正常?每次都这样做似乎有点重复。
  • 是的,这很正常。 build 这样做是为了确保一切都尽可能干净。

标签: python setuptools python-wheel


【解决方案1】:

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

默认情况下,构建会在隔离环境中构建包,但可以使用--no-isolation 禁用此行为。

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

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

【讨论】:

  • 谢谢!正是我想要的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-10-09
  • 1970-01-01
  • 1970-01-01
  • 2011-12-14
  • 2023-03-31
  • 2013-10-26
  • 1970-01-01
相关资源
最近更新 更多