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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for semantic-versioning-0.1.4.tar.gz
Algorithm Hash digest
SHA256 c999168066eebed905bb89fa1cc527f4427bab1f3409b124a3ecc8b7fadb1b9b
MD5 974c93cd266bf8a1c2c949fbb12307dd
BLAKE2b-256 33718eaaaef7ae5cb0ff3d7181b521c5ae7698b488b6ed590adb33f28ba2c553

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for semantic_versioning-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 346853d6a44846c96027a286dc75882aea01c30bd3c6cc87ed0361ea71c77046
MD5 838063051df055e69bcd3f058002c393
BLAKE2b-256 bafa4213b9dfd1f45d7060da231859c5bc0a1ae88dd564606a47b8042a6383a7

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