From 9ab093a3c77281bdab634838fc2b7148d7eac7bf Mon Sep 17 00:00:00 2001 From: Justin Gu <97915@qq.com> Date: Tue, 7 Jul 2026 20:50:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(build):=20hatchling=20artifacts=20=E8=AE=A9?= =?UTF-8?q?=20sdist=20=E4=B9=9F=E5=90=AB=20web-ui/dist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit python -m build 先构建 sdist 再从 sdist 构建 wheel。sdist 默认尊重 .gitignore 不含 web-ui/dist(构建产物),导致 wheel 阶段 force-include 找不到源报 FileNotFoundError。用 [tool.hatch.build] artifacts 强制 sdist 和 wheel 都包含 web-ui/dist。 本地验证:sdist 含 4 个 dist 文件,wheel 含 4 个 web/dist 文件。 --- pyproject.toml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1d9cab8..ca6e943 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,16 +21,18 @@ web = ["fastapi>=0.110,<1", "uvicorn[standard]>=0.29"] # 仅 PyInstaller 打包态需要,开发态 ``pip install -e .[web]`` 不强制装。 packaging = ["pystray>=0.19", "Pillow>=10.0"] +[tool.hatch.build] +# 前端 dist 是构建产物(在 .gitignore 里),hatchling 默认不打包。 +# artifacts 让它被 sdist 和 wheel 都强制包含。 +artifacts = [ + "web-ui/dist/", +] + [tool.hatch.build.targets.wheel] packages = ["src/easy_tdx"] -# 前端 dist 作为数据文件打进 wheel,让 PyPI 安装的用户也能开箱即用 web UI。 -# 前端必须先构建到 web-ui/dist/(release.yml / publish.yml 都会先 npm run build)。 -# 映射到包内 easy_tdx/web/dist/,运行时由 _resolve_web_dist_dir 第 4 级探测。 -artifacts = [ - "src/easy_tdx/web/dist", -] -[tool.hatch.build.targets.wheel.force-include] -"web-ui/dist" = "easy_tdx/web/dist" +# 前端 dist 映射到包内 easy_tdx/web/dist/,让 pip install 后开箱即用 UI。 +# 运行时由 _resolve_web_dist_dir 第 4 级探测找到。 +force-include = { "web-ui/dist" = "easy_tdx/web/dist" } [tool.mypy] strict = true