Source-aware license resolution for uv projects: editables, private indexes, exact artifacts - #151
Open
joshuanapoli wants to merge 14 commits into
Open
Conversation
instead of guessing package names from configuration.
Resolve active editable paths to their local pyproject metadata and add them to the audited dependency set instead of dropping them. Preserve filtering for inactive sources and cover nested, workspace, mismatched directory, and spaced-path cases.
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.
Purpose of This Pull Request
Overview of Changes
This change gets the latest LicenseCheck to work with our monorepo. LicenseCheck was crashing because of the "pip-style editable entries".
It's also an attempt to tighten up our long list of "ignore_packages", by trying harder to understand the analyzed licenses and providing a more exact way to work around dependencies with incorrect or missing license metadata.
Audit editable and local path dependencies
LicenseCheck previously crashed when
uvemitted pip-style editable entries such as:Declares
requirements-parserdirectly (already present transitively viadepgather); uv emits pip-style requirements files whose-e <path>lines are not valid PEP 508 requirements. Passing them directly topackaging.RequirementraisedInvalidRequirement.This change:
pyproject.toml.[tool.uv.sources]paths and uv workspace members.Audit locked versions
uv.lockinstead of re-resolving the project.Support private indexes and exact artifact metadata
uv's configured indexes and credentials to retrieve private package wheels.METADATAwhen public PyPI is unavailable or omits usable license metadata.Partially addresses #95 and #128 by delegating package-index selection and authentication to uv.
Fixes #121 by reading the PEP 639
License-Expressionfield from local and downloaded artifact metadata.Fixes #150.
Make policy evaluation safer
package==versionentries inignore_packagesandfail_packages.pyproject.tomlrather than falling back to a less accurate parser.allowed_license_references/--allowed-license-referencesfor explicitly accepting exact rawLicenseRef-*identifiers without allowing the generic proprietary-license category. Package and license deny rules retain precedence.LicenseRef-*identifiers, and conservative aliases such asApache 2.0—over less-specific classifiers. Unrecognized legacy text continues to fall back to classifiers.WITHexpressions without assuming every parsed expression has a.keyattribute.This precedence handles packages that publish a specific license in
Licensealongside a generic or incorrect Trove classifier, including NVIDIA packages whoseLicenseRef-NVIDIA-ProprietaryorApache 2.0metadata was previously hidden byOther/Proprietary License.Fixes #137.
Audit reviewed metadata overrides
Projects can supply a reviewed license when an exact artifact publishes missing, ambiguous, or incorrect metadata:
name==version; ranges, wildcards, markers, extras, URLs, and unversioned names are rejected.licenseSource = "configured override".This provides a safer alternative to
ignore_packagesfor reviewed packages with defective upstream metadata, without guessing from license text or maintaining package-specific rules in LicenseCheck.License-matrix indexing fix
liceCompatindexedmatrix.csvbylist(License)position, but enum order and CSV order diverge forUPL_1/NCSA/PSFL; it now looks rows and columns up by name. Independent correctness fix, worth its own bullet.Subprocess hardening
stdin=DEVNULLplus timeouts on both uv calls, so a private-index credential prompt can't hang a worker thread forever; artifact-fetch and resolver-fallback failures now log.Performance
The SPDX licensing index is cached instead of rebuilt per license string, index discovery happens once per requirements file rather than once per requirement, and a duplicate
uv pip installon the artifact-failure path was removed.Testing
uv run pytest tests/test_packageinfo.py -q— 45 passeduv run pytest -q -k 'not ansi'— 124 passed, 3 deselected