From 7755085e6c5c4156ad56a4bc61b91e8eaf3ff677 Mon Sep 17 00:00:00 2001 From: Oliver Mannion <125105+tekumara@users.noreply.github.com> Date: Sat, 13 Jul 2024 19:35:43 +1000 Subject: [PATCH] feat: use setuptools_scm for versioning Use `setuptools_scm` to generate version numbers from git as per the [Default versioning scheme](https://github.com/pypa/setuptools_scm/blob/main/docs/usage.md#default-versioning-scheme). It provides a convenient way to align version numbers with tags, and as a bonus, we can generate `dev` versions from any commit, and not just tagged commits. When there is no git repo present (eg: inside a Docker container) fallback to version `0.0.0` --- {{cookiecutter.repo_name}}/pyproject.toml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.repo_name}}/pyproject.toml b/{{cookiecutter.repo_name}}/pyproject.toml index 04fd0c3..41482c7 100644 --- a/{{cookiecutter.repo_name}}/pyproject.toml +++ b/{{cookiecutter.repo_name}}/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "{{cookiecutter.project_name}}" description = "{{cookiecutter.description}}" -version = "0.0.0" +dynamic = ["version"] readme = "README.md" requires-python = ">=3.11" dependencies = [] @@ -16,11 +16,14 @@ dev = [ ] [build-system] -requires = ["setuptools~=69.1", "wheel~=0.42"] +requires = ["setuptools~=69.1", "setuptools_scm~=8.0", "wheel~=0.42"] [tool.setuptools.packages.find] where = ["."] exclude = ["tests*", "node_modules*", "build*"] +# enable setuptools_scm to set the version based on git tags +[tool.setuptools_scm] +fallback_version = "0.0.0" [tool.pyright] venvPath = "."