Semantic versioning module enriched by hotfix version
Slowing down. Last release over 2 years ago, little activity since. Fine for existing code; think twice for a new project.
Consider insteadsemver
Semantic versioning module enriched by hotfix version
Slowing down. Last release over 2 years ago, little activity since. Fine for existing code; think twice for a new project.
Consider insteadsemver
pip install semver4A python module to deal with modified semantic versioning.
There are three numbers as main part of a version in semantic version (semver.org). Third number, patch, is defined as:
PATCH version when you make backward compatible bug fixes
However, sometimes we need to distinguish two types of a bugfix.
The first type is released in a standard release process and at the end the patch of a version is increased.
The second one is the case when we identified a bug which has to be fixed and released immidiately. In this case the version increased patch can potentially already exists as any sort of pre-release version.
Let's assume there is version 0.4.2 deployed in production. Versions 0.4.3-rc and 0.4.4-rc already exist in our non prod environment but they are not ready to be released. So, what should be the version of the hotfix? If we want to increase patch we would have to jump to 0.4.5 which may (and will) brings confusion in the versioning.
To solve to the scenario described above, we introduce 4th number to main version part. Let's call it fix version and define it as:
FIX version when you make hot fixes released immidiately
So the new version in the described scenario would be 0.4.2.1
At the end, the modification is only the one number.
Few samples how to use the module. There are tow classes:
from semver4 import Version
version = Version4('2.4.4.0-alpha+123')
print(version)
# '2.4.4-alpha+123'
version = Version4(major=2, minor=4, patch=4, prerelease='beta', build='12346')
print(version)
# '2.4.4-beta+12346'
print(version.minor, version.fix)
# 4 0
print(version.core)
# '2.4.4'
print(version > Version('0.4.2.4'))
# True
print(version == '2.4.4-beta+12346')
# True
print(version == 'blabla')
# raises NotComparableError
version.inc_fix()
print(version)
# '2.4.4.1'
print(version.fix)
# 1
version.prerelease = 'rc'
version.metadata = '987'
print(version)
# '2.4.4.1-rc+987'
print(version.core)
# '2.4.4.1'
version.inc_minor().inc_major().inc_patch()
print(version)
# '3.0.1'
# classic semver2.0 parser
v = SemVersion('1.2.3-alpha+007')
print(v)
# '1.2.3-alpha+007'
Both, Version4 and SemVersion objects now support json serialization and yaml serialization.
import json
import yaml
from semver4 import Version
from semver4.yaml import get_version4_dumper, get_version4_loader
data = {
'version': Version('1.2.3.4-beta')
}
dumped = json.dumps(data, default=Version.json_enc)
print(dumped)
# '{"version": "1.2.3.4-beta"}'
print(json.loads(dumped, object_hook=Version.json_dec))
# {"version": 1.2.3.4-beta}
dumped = yaml.dump(data, Dumper=get_version4_dumper())
print(dumped)
# version: 1.2.3.4-beta
print(yaml.load(dumped, Loader=get_version4_loader()))
# {'version': 1.2.3.4-beta}
The PyYAML module is not installed with the package because it is required by only one specific feature of the semver4 package which makes it redundant in most of use cases. This also the reason the dumper and the loader are placed in dedicated module.
Installation of PyYAML:
python3 -m pip install PyYAML
# or python or py or whatever alias you have set
# add --user for installation to the user dir
Use instead of semver4: tools that do the same job, closest first.
Compare with semver →Compare with semantic-version →Compare with version-parser →Compare all 4 →
Python helper for Semantic Versioning (https://semver.org)
Recent release
last release 979 days ago
Commit activity
0/26 weeks with commits
Release cadence
0 releases in 12 months
Issues & PRs handled
no data
Contributor spread
1 authors in last 100 commits
OpenSSF Scorecard
not evaluated
A library implementing the 'SemVer' scheme.
This package can parse and compare semantic versioning.
One version package to rule them all, One version package to find them, One version package to bring them all, and in the darkness bind them.
Parsing, inspecting and specifying versions.