Skip to content

Commit 46a3938

Browse files
Fix pyproject.toml for templates without Python package directories
When templates have no Python package directory (include_python=no AND no jobs/pipelines, OR lakeflow_only=yes), hatch cannot automatically detect what to build. This causes 'uv run pytest' to fail with build errors: "Unable to determine which files to ship inside the wheel using the following heuristics: <https://hatch.pypa.io/latest/plugins/builder/wheel/#default-file-selection>" Add conditional [tool.hatch.build.targets.wheel] configuration with packages = ["src"] when $has_python_package_dir is false. This matches the same logic used in __preamble.tmpl to determine directory structure. The fix applies to: - default-minimal template (no sample code) - lakeflow-pipelines templates (SQL-only, no Python packages) This ensures 'uv run pytest' works correctly in all template variants. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f7fc738 commit 46a3938

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

acceptance/bundle/templates/default-minimal/output/my_default_minimal/pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies = [
88
# See also https://docs.databricks.com/dev-tools/bundles/library-dependencies
99
#
1010
# LIMITATION: for pipelines, dependencies are cached during development;
11-
# add dependencies to the 'environment' section of pipeline.yml file instead
11+
# add dependencies to the 'environment' section of your pipeline.yml file instead
1212
]
1313

1414
[dependency-groups]
@@ -25,5 +25,8 @@ main = "my_default_minimal.main:main"
2525
requires = ["hatchling"]
2626
build-backend = "hatchling.build"
2727

28+
[tool.hatch.build.targets.wheel]
29+
packages = ["src"]
30+
2831
[tool.black]
2932
line-length = 125

acceptance/bundle/templates/lakeflow-pipelines/python/output/my_lakeflow_pipelines/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ main = "my_lakeflow_pipelines.main:main"
2525
requires = ["hatchling"]
2626
build-backend = "hatchling.build"
2727

28+
[tool.hatch.build.targets.wheel]
29+
packages = ["src"]
30+
2831
[tool.black]
2932
line-length = 125

acceptance/bundle/templates/lakeflow-pipelines/sql/output/my_lakeflow_pipelines/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ main = "my_lakeflow_pipelines.main:main"
2525
requires = ["hatchling"]
2626
build-backend = "hatchling.build"
2727

28+
[tool.hatch.build.targets.wheel]
29+
packages = ["src"]
30+
2831
[tool.black]
2932
line-length = 125

libs/template/templates/default/template/{{.project_name}}/pyproject.toml.tmpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ main = "{{.project_name}}.main:main"
2727
[build-system]
2828
requires = ["hatchling"]
2929
build-backend = "hatchling.build"
30+
{{- $has_python_package_dir := and (or (eq .include_python "yes") (eq .include_job "yes") (eq .include_pipeline "yes")) (not (eq .lakeflow_only "yes")) }}
31+
{{- if not $has_python_package_dir }}
32+
{{- /* Hatch can normally automatically detect the package directory,
33+
* but requires an explicit setting when the package directory is empty.
34+
*/}}
35+
36+
[tool.hatch.build.targets.wheel]
37+
packages = ["src"]
38+
{{- end }}
3039

3140
[tool.black]
3241
line-length = 125

0 commit comments

Comments
 (0)