Skip to content

Use PEP639 license format internally.#2732

Open
freakboy3742 wants to merge 10 commits intobeeware:mainfrom
freakboy3742:pep639
Open

Use PEP639 license format internally.#2732
freakboy3742 wants to merge 10 commits intobeeware:mainfrom
freakboy3742:pep639

Conversation

@freakboy3742
Copy link
Member

@freakboy3742 freakboy3742 commented Mar 10, 2026

Switch to using PEP 639 license metadata internally.

  • Existing projects without a license declaration get a warning, a dummy licence file, and an SPDX license declaration of LicenseRef-UnknownLicense
  • Existing projects in pre-PEP621 license format have the value of license written to a dummy file, and a SPDX-compliant value of license derived from the contents of the existing license field. A value of LicenseRef-UnknownLicense is used if a license cannot be determined.
  • Existing projects in PEP621 license.text format are treated the same as pre-PEP621 license format
  • Existing projects in PEP621 license.file format have the location turned into license-files, and a license value guessed from the license text. A value of LicenseRef-UnknownLicense is used if a license cannot be determined.
  • Any value provided in license-files (before or after coercion to PEP 639) must exist.

If a dummy license file is needed, it is written into the build directory as build/license_file.<app name>.txt

As 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:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

license-files = ["LICENSE"]
""") from None

# license_files without a license expression is always an error
Copy link
Member

@mhsmith mhsmith Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this comment was meant to be at "Empty license-files list is always an error" below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@freakboy3742 freakboy3742 requested a review from mhsmith March 13, 2026 02:23
- `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`][].
Copy link
Member

@mhsmith mhsmith Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

Support PEP 639 license metadata

2 participants