A package for easily managing Semantic versions as described in PEP440.
Project description
semantic_versioning
Another semantic versioning package, but better! It follows semantic versioning described in PEP440.
Installation
Use the package manager pip to install semantic_versioning.
pip install semantic_versioning
Usage
Use validate function to check if versions in strings are correctly formatted.
from semantic_versioning import SemanticVersion
# use to validate (returns True)
assert SemanticVersion.validate("3.4.5-dev1")
Use parse function to load a SemanticVersion object from a string.
from semantic_versioning import SemanticVersion
SemanticVersion.parse("1.2.4")
# SemanticVersion(major=1, minor=2, patch=3)
SemanticVersion.parse("1.2a3.dev6")
# SemanticVersion(major=1, minor=2, pre_release_type="a", pre_release=3, dev_release=6)
SemanticVersion.parse("1-5-6", separator="-")
# SemanticVersion(major=1, minor=5, patch=3)
SemanticVersion.parse("1.0.1.2.5")
# SemanticVersion(major=1, minor=0, patch=1, versions=[2,5])
The SemanticVersion class is comparable and will correctly take pre/dev/post releases into account.
from semantic_versioning import SemanticVersion
SemanticVersion.parse("1.2.3") < SemanticVersion.parse("1.2.4") # True
SemanticVersion.parse("1.2.3") < SemanticVersion.parse("1.2") # True
SemanticVersion.parse("1.2.dev0") < SemanticVersion.parse("1.2.dev1") # True
SemanticVersion.parse("1.2.dev0") < SemanticVersion.parse("1.2") # True
SemanticVersion.parse("1.2a1") < SemanticVersion.parse("1.2b0") # True
SemanticVersion.parse("1.2a1") < SemanticVersion.parse("1.2.post2") # True
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file semantic_versioning-0.1.5.tar.gz
.
File metadata
- Download URL: semantic_versioning-0.1.5.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 323432ec42163385cdb955fbd59c98949ec11e375a852f1c4094873f483f91fb |
|
MD5 | 8905f2bae9f12ab8145def072d82c65e |
|
BLAKE2b-256 | 78e12d4c5e68b69b5828b6901cd84d07010cc37c5ffcc6af037a86fe3c046450 |
File details
Details for the file semantic_versioning-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: semantic_versioning-0.1.5-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2046c9956a7fc267412289bf99816efefbbd89bcce5e2a5197ef59c1b92ce6c1 |
|
MD5 | bd53c3883b998dc2ca4429c4889dd989 |
|
BLAKE2b-256 | d49e4e91222a88f9493b80d2ace55f2c5c866173058ad1c3b8946b12fa606d11 |