Python tox 依赖项安装输出

Python tox dependencies installation output

是否可以使用 tox 来避免在使用 pip 安装依赖项时将输出重定向到文件?我想看看正在安装什么,所以我想登录到标准输出而不是文件。

如果您想查看每个 运行 都安装了什么,使用 pip freeze 怎么样?您可以将它添加到 commands 部分,它将以需求格式转储已安装的包。

commands =
    pip freeze
    ... rest of your commands here.

我经常使用这种策略来做类似 python echo_versions.py 的事情,其中​​ echo_versions.py 是一个小脚本,显示我对每个 运行 感兴趣的软件包版本 - 只是以确保安装了预期的软件包。

我通过在 tox.ini 中添加更改 install_command 来解决,如下所示:

install_command = ./install_deps {opts} {packages}

其中 install_deps 是:

#!/bin/sh
# This script is used as `install_command` for `tox` in order to log to stdout
# the requirements that are being installed.

pip install $@ | tee /dev/tty