← 返回首页
License Expression - Python Packaging User Guide Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode
Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Toggle site navigation sidebar
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar
Back to top
Toggle Light / Dark / Auto color theme
Toggle table of contents sidebar

License Expression

PEP 639 defined a new pyproject.toml’s license value and added a corresponding core metadata License-Expression field. This specification defines which license expressions are acceptable.

Specification

License can be defined as a text string that is a valid SPDX license expression, as documented in the SPDX specification, either Version 2.2 or a later compatible version.

A license expression can use the following license identifiers:

  • Any SPDX-listed license short-form identifiers that are published in the SPDX License List, version 3.17 or any later compatible version.

  • The custom LicenseRef-[idstring] string(s), where [idstring] is a unique string containing letters, numbers, . and/or -, to identify licenses that are not included in the SPDX license list. The custom identifiers must follow the SPDX specification, clause 10.1 of the given specification version.

Examples of valid license expressions:

MIT BSD-3-Clause MIT AND (Apache-2.0 OR BSD-2-Clause) MIT OR GPL-2.0-or-later OR (FSFUL AND BSD-2-Clause) GPL-3.0-only WITH Classpath-Exception-2.0 OR BSD-3-Clause LicenseRef-Special-License OR CC0-1.0 OR Unlicense LicenseRef-Proprietary

Examples of invalid license expressions:

Use-it-after-midnight # No `LicenseRef` prefix Apache-2.0 OR 2-BSD-Clause # 2-BSD-Clause is not a valid SPDX identifier LicenseRef-License with spaces # spaces are not allowed LicenseRef-License_with_underscores # underscore are not allowed
Made with Sphinx and @pradyunsg's Furo
Last updated on May 21, 2026