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

Proposal: Derive pkg version from git using setuptool_scm #92

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

aaraney
Copy link
Member

@aaraney aaraney commented Jan 17, 2024

Given that our packages are not published to a public registry (i.e. PyPI), anyone who uses these packages either installs using a github link via pip or by cloning the repo and installing from a local copy. When issues arise and user submit issues, a common first question is, "what version of the code are you using?" For worse, at this moment, we/users dont have a robust way of answering that question. As it sits, we hardcode the version of a package in a subpackage's _version.py file and call it a day. However, as we all know, this does not tell the the whole story unless we were to update _version.py with every commit to the repo (insanity). To remedy this, this PR introduces setuptool_scm, a build time tool that extracts information from git and adds version information to packages including a _version.py file, as a build time step to all of our packages. This works when installing from a git link, locally, and locally in edit mode.

How does it work? setuptool_scm uses git tags to determine versions. It searches for the latest git tag and creates a version string based on the tag. See the table of the default version scheme for more information.

Given that this repo is effectivity a monorepo, i've chosen to introduce a tagging convention that lets us track subpackage versions using tagging namespaces (i.e. ngen.<package-name>/v<x>.<y>.<z>). So for example, to cut a release of the ngen.config subpackage, just push an annotated tag like git tag --annotated "ngen.config/v0.2.5" --message "ngen.config v0.2.5"; git push upstream "ngen.config/v0.2.5".

To aide in the transition, ive created tags for all releases of all subpackages and pushed them to the repo. Even if we decide against this, this will be helpful.

related to NOAA-OWP/DMOD#476

Notes

  • Tags follow the following semantics: ngen.<package-name>/v<x>.<y>.<z>. Tags that do not follow this format will not be recognized and used by setuptools_scm to create the correct pkg version.

remove setup.cfg in favor of pyproject.toml files.
this consolidates metadata and allows us to use...
setuptools_scm to version all packages.
previously a namespace package would contain an _version.py file,
w/ __version__ = "x.y.z".
this was a little cumbersome, but worse, there was not a good way to
determine which version of the code someone was using.

setuptools_scm will now automatically create ._version using git tags
when the package is installed. additionally, if the installed package is
not from a specific tag, setuptools_scm will add metadata to the version
including the code's git hash and date of install. this in-theory will
vastly improve our ability to reproduce user submitted issues.

tags follow the following semantics: ngen.<package-name>/v<x>.<y>.<z>
tags that do not follow this format will not be recognized and used by
setuptools_scm to create the correct pkg version.
@aaraney
Copy link
Member Author

aaraney commented Jan 17, 2024

Looks like setuptools_scm does not have a >=8 version for 3.7. Ill look into if we can get around this tomorrow.

@aaraney
Copy link
Member Author

aaraney commented Jan 18, 2024

Moving this into draft. There are still a few things I need to sort out before this is ready for review.

@aaraney aaraney marked this pull request as draft January 18, 2024 22:24
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