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

Uploaded Source

Built Distribution

semantic_versioning-0.1.3-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: semantic-versioning-0.1.3.tar.gz
  • Upload date:
  • Size: 6.3 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.3.tar.gz
Algorithm Hash digest
SHA256 efe3471f53c27d879991b850df13530ae47d6800eb55bf07bb715ee995d67f1c
MD5 7b443bbbf26a71a78af45a28c8aabe55
BLAKE2b-256 9d8e17c10dd50c1703b53c6da0efd8170f5c8737fdc6400b21f60123f41df329

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for semantic_versioning-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0c3f90ccd863c7a50a7a4bfeaae0cefae103fcdc85aeb08841afb532b932e74e
MD5 2c1ef7c9f9fe3d33e5bce220bd2a670a
BLAKE2b-256 afafbfdf14cafd28f93d4b52fddb872eb9de19bfbfe9f04e934c35d9fd9db978

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