From f62845d39f575a868591d93f568b788bff9bd5bd Mon Sep 17 00:00:00 2001 From: David C Ellis Date: Wed, 17 Jul 2024 12:50:32 +0100 Subject: [PATCH] Switch to setuptools-scm for version numbering --- .github/workflows/publish_to_testpypi.yml | 5 ++++- .gitignore | 3 +++ pyproject.toml | 8 ++++---- src/ducktools/classbuilder/__init__.py | 3 +-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish_to_testpypi.yml b/.github/workflows/publish_to_testpypi.yml index 4745d6f..788d8c2 100644 --- a/.github/workflows/publish_to_testpypi.yml +++ b/.github/workflows/publish_to_testpypi.yml @@ -1,6 +1,9 @@ name: Test Publish Package to TestPyPi -on: workflow_dispatch +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+*" jobs: build: diff --git a/.gitignore b/.gitignore index f9450bf..af3aed0 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,6 @@ hyperfine_testfiles/ .vscode/ __pycache__/ *.pyc + +# setuptools-scm generated version file +_version.py diff --git a/pyproject.toml b/pyproject.toml index 4725b98..e579afe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [build-system] requires = [ - "setuptools>=61.0", - "wheel" + "setuptools>=64", + "setuptools-scm>=8", ] build-backend = "setuptools.build_meta" @@ -29,8 +29,8 @@ license = {file = "LICENSE.md"} [tool.setuptools.packages.find] where = ["src"] -[tool.setuptools.dynamic] -version = {attr = "ducktools.classbuilder.__version__"} +[tool.setuptools_scm] +version_file = "src/ducktools/classbuilder/_version.py" [project.optional-dependencies] testing = ["pytest>=8.2", "pytest-cov", "mypy", "typing_extensions"] diff --git a/src/ducktools/classbuilder/__init__.py b/src/ducktools/classbuilder/__init__.py index ccefed7..d9cae82 100644 --- a/src/ducktools/classbuilder/__init__.py +++ b/src/ducktools/classbuilder/__init__.py @@ -33,8 +33,7 @@ import os from .annotations import get_ns_annotations, is_classvar - -__version__ = "v0.6.3" +from ._version import __version__ # Change this name if you make heavy modifications INTERNALS_DICT = "__classbuilder_internals__"