pyproject.toml checker · guide
Why license = "MIT License" breaks your Python build
For years license = { text = "MIT License" } and a License :: OSI Approved :: MIT License classifier were the normal way to say a Python package was MIT licensed. PEP 639 changed both. The license key now holds an SPDX license expression as a plain string, licence files are listed with license-files, and the table form and the licence classifiers are deprecated. Backends adopted it at different speeds, so the same file can build with one and fail with another.
What three backends did with the same project
We built one small project with each backend's own build hook, changing one thing at a time (setuptools 84.2.1, hatchling 1.33.0, flit_core 4.2.0, November 2026; the script is eval/backend_claims.py in the source and its output is eval/backend-claims.json). "Refuses" means the build stopped with an error; "warns, builds" means it printed a deprecation or warning and went on.
| In pyproject.toml | setuptools | hatchling | flit_core |
|---|---|---|---|
license = "MIT License" | refuses | refuses | refuses |
license = "MIT" plus a License :: classifier | refuses | builds | refuses |
license = { text = "MIT" } | warns, builds | builds | builds |
the table form plus license-files | refuses | builds | refuses |
a license-files pattern that matches nothing | warns, builds | builds | refuses |
homepage = "..." in [project] | refuses | builds | refuses |
[project.entry-points.console_scripts] | builds | refuses | refuses |
readme = { file = "README.md" } with no content-type | refuses | refuses | refuses |
| an author e-mail without a dot in the domain | refuses | builds | builds |
| an unknown classifier | refuses | refuses | builds |
requires-python = "^3.8" | refuses | refuses | builds |
Two things stand out. Of the 17 cases we tried, only an invalid licence string, an invalid version, a dynamic field also given statically and a readme table without a content type were refused by all three. And hatchling is the most forgiving: it built a file with an unknown [project] key, which means whatever that key was meant to say (often a homepage) silently never reaches the package.
The fix
[project] license = "MIT" # an SPDX identifier, not a name license-files = ["LICEN[CS]E*"] # glob patterns, relative to pyproject.toml # and no "License :: ..." classifiers
Combine licences with AND, OR and WITH (Apache-2.0 OR MIT, GPL-2.0-or-later WITH Classpath-exception-2.0). A licence with no SPDX identifier is LicenseRef- plus a name. Old GNU identifiers like GPL-3.0 still parse but are deprecated: say GPL-3.0-only or GPL-3.0-or-later.
The checker reads your file and reports each of these with its line, and names the backend that will refuse it; it also checks the rest of [project], your dependency strings and [build-system].
Questions
What does PEP 639 change in pyproject.toml?
The license key now takes an SPDX license expression as a plain string, such as MIT or Apache-2.0 OR MIT, and a new license-files key lists the licence files to ship as glob patterns. The old table form, license = { text = ... } or { file = ... }, is deprecated, and so are the License :: classifiers.
Why did my build start failing after a setuptools upgrade?
Recent setuptools validates license as an SPDX expression and refuses a License :: classifier next to one. A license string written as a name, like MIT License or BSD, or a classifier left in place after switching to license = "MIT", now stops the build with a configuration error.
What should I write instead?
license = "MIT" (or your SPDX identifier, such as Apache-2.0, BSD-3-Clause or GPL-3.0-or-later), license-files = ["LICEN[CS]E*"], and no License :: classifier. A licence with no SPDX identifier is written LicenseRef-YourName.
Do all backends behave the same?
No. We built the same small project with setuptools, hatchling and flit_core; the table above shows where they differ. hatchling accepts the classifier pair and an unknown [project] key that setuptools and flit_core refuse, and setuptools accepts console_scripts under entry-points, which the other two refuse.