Skip to content

Instantly share code, notes, and snippets.

@matthewdeanmartin
Created January 23, 2021 04:42
Show Gist options
  • Save matthewdeanmartin/53f979c313ee63598c93a76528febd1b to your computer and use it in GitHub Desktop.
Save matthewdeanmartin/53f979c313ee63598c93a76528febd1b to your computer and use it in GitHub Desktop.
This is one weird library
# So how to bump versions with this library if you refuse to
# use setup.py
# and don't want .dev123 junking up your version numbers
from setuptools_scm import get_version
from setuptools_scm.version import guess_next_version
# custom versioning to get rid of .devX logic
def version_scheme(version):
verstr = str(version.tag)
ver = verstr.split(".")
return "{}.{}.{}".format(ver[0],ver[1],int(ver[2])+1)
# this code now only finds most recent git tag & calls code I wrote to bump
v = get_version(
version_scheme=version_scheme,
local_scheme=lambda *args, **kwargs:"",
)
print(guess_next_version(v))
# run 1, bumps 0.1.0 -> 0.1.1
# run again, bumps to 0.1.3 (skips!)
# run again, errors out says 0.1.3 already exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment