fix(build): pick PEP 440-compatible nbgv field, avoid trailing .height#454
Merged
Conversation
Released version was `2.0.13.4` instead of `2.0.13` because the hatch
plugin preferred nbgv's CloudBuildNumber field. On release branches with
a plain three-part version, nbgv appends git height as a 4th component
(`2.0.13.4`).
Switch the field priority to SemVer2 -> CloudBuildNumber -> SimpleVersion,
and walk past any field that isn't PEP 440-parseable. End result:
- release: SemVer2 picks `2.0.13`
- main: SemVer2 has +gHASH (not PEP 440) so falls through to
CloudBuildNumber `2.0.13-dev.11+eaec265930` (PEP 440-valid)
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Teams Hatch build plugin’s version selection logic so that release builds prefer an nbgv field that yields a PEP 440-compatible stable version (avoiding an unintended 4th “git height” component like 2.0.13.4 when 2.0.13 is intended).
Changes:
- Reorders nbgv field selection priority to prefer
SemVer2, thenCloudBuildNumber, thenSimpleVersion. - Adds a PEP 440 parse check to skip unparseable nbgv fields instead of blindly selecting the first populated one.
- Improves the failure message when no usable PEP 440 version is available in expected fields.
…ase segment, not +gHASH local)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
lilyydu
approved these changes
Jun 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the hatch build plugin so released package versions don't have a trailing
.heightcomponent (we just shipped2.0.13.4when we meant2.0.13).Why
I introduced this in PR #445 when migrating off the 3.12-only
nbgv-pythonwrapper. The plugin picked nbgv'sCloudBuildNumberfield, which works fine onmain(2.0.13-dev.11+eaec265930) but onreleaseit expands to2.0.13.4because nbgv appends git height as a 4th version component whenversion.jsonhas a plain three-part version. PyPI then gotmicrosoft-teams-apps==2.0.13.4instead of2.0.13.What changed
Field priority is now
SemVer2→CloudBuildNumber→SimpleVersion, with a PEP 440 validity check that walks past unparseable fields. End result:SemVer2is2.0.13(plain stable) — pickedSemVer2is2.0.13-dev.11.geaec265930(not PEP 440 due to trailing.gHASH) — falls through toCloudBuildNumber2.0.13-dev.11+eaec265930(PEP 440-valid via local-version+)Reviewer tips
Diff is small — just the field list + a try/except in
_select_version. The comment block explains the rationale so future folks don't reintroduce the bug.Testing
Verified both code paths locally:
Will be visible end-to-end on the next release (
2.0.14).