Skip to content

fix: update macros.py to use setuptools_scm for dynamic versioning#20

Merged
eman merged 2 commits intomainfrom
fix/docs-setuptools-scm
Feb 22, 2026
Merged

fix: update macros.py to use setuptools_scm for dynamic versioning#20
eman merged 2 commits intomainfrom
fix/docs-setuptools-scm

Conversation

@eman
Copy link
Copy Markdown
Owner

@eman eman commented Feb 22, 2026

Problem

After migrating from bump2version to setuptools_scm (commit 23f44fd), project.version is no longer a static field in pyproject.toml (it uses dynamic = ["version"]). This broke the Docs CI build with:

ValueError: project.version must be defined in pyproject.toml

Fix

  • Update macros.py to call setuptools_scm.get_version() instead of reading from pyproject.toml
  • Add setuptools_scm>=8.0 to the docs optional dependencies so the CI pip install .[docs] step includes it

After migrating from bump2version to setuptools_scm, project.version is
no longer a static field in pyproject.toml. Use get_version() from
setuptools_scm instead, and add it to docs optional dependencies so the
CI docs build has access to it.
Copilot AI review requested due to automatic review settings February 22, 2026 00:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a broken documentation build by migrating the macros.py version detection from reading a static version field in pyproject.toml to using setuptools_scm.get_version(). This aligns with the project's recent migration from bump2version to setuptools_scm (commit 23f44fd), which changed the version to be dynamically determined from Git tags rather than statically defined.

Changes:

  • Updated macros.py to call setuptools_scm.get_version() instead of parsing pyproject.toml with tomllib
  • Added setuptools_scm>=8.0 to the docs optional dependencies to ensure it's available during documentation builds

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
macros.py Replaced tomllib-based version reading with setuptools_scm.get_version() call; simplified _load_version() function to accept root path and delegate to setuptools_scm
pyproject.toml Added setuptools_scm>=8.0 to docs optional dependencies to ensure CI has access to the versioning tool
Comments suppressed due to low confidence (1)

macros.py:11

  • The get_version() call can raise LookupError when the project is not in a Git repository or when Git metadata is unavailable (e.g., in a source tarball). This will cause the documentation build to fail in non-Git environments.

Consider adding error handling with a fallback value, similar to how src/alpha_hwr/__init__.py handles version lookup using importlib.metadata.version() with a try-except block that falls back to "0.0.0+unknown".

def _load_version(root: Path) -> str:
    """Return project version string using setuptools_scm."""
    return get_version(root=str(root))

macros.py is a MkDocs plugin file (not library source) and imports
setuptools_scm which is not installed in the type-check environment.
@eman eman merged commit 8fb919f into main Feb 22, 2026
6 checks passed
@eman eman deleted the fix/docs-setuptools-scm branch February 22, 2026 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants