Skip to content

Add git-based dynamic versioning with setuptools-scm#165

Merged
beckermr merged 5 commits intomainfrom
setup-dynamic-versioning
Feb 7, 2026
Merged

Add git-based dynamic versioning with setuptools-scm#165
beckermr merged 5 commits intomainfrom
setup-dynamic-versioning

Conversation

@EiffL
Copy link
Copy Markdown
Member

@EiffL EiffL commented Feb 7, 2026

Summary

  • Replace hardcoded version = "0.0.1rc1" with setuptools-scm, which derives versions automatically from git tags
  • Expose jax_galsim.__version__ at runtime via a generated _version.py
  • Update CI to fetch full git history (fetch-depth: 0) so setuptools-scm can resolve the version, and use submodules: recursive in the checkout step instead of a manual git submodule update

How it works

setuptools-scm reads git tags at build/install time:

  • At a tag like v0.0.1rc1 → version is 0.0.1rc1
  • N commits past a tag → version is 0.0.1rc1.devN+g<hash>
  • No tag found → falls back to 0.0.1rc1.dev0 (configured in pyproject.toml)

Action needed after merge

To anchor the versioning, a maintainer should create an initial SemVer tag on the merge commit:

git tag v0.0.1rc1
git push origin v0.0.1rc1

We recommend SemVer (MAJOR.MINOR.PATCH) over CalVer for this project because:

  • As a library, downstream code depends on the API — SemVer communicates compatibility (breaking vs non-breaking changes)
  • Scientific computing users need clear signals about whether an upgrade is safe
  • The 0.x.y convention explicitly signals "pre-stable, API may change"

Also, I don't think setuptools-scm works with CalVer

Replace the hardcoded version in pyproject.toml with setuptools-scm,
which derives versions automatically from git tags. This also exposes
`jax_galsim.__version__` at runtime and ensures CI fetches full git
history so setuptools-scm can resolve the version.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@EiffL EiffL linked an issue Feb 7, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Collaborator

@beckermr beckermr left a comment

Choose a reason for hiding this comment

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

This version string

0.0.1rc1.dev0

confuses me since "rc" means release candidate and the patch version is for patches.

Maybe we should adopt

0.1.0.dev0

as the fallback?

Comment thread jax_galsim/__init__.py Outdated
Comment thread .github/workflows/python_package.yaml
@beckermr
Copy link
Copy Markdown
Collaborator

beckermr commented Feb 7, 2026

Also, I don't think setuptools-scm works with CalVer

What do you mean by this?

@beckermr
Copy link
Copy Markdown
Collaborator

beckermr commented Feb 7, 2026

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Feb 7, 2026

Merging this PR will degrade performance by 30.63%

❌ 1 regressed benchmark
✅ 30 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
test_benchmark_spergel_calcfluxrad[run] 1 ms 1.5 ms -30.63%

Comparing setup-dynamic-versioning (d41c90d) with main (04d22c6)

Open in CodSpeed

EiffL and others added 2 commits February 7, 2026 13:42
Co-authored-by: Matthew R. Becker <beckermr@users.noreply.github.com>
@EiffL
Copy link
Copy Markdown
Member Author

EiffL commented Feb 7, 2026

Ok excellent, happy to use CalVer then. Not sure if we should tag the branch first, for after merging the code to main.

@beckermr
Copy link
Copy Markdown
Collaborator

beckermr commented Feb 7, 2026

No need to tag anything before or after merging. The existing tag for the oja paper may need adjusting. We can handle that later.

Once we switch the fallback version to 0.1.0.dev0, I think this is good to go.

EiffL and others added 2 commits February 7, 2026 14:05
Co-authored-by: Matthew R. Becker <beckermr@users.noreply.github.com>
@beckermr
Copy link
Copy Markdown
Collaborator

beckermr commented Feb 7, 2026

If we switch to calver we may want to change the default version. We can do that in a future PR.

@beckermr beckermr enabled auto-merge (squash) February 7, 2026 13:14
@beckermr beckermr merged commit 40845dd into main Feb 7, 2026
5 checks passed
@beckermr beckermr deleted the setup-dynamic-versioning branch February 7, 2026 13:47
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.

decide and implement versioning system

2 participants