Use PEP639 license format internally.#2732
Use PEP639 license format internally.#2732freakboy3742 wants to merge 10 commits intobeeware:mainfrom
Conversation
src/briefcase/config.py
Outdated
| license-files = ["LICENSE"] | ||
| """) from None | ||
|
|
||
| # license_files without a license expression is always an error |
There was a problem hiding this comment.
This contradicts the spec, which says:
If the license-files key is present and is set to a value of an empty array, then tools MUST NOT include any license files and MUST NOT raise an error. If the license-files key is not defined, tools can decide how to handle license files. For example they can choose not to include any files or use their own logic to discover the appropriate files in the distribution.
There was a problem hiding this comment.
Sorry, this comment was meant to be at "Empty license-files list is always an error" below.
There was a problem hiding this comment.
Huh - that's... inconvenient.
This is problematic because Linux and Windows projects both require the existence of a file.
Since license appears to be a required field, I'll modified the code to allow an empty/absent license-files definition, but use dummy "Released under the terms of the {license} license" text with a warning that the user probably wants to provide an actual license.
There was a problem hiding this comment.
On reflection, I think the better approach is to avoid dummy files wherever possible.
Since an empty or absent license-files list is legal, I've taken the approach of always normalising license-files to a list - even if it's an empty list, and only populating a file if a "text-like" license value contains more than one line (i.e., trying to capture the license.text = """<actual license text>""" case), and raising warnings about the likely migration path. However, if there isn't any content that could be plausibly considered a "full" license, we don't write a file, and we use license-files = [].
Then, when the licenses are actually used, we raise an error if the packaging format requires a license, but one hasn't been provided. That means we can create an iOS/Android/macOS project without any license files; but Windows and Linux will both raise an error (because they have a hard requirement during packaging).
| - `dependencies` maps to the Briefcase [`requires`][] setting. This is a cumulative setting; any packages defined in the [`requires`][] setting at the `[tool.briefcase]` level will be appended to the packages defined with `dependencies` at the `[project]` level. | ||
| - `description` maps to the same key in Briefcase. | ||
| - `test` in an `[project.optional-dependencies]` section maps to [`test_requires`][]., As with `dependencies`/[`requires`][], this is a cumulative setting. | ||
| - `text` in a `[project.license]` section will be mapped to [`license`][]. |
There was a problem hiding this comment.
license and license_files should still be included here. Maybe we could say "The following [project] keys have the same format as in [tool.briefcase]", and then list them along with version and description.
And we shouldn't be referring to PEP 621 here, because we don't want to encourage people to look at an outdated PEP and get confused by the different license format. Suggest renaming the section to "[project] section" or similar, and then referring to "[project] metadata" elsewhere, with the square brackets making it clear that we're not referring to the tool.briefcase section.
Switch to using PEP 639 license metadata internally.
LicenseRef-UnknownLicenselicenseformat have the value oflicensewritten to a dummy file, and a SPDX-compliant value oflicensederived from the contents of the existinglicensefield. A value ofLicenseRef-UnknownLicenseis used if a license cannot be determined.license.textformat are treated the same as pre-PEP621licenseformatlicense.fileformat have the location turned intolicense-files, and alicensevalue guessed from the license text. A value ofLicenseRef-UnknownLicenseis used if a license cannot be determined.license-files(before or after coercion to PEP 639) must exist.If a dummy license file is needed, it is written into the
builddirectory asbuild/license_file.<app name>.txtAs a result of the config parsing changes, we can now assume that full license files are always available when building an app. This significantly simplifies the app builds.
Disclosure: This PR was generated with the use of SpecKit and Claude Sonnet 4.6, but has had substantial manual modifications.
Fixes #2146.
Refs beeware/briefcase-template#249 which makes the PEP639 change to the default app template.
PR Checklist: