Skip to content

Implement dynamic versioning with setuptools-scm#129

Merged
monodera merged 1 commit intomainfrom
u/monodera/versioning
Jan 9, 2026
Merged

Implement dynamic versioning with setuptools-scm#129
monodera merged 1 commit intomainfrom
u/monodera/versioning

Conversation

@monodera
Copy link
Contributor

@monodera monodera commented Jan 9, 2026

Summary

  • Replace manual version management with setuptools-scm for automatic version derivation from git tags
  • Development versions now include commit hash and date (e.g., 0.8.1.dev44+g8e7d5a28e.d20260109)
  • Remove need for manual version string updates in __init__.py

Changes

Configuration

  • pyproject.toml: Added setuptools-scm to build requirements and dev dependencies
  • pyproject.toml: Configured [tool.setuptools_scm] with version file generation and tag regex
  • pyproject.toml: Removed [tool.setuptools.dynamic] section (handled by setuptools-scm)

Code

  • src/targetdb/init.py: Import version from generated _version.py with fallback
  • .gitignore: Added src/targetdb/_version.py to ignore generated file
  • uv.lock: Updated with setuptools-scm dependencies

Version Format

  • On tagged release: 0.8.0 (clean version)
  • Development builds: 0.8.1.dev44+g8e7d5a28e.d20260109
    • Base version: 0.8.1 (next version after tag)
    • Dev commits: dev44 (44 commits since v0.8.0)
    • Commit hash: g8e7d5a28e
    • Build date: d20260109 (2026-01-09)

Future Release Workflow

# Create annotated tag
git tag -a v0.9.0 -m "Release 0.9.0"

# Push with tags
git push --follow-tags

# Build (version automatically set to 0.9.0)
uv run --with build python -m build

Test Plan

  • Version detected correctly: python -m setuptools_scm0.8.1.dev44+g8e7d5a28e.d20260109
  • Python import works: import targetdb; targetdb.__version__
  • Version file generated: src/targetdb/_version.py
  • Version file git-ignored
  • Package builds with correct version in metadata
  • Tag regex accepts both v.x.x.x and vx.x.x formats

🤖 Generated with Claude Code

Replace manual version management with setuptools-scm for automatic
version derivation from git tags. Development versions now include
commit hash and date for better traceability.

Changes:
- Add setuptools-scm to build requirements and dev dependencies
- Configure setuptools-scm to generate src/targetdb/_version.py
- Update __init__.py to import version from generated file with fallback
- Add _version.py to .gitignore
- Support both v.x.x.x and vx.x.x tag formats for backward compatibility

Version format: 0.8.1.dev44+g8e7d5a28e.d20260109
- Base version from git tag
- Dev info with commit count
- Git commit hash
- Build date

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@monodera monodera merged commit 26ce493 into main Jan 9, 2026
2 checks passed
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.

1 participant