检查requirement.txt中的python包并报告问题
liccheck2的Python项目详细描述
python许可证检查器
检查requirement.txt中的python包并报告许可证问题。
关于
您可以定义授权许可证、授权包的列表, 未经授权的许可。
该工具将检查requirement.txt文件,检查包及其 依赖项,如果某些包不兼容,则返回错误 与战略背道而驰。当包的许可证被认为不符合 在未授权许可证列表中或未知。当一个包的 许可证在授权许可证列表中,或者如果包本身在 授权包裹。
如何安装
$ pip install liccheck
如何使用
liccheck将读取requirement.txt并根据ini文件中定义的策略检查包。 如果未在命令行中指定该文件,它将在当前文件夹中查找requirement.txt。 必须使用授权许可证列表、未授权许可证列表、授权包列表来设置ini文件。
下面是一个策略示例:
# Authorized and unauthorized licenses in LOWER CASE [Licenses] authorized_licenses: bsd new bsd bsd license new bsd license simplified bsd apache apache 2.0 apache software license gnu lgpl lgpl with exceptions or zpl isc license isc license (iscl) mit mit license python software foundation license zpl 2.1 unauthorized_licenses: gpl v3 [Authorized Packages] # Python software license (see http://zesty.ca/python/uuid.README.txt) uuid: 1.30
为了演示,假设您的requirement.txt文件包含以下内容:
Flask>=0.12.1 flask_restful jsonify psycopg2>=2.7.1 nose scipy scikit-learn pandas numpy argparse uuid sqlbuilder proboscis pyyaml>=3.12
执行将输出此消息:
$ liccheck -s my_strategy.ini -r my_project/required.txt gathering licenses...23 packages and dependencies. check forbidden packages based on licenses...none check authorized packages based on licenses...19 packages. check authorized packages...4 packages. check unknown licenses...none
如果某些依赖项未知或与策略不匹配,则输出如下:
$ liccheck -s my_strategy.ini -r my_project/required.txt gathering licenses...32 packages and dependencies. check forbidden packages based on licenses...1 forbidden packages : Unidecode (0.4.21) : GPL ['GNU General Public License v2 or later (GPLv2+)'] dependencye(s): Unidecode << python-slugify << yoyo-migrations check authorized packages based on licenses...24 packages. check authorized packages...6 packages. check unknown licenses...1 unknown packages : feedparser (5.2.1) : UNKNOWN [] dependencye(s): feedparser