Skip to content

Commit

Permalink
Fall back to parse info.license in registryData for pypi packages
Browse files Browse the repository at this point in the history
In addition to info.classifier entries in the registry data used to
extract license information, there is also info.license in the registry data.
This can also provide license information when there is no license
information in the classifiers.

Tese cases:
pypi/pypi/-/dnspython/1.11.0
pypi/pypi/-/pytorch-ignite/0.5.0.dev20220727
pypi/pypi/-/mitmproxy-wireguard/0.1.10
  • Loading branch information
qtomlinson committed Apr 11, 2023
1 parent fd5e9cd commit 08bcf82
Show file tree
Hide file tree
Showing 3 changed files with 669 additions and 2 deletions.
9 changes: 8 additions & 1 deletion providers/fetch/pypiFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PyPiFetch extends AbstractFetch {
return release.upload_time
}

_extractDeclaredLicense(registryData) {
_extractLicenseFromClassifiers(registryData) {
const classifiers = get(registryData, 'info.classifiers')
if (!classifiers) return null
for (const classifier in classifiers) {
Expand All @@ -86,6 +86,13 @@ class PyPiFetch extends AbstractFetch {
return null
}

_extractDeclaredLicense(registryData) {
const licenseFromClassifiers = this._extractLicenseFromClassifiers(registryData)
if (licenseFromClassifiers) return licenseFromClassifiers
const license = get(registryData, 'info.license')
return license && spdxCorrect(license)
}

async _getPackage(spec, registryData, destination) {
const releaseTypes = get(registryData, ['releases', spec.revision])
const release = find(releaseTypes, entry => entry.url?.endsWith('tar.gz') || entry.url?.endsWith('zip'))
Expand Down

0 comments on commit 08bcf82

Please sign in to comment.