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.1.2.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

semantic_versioning-0.1.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file semantic-versioning-0.1.2.tar.gz.

File metadata

  • Download URL: semantic-versioning-0.1.2.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for semantic-versioning-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b3ce9f8f57c289233452ab1d6f5cef439309127f41ca49681f02de602ab3af76
MD5 d94e6aa4bd1839e3dedf131976650fee
BLAKE2b-256 9d52cb5a7299529a7e461c5d9966cf45fc2289e92b9fccb6057bfcdccb7bee38

See more details on using hashes here.

File details

Details for the file semantic_versioning-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for semantic_versioning-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f170d7126b29342db93ccd49d1ee9bba96ed1c8d775c3b7c5532191911cd2b29
MD5 84363a7e0521bc85aac03a48686a67cb
BLAKE2b-256 2bd7e59435d093c30a42e60a0291faf991aeb78702bf9c1032d796aaf99fbe01

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