Repository navigation
Add license/ PyPI derivation package - #13
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new stdlib-only
license/package: PyPI license derivation seeded byte-for-byte from rstudio/package-manager's PyPI logic (getLicense/getLicenseTypes+ thelicensespackage's PyPI path).Public API:
Names(expression string, classifiers []string, license string) []string— display names via the priority ladder (License-Expression → classifiers → freeform →"UNKNOWN").Types(expression string, classifiers []string) []string— SPDX-id set (License-Expression → classifiers→SPDX →"Unknown").ParseSPDXExpression,GetLicensesFromPyPIClassifiers,StandardizeLicensePyPIClassifiers,LicenseUnknown,PyPILicense, and the embeddeddata/pypi_licenses.json(public PyPI Trove classifier → SPDX mapping).Two intentional cleanups vs the PPM original (behavior-preserving for valid inputs): dropped a dead
_ = ino-op; the embedded-JSON parse failure now fails fast (panic) instead ofslog-and-continue.Why
The PyPI RSF producer (rstudio/pypi-manifest) needs to derive the same license value PPM computes, so a package's license can be filtered at list speed instead of via per-package lazy data. Sharing one implementation means producer and consumer can't diverge.
Context
Part of rstudio/package-manager epic #19133 (this is #19135). PPM's own migration to consume this package, plus a cross-parity CI test, are tracked separately (#19132). Licensing: new files carry
SPDX-License-Identifier: Apache-2.0 OR MIT; a NOTICE entry attributes the provenance.Tests
go test ./license/— SPDX-expression parsing, classifier standardization, andNames/Typesgolden vectors (including the two case-distinct sentinels and theNamesvsTypesclassifier-handling difference). gofmt/vet clean.