运行pip install -r requirements.txt
时,有什么方便的方法可以打印每个包所花费的时间吗?
我想要pip install -r requirement.txt --print-times
之类的而不是仅仅打印包的名称和版本,我希望输出看起来像这样:
Collecting shellescape==3.8.1
Using cached shellescape-3.8.1-py2.py3-none-any.whl (3.1 kB)
took 2.4 seconds
Collecting lxml==4.5.2
Using cached lxml-4.5.2-cp38-cp38-manylinux1_x86_64.whl (5.4 MB)
Collecting gevent==20.9.0
Using cached gevent-20.9.0-cp38-cp38-manylinux2010_x86_64.whl (6.1
took 4.4 seconds
等等。。。
我没有在--verbose下找到这些数据。
谢谢!
编辑:我知道写bash/python脚本之类的选项,但我正在寻找一个简单的标志或单行命令。
创建一个包含以下内容的bash脚本
while IFS= read -r line; do
start=`date +%s`
pip install $line
end=`date +%s`
runtime=$((end-start))
echo "took $runtime seconds"
done < requirements.txt
我有一个建议给你,你可以使用python程序:
- 打开requirement.txt(
f = open('requirement.txt', 'r')
( - 读取文件(
doc = f.readlines()
( - 在for循环中,取每一行
- 初始化计时器(
t0 = time.time()
( - 使用python中的pip包运行pip-install
- 显示嘟嘟声的时间(
time.time() - t0
( - 使用别名替换在pip安装之前运行此脚本