Add hatchling build hook to build UI during package installation#565
Add hatchling build hook to build UI during package installation#565
Conversation
0bc3175 to
a8bda04
Compare
This allows installing dbt-mcp directly from GitHub via `uvx git+https://github.com/dbt-labs/dbt-mcp@main` by automatically building the UI assets during package build. Changes: - Add hatch_build.py with UIBuildHook that runs pnpm install/build - Configure the hook in pyproject.toml for both wheel and sdist targets - Include ui/ source files in sdist (excluding node_modules) - Remove manual UI build from Taskfile build task (hook handles it) - Fix pnpm-workspace.yaml to include packages field for pnpm v10 Closes #560
a8bda04 to
b0f4b16
Compare
| return | ||
|
|
||
| root = Path(self.root) | ||
| ui_dir = root / "ui" |
There was a problem hiding this comment.
Would it be better to keep this path the same as before, src/dbt_mcp/ui? The app expects that specific path, here.
| [tool.hatch.build.targets.wheel.hooks.custom] | ||
| path = "hatch_build.py" | ||
|
|
||
| [tool.hatch.build.targets.sdist.hooks.custom] | ||
| path = "hatch_build.py" |
There was a problem hiding this comment.
I've never worked w/ build hooks before so was generally curious about the behavior as well as the diff between sdist and wheel distributions.
I ran uv build -v locally and saw that the "pnpm install + pnpm build" step ran twice. Is this intended?
From my new understanding, the wheel dist is the built package that gets directly installed and used. The source dist is one step before that (has raw src files and no build assets) and is the basis for then building a wheel. So given this, is the hook on sdist necessary? Or would it make sense to just keep it on the wheel target?
Summary
Fixes #560
This PR adds a hatchling build hook that automatically builds the UI assets during package installation, enabling users to install dbt-mcp directly from GitHub:
Changes
hatch_build.pywithUIBuildHookthat runspnpm installandpnpm buildpyproject.tomlfor both wheel and sdist targetsui/source files in sdist (excludingnode_modules)buildtask (hook handles it now)pnpm-workspace.yamlto includepackagesfield required by pnpm v10Notes
pnpminstalled (as discussed in the issue, this is an acceptable tradeoff)pnpm/action-setupTest plan
uv buildworks and triggers the hooknode_modules