funkelab / motile_toolbox

A toolbox for tracking with motile, including constructing candidate graphs and computing common features.
https://funkelab.github.io/motile_toolbox/
4 stars 1 forks source link

Dynamic version supplied by GitHub tags #12

Closed cmalinmayor closed 4 months ago

cmalinmayor commented 4 months ago

@tlambert03 I think I got the "dynamic" version tag in my pyproject.toml from your cookiecutter repo, but I see now that your cookie cutter uses hatch to provide the version from "vcs". Is there an equivalent for setuptools to provide the version from github? Should I just switch to hatch? I'll look into it myself as well, but I figured you might have an immediate idea 🙂 P.S. I did mess up the motile (main repo, not toolbox) releases a bit by not following the (very clear) instructions in the README about updating the __init__.py and making an annotated tag... so I wouldn't mind automating the versioning there as well 😆

tlambert03 commented 4 months ago

if you're using setuptools, then use setuptools_scm (which is what hatch-vcs uses under the hood anyway): https://github.com/pypa/setuptools_scm

[build-system]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"

[project]
dynamic = ["version"]

[tool.setuptools_scm]

Then don't forget to add it somewhere in your package, for example in __init__.py

from importlib.metadata import version, PackageNotFoundError

try:
    __version__ = version("motile-toolbox")
except PackageNotFoundError:
    # package is not installed
    __version__ = 'uninstalled'
tlambert03 commented 4 months ago

I wouldn't mind automating the versioning there as well 😆

yeah we left that manually done there to minimize the amount of tooling that I was piling onto Jan at the moment :joy: can add

cmalinmayor commented 4 months ago

Worked perfectly :) thank you!!