Ale*_*ros 3 python pip pip-tools
我正在尝试使用 pip-tools 来管理 venv(如python -m venv .venv)环境。新激活的环境最初只有 pip-tools:
> pip list
Package   Version
--------- -------
Click     7.0
pip       19.3.1
pip-tools 4.2.0
six       1.13.0
我创建了一个requirements/main.in文件:
numpy
matplotlib
跑步pip-compile --upgrade --build-isolation --generate-hashes --output-file requirements/main.txt requirements/main.in给了我这个警告:
# WARNING: The following packages were not pinned, but pip requires them to be
# pinned when the requirements file includes hashes. Consider using the --allow-unsafe flag.
# setuptools==41.6.0        # via kiwisolver
The generated requirements file may be rejected by pip install. See # WARNING lines for details.
如警告,pip install --upgrade -r requirements/main.txt拒绝操作:
ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
    setuptools from https://files.pythonhosted.org/packages/d9/de/554b6310ac87c5b921bc45634b07b11394fe63bc4cb5176f5240addf18ab/setuptools-41.6.0-py2.py3-none-any.whl#sha256=3e8e8505e563631e7cb110d9ad82d135ee866b8146d5efe06e42be07a72db20a (from kiwisolver==1.1.0->-r requirements/main.txt (line 11)) 
所以现在我的困境是:我应该使用--allow-unsafe吗?这样做有什么影响?我试了一下,发现生成的需求文件已经固定到那个特定的版本,哪个kiwisolver(我猜是 numpy/matplotlib 的传递依赖)需要对吗?但为什么这是不安全的?
如果我理解正确,我可以根据需要保留生成的需求,但是 - 每当我决定更新时 - 我可以重新运行 pip-compile 并创建一个新的需求文件将是新鲜的,它可能有一个新的 kiwisolver 没有这个限制,对吧?
pip-tools 要求我做出这个决定的原因是什么?为什么这可能是不安全的,有哪些示例不想使用 --allow-unsafe?
一个相关的问题是:我可以仅为 setuptools 指定“--allow-unsafe”吗?它似乎是 pip-compile 的一个参数,它是一种全有或全无的方法。我可以将特定的标记为“可以固定”吗?如果出现其他情况,我想再次收到警告,以便我可以评估这是否可以?
所以现在我的困境是:我应该使用
--allow-unsafe吗?这样做有什么影响?
是的你应该。这个选项允许你在引脚requirements.txt以下软件包:distribute,pip,和setuptools。如果你不在乎,那就继续吧!
但为什么这是不安全的?
AFAIK,由于以下原因,这些包可能被认为是不安全的:
setuptools可能会导致与pip(
distribute的旧包装器发生冲突,setuptools自 2013 年起已弃用)。pip可能会破坏pip-tools自身或您的系统pip。该--allow-unsafe选项很可能会在不久的将来被弃用,请参阅pip-tools和pip 的问题跟踪器中的讨论。