scriptharness.version module

Deal with the scriptharness version in semver format.

However, since writing this I’ve discovered that setuptools and sphinx don’t accept all semver formatted versions. It’s not clear if this will go away.

When called as a script, this will update ../version.json with the appropriate version info.



semver version - three integers and an optional string.



semver version in string format.


Translate a version tuple into a string.

Specify the __version__ as a tuple for more precise comparisons, and translate it to __version_string__ for when that’s needed.

This function exists primarily for easier unit testing.

Parameters:version (tuple) – three ints and an optional string.
Returns:version_string – the tuple translated into a string per
Return type:str
scriptharness.version.write_version(name=None, path=None)

Write the version info to ../version.json, for

  • name (Optional[str]) – this is for the write_version(name=__name__) below. That’s one way to both follow the if __name__ == '__main__': convention but also allow for full coverage without ignoring parts of the file.
  • path (Optional[str]) – the path to write the version json to. Defaults to ../version.json