raimon49/pip-licenses

Feature Request PEP 503 + PEP 691: License information from PyPi

開放

#30 建立於 2019年4月7日

 (6 則留言) (0 個反應) (0 位負責人)Python (58 個分叉)auto 404
enhancementhelp wantedpythonquestion

倉庫指標

星標
 (372 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

In using pip-licenses, I've found that some packages which do non-standard things with their license information are categorized as UNKNOWN even when they use mainstream OSS licenses.

PyPi exposes a /json endpoint that allows you to get a JSON representation of the metadata for a package.

One example I've seen is pytest-cache.

import requests

res = requests.get('https://pypi.org/pypi/pytest-cache/json').json()['info']
print(res)

license = res['license']

>>> res['license']
'MIT License'

Running this through the current pip-licenses setup yields UNKNOWN (running in non-Docker mode because I don't want to do the "only from trove classifiers" version)

echo "pytest-cache" > docker/requirements.txt
pip install pytest-cache
pip-licenses | grep pytest

 pytest                       3.6.3       MIT license
 pytest-cache                 1.0         UNKNOWN
 pytest-cov                   2.6.1       MIT

@raimon49 would you be open to a contribution that adds a method to get package metadata from PyPi? I would propose wrapping it in a try-catch that fails gracefully so we don't add a new restriction "must be connected to the internet to run pip-licenses".

If you are open to this idea, I'd like to try implementing and PR-ing in this feature.

Thanks for considering it!

貢獻者指南