-
Notifications
You must be signed in to change notification settings - Fork 21
Validate SPDX license expressions #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -378,7 +378,31 @@ def int(value: builtins.int) -> bool: | |
| return -(2**63) <= value < 2**63 | ||
|
|
||
|
|
||
| def SPDX(value: str) -> bool: | ||
| """Should validate eventually""" | ||
| # TODO: validate conditional to the presence of (the right version) of packaging | ||
| return True | ||
| try: | ||
| try: | ||
| from packaging import licenses as _licenses | ||
| except ImportError: # pragma: no cover | ||
| # let's try setuptools vendored version | ||
| from setuptools._vendor.packaging import ( # type: ignore[no-redef] | ||
| licenses as _licenses, | ||
| ) | ||
|
||
|
|
||
| def SPDX(value: str) -> bool: | ||
| """See :ref:`PyPA's license specifiers <pypa:#license>` | ||
cdce8p marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| (amended in :pep:`639`). | ||
| """ | ||
| try: | ||
| _licenses.canonicalize_license_expression(value) | ||
| return True | ||
| except _licenses.InvalidLicenseExpression: | ||
| return False | ||
|
|
||
| except ImportError: # pragma: no cover | ||
| _logger.warning( | ||
| "Could not find an installation of `packaging`. License expressions " | ||
| "might not be validated. " | ||
| "To enforce validation, please install `packaging`." | ||
cdce8p marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| def SPDX(value: str) -> bool: | ||
| return True | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| `project.license` must be valid exactly by one definition (0 matches found) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [project] | ||
| name = "example" | ||
| version = "1.2.3" | ||
| license = "Apache Software License" # should be "Apache-2.0" | ||
| license-files = ["licenses/LICENSE"] |
Uh oh!
There was an error while loading. Please reload this page.