Skip to content

Derive the version from git instead of a hardcoded 0.1.0 - #1

Merged
rec3141 merged 1 commit into
mainfrom
version-from-git
Jul 31, 2026
Merged

Derive the version from git instead of a hardcoded 0.1.0#1
rec3141 merged 1 commit into
mainfrom
version-from-git

Conversation

@rec3141

@rec3141 rec3141 commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Why

version = "0.1.0" is hardcoded in pyproject.toml and has never moved, so every build
of this package reports the same version regardless of what is in it.

That matters because microscape-nf installs this with pip install git+https://…. A
363-sample dataset analysed on 2026-07-23 could not say which code produced it: the run
manifest recorded 0.1.0 and nothing else, and the container that ran it had since been
rebuilt. Three versions of the pipeline were in play with no way to tell them apart.

What this does

setuptools-scm derives the version from git describe. Between tags that yields
0.1.1.dev<n>+g<commit> — the version string carries the commit itself, so it identifies
the source even with no other metadata.

state version
at tag v0.1.0 0.1.0
n commits later 0.1.1.dev<n>+g<commit>

Tag releases deliberately (git tag -a v0.2.0 -m …); everything between tags increments
on its own.

Three details worth noting:

  • version_file generates _version.py at build time (gitignored) so __version__
    is real at runtime rather than reconstructed by the caller.
  • fallback_version because pip sometimes clones without tags — that should degrade
    to 0.0.0+unknown, not break the install.
  • __init__.py reads _version.py, falls back to importlib.metadata for editable
    checkouts, then to 0.0.0+unknown.

Verified

Wheel builds cleanly and _version.py ships inside it. The derived commit matches what
the running container's direct_url.json independently recorded — so the version string
and the install metadata now agree on the same commit, from two different mechanisms.

Companion change in microscape-nf (run-manifest branch) records both, plus the actual
version of every tool the pipeline runs.

version was pinned at "0.1.0" in pyproject.toml, so every build reported the same
version regardless of what was in it. microscape-nf installs this with
`pip install git+https://...`, so a pipeline run could not say which code it ran — a
363-sample dataset analysed in July recorded "0.1.0" and nothing else.

setuptools-scm derives it from git describe. Between tags that is
0.1.1.dev<n>+g<commit>, so the version string carries the commit itself. Tag releases
deliberately; everything in between increments on its own.

  version_file       generates _version.py at build time, gitignored, so __version__
                     is real at runtime rather than reconstructed
  fallback_version   pip sometimes clones without tags — fail soft, do not break install
  __init__           reads _version.py, falls back to importlib.metadata for editable
                     installs, then to 0.0.0+unknown

Verified: wheel builds to 0.1.1.dev9+g1bbad5a19, and that commit
matches what the container's direct_url.json independently recorded.
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