Skip to content

Commit a09128c

Browse files
committed
switch to uv_build build backend
also use pyproject.toml as single source of truth for version since uv does not support dynamic attribute
1 parent b0ebef0 commit a09128c

2 files changed

Lines changed: 11 additions & 16 deletions

File tree

{{cookiecutter.project_slug}}/pyproject.toml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "{{ cookiecutter.project_slug }}"
3-
dynamic = ["version"]
3+
version = "{{ cookiecutter.version }}"
44
description = "{{ cookiecutter.project_description }}"
55
readme = "README.md"
66
license-files = ["LICENSE"]
@@ -23,20 +23,8 @@ dependencies = []
2323
requires-python = ">=3.9"
2424

2525
[build-system]
26-
requires = ["hatchling"]
27-
build-backend = "hatchling.build"
28-
29-
[tool.hatch.version]
30-
path = "{{ cookiecutter.__project_src_path }}/__init__.py"
31-
32-
[tool.hatch.build.targets.wheel]
33-
packages = ["{{ cookiecutter.__project_src_first }}"]
34-
35-
[tool.hatch.build.targets.sdist]
36-
exclude = ["/.github"]
37-
38-
[tool.setuptools.dynamic]
39-
version = { attr = "{{ cookiecutter.__project_import }}.__version__" }
26+
requires = ["uv_build>=0.8.14,<0.9.0"]
27+
build-backend = "uv_build"
4028

4129
[dependency-groups]
4230
doc = [
@@ -133,3 +121,8 @@ fail-under = 100
133121

134122
[tool.uv.sources]
135123
{{ cookiecutter.project_slug }} = { workspace = true }
124+
125+
{%- if cookiecutter.project_namespace_import %}
126+
[tool.uv.build-backend]
127+
module-name = "{{ cookiecutter.__project_import }}"
128+
{%- endif %}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
"""The `{{ cookiecutter.project_slug }}` APIs."""
22

3-
__version__ = "{{ cookiecutter.version }}"
3+
import importlib.metadata
4+
5+
__version__ = importlib.metadata.version("{{ cookiecutter.project_slug }}")

0 commit comments

Comments
 (0)