Skip to main content

Makes it easier to work with versions for your projects.

Project description

Version Class (Python Implementation)

A Python implementation of version number management inspired by .NET's Version class, providing robust version number handling and comparison capabilities.

Features

  • Multiple constructors for flexible version creation
  • String parsing and validation
  • Component-based comparison operations
  • Strict type and value checking
  • Comprehensive error handling

Installation

pip install model_version_manager

Basic Usage

from model_version_manager import Version

# Different ways to create versions
v1 = Version()           # 0.0
v2 = Version(1, 2)       # 1.2
v3 = Version(1, 2, 3)    # 1.2.3
v4 = Version("1.2.3.4")  # From string

# Access components
print(f"{v4.major}.{v4.minor}.{v4.build}.{v4.revision}")

# Comparison
print(v2 == Version(1, 2))  # True
print(v3 < Version(1, 3))   # True
print(v1 > v2)              # False

API Reference

Version()   # 0.0
Version(major: int, minor: int) 
Version(major: int, minor: int, build: int) 
Version(major: int, minor: int, build: int, revision: int)
Version(version_string: str)  # Parses "major.minor.build.revision"

Properies

  • major: int - Major version number

  • minor: int - Minor version number

  • build: int - Build number (-1 if not specified)

  • revision: int - Revision number (-1 if not specified)

Methods

  • __str__(): Returns string representation (e.g. "1.2.3.4")

  • __eq__(), __lt__(), etc.: Comparison operators

  • parse(version_string): Classmethod to parse version strings

Comparison Rules

Versions are compared component by component in order:

  1. Major

  2. Minor

  3. Build

  4. Revision

Missing components (represented by -1) are considered older than any specified component.

Examples

See complete examples in the examples/ directory:

  • basic_usage.py - Basic functionality

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

model_version_manager-1.0.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

model_version_manager-1.0.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file model_version_manager-1.0.1.tar.gz.

File metadata

  • Download URL: model_version_manager-1.0.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for model_version_manager-1.0.1.tar.gz
Algorithm Hash digest
SHA256 20aa33a749ab0e649cab9bfacc67331e4fc80ea62f85be96a21a73b7040faf69
MD5 9e04929fcfd1dfd495ab3f6657e49c6b
BLAKE2b-256 b5b440f92e2dd4365fc8e1464741fce4afbc88269b5057029f7a6c9a0f14aeac

See more details on using hashes here.

File details

Details for the file model_version_manager-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for model_version_manager-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bcc83dae8d3fc4f83713edebe61354d3c4ddcfa382850b58455b9cd4e4d0ba86
MD5 fa4d5099f5c2089fe4c1aef214b7cf15
BLAKE2b-256 110aad81713b673c0d9cae14bae0cc428d33dc7764f00cb2bb9f44a8dabccaef

See more details on using hashes here.

Supported by

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