Versioning is a Python package for managing version strings according to PEP 440 and SemVer 2.0 specifications. It includes support for parsing, comparing, rendering, and incrementing version strings.
To install the package from GitHub, use the following command:
pip install git+https://github.com/conradbzura/versioning.git
from versioning import PythonicVersion, SemanticVersion
# Create a pythonic version
py_version = PythonicVersion(major_release=1, minor_release=0, patch_release=0, release_cycle=".", post_release=1, local_identifier="deadbeef")
print(py_version) # Output: 1.0.0.post1+deadbeef
# Create a semantic version
sem_version = SemanticVersion(major_release=1, minor_release=0, patch_release=0, pre_release=("alpha", 1), build="deadbeef")
print(sem_version) # Output: 1.0.0-alpha.1+deadbeef
You can define custom parsers using the @parser
decorator:
from versioning import parser, PythonicVersion
@parser("custom")
def custom() -> str:
return "1.0.0"
version = PythonicVersion.parse.custom()
To run the unit tests, use the following command:
make tests
To run the tests in debug mode, use:
make debug-tests
To run the tests and update expected results, use:
make update-tests
This project is licensed under the MIT License.