Skip to content

Add license/ PyPI derivation package - #13

Merged
jonyoder merged 3 commits into
mainfrom
pypi-license-derivation
Jul 23, 2026
Merged

jonyoder merged 3 commits into
mainfrom
pypi-license-derivation

Conversation

@jonyoder

Copy link
Copy Markdown
Collaborator

Summary

Adds a new stdlib-only license/ package: PyPI license derivation seeded byte-for-byte from rstudio/package-manager's PyPI logic (getLicense/getLicenseTypes + the licenses package'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").
  • Plus the reusable primitives under their existing names: ParseSPDXExpression, GetLicensesFromPyPIClassifiers, StandardizeLicensePyPIClassifiers, LicenseUnknown, PyPILicense, and the embedded data/pypi_licenses.json (public PyPI Trove classifier → SPDX mapping).

Two intentional cleanups vs the PPM original (behavior-preserving for valid inputs): dropped a dead _ = i no-op; the embedded-JSON parse failure now fails fast (panic) instead of slog-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, and Names/Types golden vectors (including the two case-distinct sentinels and the Names vs Types classifier-handling difference). gofmt/vet clean.

@jonyoder
jonyoder merged commit bb0befc into main Jul 23, 2026
2 checks passed
@jonyoder
jonyoder deleted the pypi-license-derivation branch August 27, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant