## 事象
`uv publish` を実行すると以下のエラーになる。[[uv]]のバージョンは0.5.14。
```error
error: Failed to publish `dist/owlmixin-7.0.0-py3-none-any.whl` to https://upload.pypi.org/legacy/
Caused by: Upload failed with status code 400 Bad Request. Server says: 400 license-file introduced in metadata version 2.4, not 2.1. See https://packaging.python.org/specifications/core-metadata for more information.
```
[[pyproject.toml]]は以下。
```toml
[project]
authors = [
{name = "tadashi-aikawa", email = "
[email protected]"},
]
license = {text = "MIT"}
requires-python = "<4.0,>=3.9"
dependencies = [
"pyyaml<7.0,>=6.0",
]
name = "owlmixin"
version = "6.2.4"
description = "Mixin which converts ``data class instance`` and others each other more simple."
readme = "README.md"
keywords = [
"dict",
"json",
"yaml",
"parser",
"mixin",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities",
]
[project.urls]
homepage = "https://github.com/tadashi-aikawa/owlmixin"
repository = "https://github.com/tadashi-aikawa/owlmixin"
documentation = "https://tadashi-aikawa.github.io/owlmixin/"
[dependency-groups]
dev = [
"ruff<1.0.0,>=0.8.5",
"sphinx<8.0,>=7",
"pytest<8.0,>=7.2",
"mock<4.0,>=3.0",
"pytest-cov<5.0,>=4.0",
]
[tool.ruff.lint]
# import順を最適化
extend-select = ["I"]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
```
## 原因
[[uv]] 0.5.5 からライセンスファイルを使用するようになった。
<div class="link-card-v2">
<div class="link-card-v2-site">
<img class="link-card-v2-site-icon" src="https://github.githubassets.com/favicons/favicon.svg" />
<span class="link-card-v2-site-name">GitHub</span>
</div>
<div class="link-card-v2-title">
Uploads fail due to setuptools using wrong metadata version for license-file · Issue #9513 · astral-sh/uv
</div>
<div class="link-card-v2-content">
Dear all, I got this error when building and uploading my wheel with 0.5.5 to pypi.org.: Upload failed with stat ...
</div>
<img class="link-card-v2-image" src="https://opengraph.githubassets.com/3613f185cf9d3fdd541c50b7bac362927b3caa822e9552146b9da7b16375e1eb/astral-sh/uv/issues/9513" />
<a href="https://github.com/astral-sh/uv/issues/9513"></a>
</div>
[[setuptools]]の不具合によるものらしいとのこと。
<div class="link-card-v2">
<div class="link-card-v2-site">
<img class="link-card-v2-site-icon" src="https://github.githubassets.com/favicons/favicon.svg" />
<span class="link-card-v2-site-name">GitHub</span>
</div>
<div class="link-card-v2-title">
[BUG] `tool.setuptools.license-files` results in invalid metadata · Issue #4759 · pypa/setuptools
</div>
<div class="link-card-v2-content">
setuptools version setuptools==74.1.2 Python version Python 3.13 OS any Additional environment information No re ...
</div>
<img class="link-card-v2-image" src="https://opengraph.githubassets.com/f0ffe83fcb0f1f31620f5d4be04eeb24075ae55228c86f9d570b8d24fbaf7443/pypa/setuptools/issues/4759" />
<a href="https://github.com/pypa/setuptools/issues/4759"></a>
</div>
## 解決方法
今のところ、ちゃんとした解決策はなさそう。
## 回避策
[[pyproject.toml]]の`[build-system]`に[[Hatch]]を指定する。
```toml
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
```