From 34d4ba146a6e146b426a086a037f40287936a4f1 Mon Sep 17 00:00:00 2001 From: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com> Date: Wed, 27 Mar 2024 19:23:19 -0400 Subject: [PATCH] [Maint] use setuptools_scm for versioning (#159) * use setuptools_scm for versioning * ensure checkout depth is correctly set * remove problematic [tool.setuptools.dynamic] --- .github/workflows/build_napari.yml | 3 +++ .github/workflows/deploy.yml | 2 ++ napari_sphinx_theme/__init__.py | 6 ++++-- pyproject.toml | 6 +++--- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_napari.yml b/.github/workflows/build_napari.yml index d09dd5f2..945f501b 100644 --- a/.github/workflows/build_napari.yml +++ b/.github/workflows/build_napari.yml @@ -17,6 +17,9 @@ jobs: steps: - name: Clone napari-sphinx-theme uses: actions/checkout@v4 + with: + # ensure version metadata is proper + fetch-depth: 0 - name: Clone napari docs repo uses: actions/checkout@v4 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3800e3d1..a01c0cb7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,6 +25,8 @@ jobs: python-version: [3.9] steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 diff --git a/napari_sphinx_theme/__init__.py b/napari_sphinx_theme/__init__.py index 38765cd0..b413e2c1 100644 --- a/napari_sphinx_theme/__init__.py +++ b/napari_sphinx_theme/__init__.py @@ -3,8 +3,10 @@ from .napari_code_theme import * -__version__ = "0.3.3.dev0" - +try: + from ._version import version as __version__ +except ImportError: + __version__ = 'not-installed' def update_templates(app, pagename, templatename, context, doctree): """Update template names for page build.""" diff --git a/pyproject.toml b/pyproject.toml index 29907ca4..80ee2453 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=61.0"] +requires = ["setuptools>=64", "setuptools_scm>=8"] build-backend = "setuptools.build_meta" [project] @@ -49,8 +49,8 @@ repository = "https://github.com/napari/napari-sphinx-theme" packages = ["napari_sphinx_theme"] zip-safe = false -[tool.setuptools.dynamic] -version = {attr = "napari_sphinx_theme.__version__"} +[tool.setuptools_scm] +version_file = "napari_sphinx_theme/_version.py" [tool.setuptools.package-data] napari_sphinx_theme = [