Skip to content

Slightly revamp versioning #5

@pganssle

Description

@pganssle

Currently, the package's version is just the version of the IANA database, but presumably there will be things like rcs, post-releases and dev versions.

We should modify __init__.py such that the IANA zone is the building block of the version, and other components are added as desired. One way to do it would be like so:

IANA_VERSION = "2019c"

def __version__():

    pre = {
        # "a": None, # alpha
        # "b": None, # beta
        # "rc": None, # release candidate
    }

    assert len(pre) < 2, "Must specify at most one pre component

    post = None
    dev = None

    version = IANA_VERSION
    if pre:
        comp, num = pre.items()
        assert isinstance(num, int) and num >= 0, \
            "Pre component must be a non-negative integer"

        version += "%s%d" % (comp, num)

    if post is not None:
        assert isinstance(post, int) and post >= 0, \
            "Post version must be a non negative integer"

        version += ".post%d" % post

    if dev is not None:
        assert isinstance(dev, int) and dev >= 0, \
            "Dev version must be a non-negative integer"

        version += ".dev%d" % dev

    return version

__version__ == __version__()

Though I'm thinking this might be quite a bit of logic in the __init__.py that I don't love. Another possible mechanism would be to move the version declaration into a fixed file at the repo root, VERSION, then create a "bump_version" script (possibly using parver) that updates VERSION and re-generates the __init__.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions