首页 > 编程语言 > 详细

通过脚本检测python的项目依赖包及版本

时间:2021-06-25 17:17:34      阅读:20      评论:0      收藏:0      [点我收藏+]
#!/bin/env/bash
#
find . -type f |grep py|xargs grep -E ‘^from|^import‘| awk -F "py:" {‘print $2‘}|sort|uniq>res0.log

sed -i ‘s/from/import/g‘ res0.log

cat res0.log |awk -F "import " {‘print $2‘}|awk -F ‘.‘ {‘print $1‘}> res1.log

sed -i "s/,[ ]*/\n/g" res1.log

sed -i “s/\s/\n/g" res1.log

cat res1.log|sort|uniq |while read line

do
    echo `pip list|grep $line` >> res2.log
done

awk NF res2.log > res3.log

sed -i ‘s/ (/==/g‘ res3.log

sed -i ‘s/)//g‘ res3.log

sed -i "s# #\n#g" res3.log

sort res3.log|uniq >requests.txt

rm /tmp/res* 

参考:https://www.cnblogs.com/nixiaocang/p/7502680.html

通过脚本检测python的项目依赖包及版本

原文:https://www.cnblogs.com/davis12/p/14930687.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!