Skip to main content

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

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

semantic-versioning-0.2.0.dev0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

semantic_versioning-0.2.0.dev0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file semantic-versioning-0.2.0.dev0.tar.gz.

File metadata

File hashes

Hashes for semantic-versioning-0.2.0.dev0.tar.gz
Algorithm Hash digest
SHA256 a79da48ab84c564fa3d917b6d5815b012eda60c1bfd7645aa5024d945e92002d
MD5 a003387eb57bebfc48b17adebc74df74
BLAKE2b-256 4e8455fd0687295a0b5408df3a51469d25505100fc80c842e7bfa3396d1231eb

See more details on using hashes here.

File details

Details for the file semantic_versioning-0.2.0.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for semantic_versioning-0.2.0.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 8cc016e396373d4f1fc8ba8717b945c33aa1a5be4fb78707a52df23ceb0b27a9
MD5 60d7368d5368d7ee8f45785fcadeaa09
BLAKE2b-256 2f6ebe365ba44b10fe2b831beb366a012fac57899e8a206e7d73b3068711508b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page