semver4


Namesemver4 JSON
Version 0.0.1b8 PyPI version JSON
download
home_pagehttps://github.com/martin356/python-semver4
SummarySemantic versioning module enriched by hotfix version
upload_time2024-03-24 20:10:20
maintainerNone
docs_urlNone
authorMartin Mudroch
requires_python>=3.8
licenseMIT
keywords version versioning semantic semver
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## Overview
A python module to deal with modified semantic versioning.

### Motivation
There are three numbers as main part of a version in semantic version ([semver.org](https://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.
1. bugfix which is released in a standard way
1. bugfix which has to be release immidiately as hotfix

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.
<br>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.

### Fix version part
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.

## Usage
Few samples how to use the module. There are tow classes:
- *Version4*: this class parses a version which includes the fix part as described above
- *SemVersion*: classis semver2.0 version parser

```python
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.

```python
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](https://pypi.org/project/PyYAML) 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:
```bash
python3 -m pip install PyYAML
# or python or py or whatever alias you have set
# add --user for installation to the user dir
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/martin356/python-semver4",
    "name": "semver4",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "version, versioning, semantic, semver",
    "author": "Martin Mudroch",
    "author_email": "martin.mudroch@proton.me",
    "download_url": "https://files.pythonhosted.org/packages/7e/ef/d7d21dbe836be00505d7fe0aa00e4a761363b0b01f7fa7b8471867842756/semver4-0.0.1b8.tar.gz",
    "platform": null,
    "description": "## Overview\r\nA python module to deal with modified semantic versioning.\r\n\r\n### Motivation\r\nThere are three numbers as main part of a version in semantic version ([semver.org](https://semver.org)). Third number, patch, is defined as:\r\n> PATCH version when you make backward compatible bug fixes\r\n\r\nHowever, sometimes we need to distinguish two types of a bugfix.\r\n1. bugfix which is released in a standard way\r\n1. bugfix which has to be release immidiately as hotfix\r\n\r\nThe first type is released in a standard release process and at the end the patch of a version is increased.\r\n\r\nThe 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.\r\n<br>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.\r\n\r\n### Fix version part\r\nTo solve to the scenario described above, we introduce 4th number to main version part. Let's call it fix version and define it as:\r\n> FIX version when you make hot fixes released immidiately\r\n\r\nSo the new version in the described scenario would be *0.4.2.1*\r\n\r\nAt the end, the modification is only the one number.\r\n\r\n## Usage\r\nFew samples how to use the module. There are tow classes:\r\n- *Version4*: this class parses a version which includes the fix part as described above\r\n- *SemVersion*: classis semver2.0 version parser\r\n\r\n```python\r\nfrom semver4 import Version\r\n\r\n\r\nversion = Version4('2.4.4.0-alpha+123')\r\nprint(version)\r\n# '2.4.4-alpha+123'\r\n\r\nversion = Version4(major=2, minor=4, patch=4, prerelease='beta', build='12346')\r\nprint(version)\r\n# '2.4.4-beta+12346'\r\nprint(version.minor, version.fix)\r\n# 4 0\r\nprint(version.core)\r\n# '2.4.4'\r\n\r\nprint(version > Version('0.4.2.4'))\r\n# True\r\nprint(version == '2.4.4-beta+12346')\r\n# True\r\nprint(version == 'blabla')\r\n# raises NotComparableError\r\n\r\nversion.inc_fix()\r\nprint(version)\r\n# '2.4.4.1'\r\nprint(version.fix)\r\n# 1\r\n\r\nversion.prerelease = 'rc'\r\nversion.metadata = '987'\r\nprint(version)\r\n# '2.4.4.1-rc+987'\r\nprint(version.core)\r\n# '2.4.4.1'\r\n\r\nversion.inc_minor().inc_major().inc_patch()\r\nprint(version)\r\n# '3.0.1'\r\n\r\n# classic semver2.0 parser\r\nv = SemVersion('1.2.3-alpha+007')\r\nprint(v)\r\n# '1.2.3-alpha+007'\r\n```\r\n\r\nBoth, Version4 and SemVersion objects now support json serialization and yaml serialization.\r\n\r\n```python\r\nimport json\r\nimport yaml\r\nfrom semver4 import Version\r\nfrom semver4.yaml import get_version4_dumper, get_version4_loader\r\n\r\n\r\ndata = {\r\n    'version': Version('1.2.3.4-beta')\r\n}\r\ndumped = json.dumps(data, default=Version.json_enc)\r\nprint(dumped)\r\n# '{\"version\": \"1.2.3.4-beta\"}'\r\nprint(json.loads(dumped, object_hook=Version.json_dec))\r\n# {\"version\": 1.2.3.4-beta}\r\n\r\ndumped = yaml.dump(data, Dumper=get_version4_dumper())\r\nprint(dumped)\r\n# version: 1.2.3.4-beta\r\nprint(yaml.load(dumped, Loader=get_version4_loader()))\r\n# {'version': 1.2.3.4-beta}\r\n```\r\nThe [PyYAML module](https://pypi.org/project/PyYAML) 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.\r\n\r\nInstallation of PyYAML:\r\n```bash\r\npython3 -m pip install PyYAML\r\n# or python or py or whatever alias you have set\r\n# add --user for installation to the user dir\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Semantic versioning module enriched by hotfix version",
    "version": "0.0.1b8",
    "project_urls": {
        "Homepage": "https://github.com/martin356/python-semver4"
    },
    "split_keywords": [
        "version",
        " versioning",
        " semantic",
        " semver"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f81e5087fa87cd9d1dc18960d8c44cbbbcc5e124e8a5ac5a472a3ecd6aa369b1",
                "md5": "465cc05cd3975010001406be7b6c7bed",
                "sha256": "077a683643c1567b6525f8e78c54915f094e807f8a5eaff074934ed05a6789ab"
            },
            "downloads": -1,
            "filename": "semver4-0.0.1b8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "465cc05cd3975010001406be7b6c7bed",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7382,
            "upload_time": "2024-03-24T20:10:18",
            "upload_time_iso_8601": "2024-03-24T20:10:18.631725Z",
            "url": "https://files.pythonhosted.org/packages/f8/1e/5087fa87cd9d1dc18960d8c44cbbbcc5e124e8a5ac5a472a3ecd6aa369b1/semver4-0.0.1b8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7eefd7d21dbe836be00505d7fe0aa00e4a761363b0b01f7fa7b8471867842756",
                "md5": "5018f82c55eef26c0a6947064bcfbaf6",
                "sha256": "5e10e7805a38e4a0688858fc0dd9584859d2141532285f01776dcc4f3db474df"
            },
            "downloads": -1,
            "filename": "semver4-0.0.1b8.tar.gz",
            "has_sig": false,
            "md5_digest": "5018f82c55eef26c0a6947064bcfbaf6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8225,
            "upload_time": "2024-03-24T20:10:20",
            "upload_time_iso_8601": "2024-03-24T20:10:20.298708Z",
            "url": "https://files.pythonhosted.org/packages/7e/ef/d7d21dbe836be00505d7fe0aa00e4a761363b0b01f7fa7b8471867842756/semver4-0.0.1b8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-24 20:10:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "martin356",
    "github_project": "python-semver4",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "semver4"
}
        
Elapsed time: 0.23014s