Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(chore): Update version number inference in dev environments #1831

Merged
merged 8 commits into from
Jan 17, 2025

Conversation

flying-sheep
Copy link
Member

@flying-sheep flying-sheep commented Jan 17, 2025

this PR has two closely related bugfixes:

actually configure version inference correctly

Turns out I messed up in #1680 and put the config into the wrong section, disabling it. So this PR fixes that:

 [tool.hatch.version]
 ...
+raw-options.version_scheme = "release-branch-semver"
 [tool.hatch.build.hooks.vcs]
 ...
-raw-options.version_scheme = "release-branch-semver"

main branch before this PR:

hatch version
0.11.1.dev38+gfaec0f8

(this is wrong as it’s <0.11.3 which is already released)

main branch after this PR:

hatch version
0.12.0.dev40+gffbacdeahatch build
──── sdist ────
dist/anndata-0.12.0.dev40+gffbacdea.tar.gz
──── wheel ────
dist/anndata-0.12.0.dev40+gffbacdea-py3-none-any.whl

moving that config value to the tool.hatch.version table makes build time versions work as expected (e.g. pip install -e .../anndata in CI), but this PR also fixes a second problem:

make the runtime version use our config

We follow “hatch-vcs-footgun-example”, which updated: maresb/hatch-vcs-footgun-example#4

By using hatchling APIs instead of setuptools_vcs directly, we can make sure the config used by the runtime code is the same used at build time, i.e. in a dev environment, anndata.__version__ gets calculated in the same way as the version embedded in the metadata.

@flying-sheep flying-sheep added this to the 0.11.4 milestone Jan 17, 2025
@flying-sheep flying-sheep changed the title Update runtime version code (chore): Update version number inference in dev environments Jan 17, 2025
Copy link
Contributor

@ilan-gold ilan-gold left a comment

Choose a reason for hiding this comment

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

Works well now, and I think it's a bit cleaner that the example you linked to as well. As long as CI passes, should be good.

@flying-sheep
Copy link
Member Author

The example repo is intended to capture best practices around when you do that (i.e. you want to infer the version at runtime). I’ll send a PR that way to capture the plugin error like we do here.

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.69%. Comparing base (faec0f8) to head (abb10d0).
Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1831       +/-   ##
===========================================
+ Coverage   54.13%   83.69%   +29.56%     
===========================================
  Files          40       41        +1     
  Lines        6268     6268               
===========================================
+ Hits         3393     5246     +1853     
+ Misses       2875     1022     -1853     
Files with missing lines Coverage Δ
src/anndata/__init__.py 100.00% <100.00%> (+31.25%) ⬆️
src/anndata/_version.py 100.00% <100.00%> (ø)

... and 27 files with indirect coverage changes

@flying-sheep flying-sheep merged commit 7b8d873 into main Jan 17, 2025
5 of 13 checks passed
@flying-sheep flying-sheep deleted the pa/dev-version branch January 17, 2025 11:41
meeseeksmachine pushed a commit to meeseeksmachine/anndata that referenced this pull request Jan 17, 2025
flying-sheep added a commit that referenced this pull request Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants