Skip to main content

Class to manage semantic versioning

Project description

Version-Tools

Installation

From Repository

To install the Version-Tools package from the repository, run the following commands:

git clone https://github.com/RomoloPoliti-INAF/version-tools.git
cd version-tools
poetry install

From PyPi

To install the Version-Tools package from PyPi, run the following command:

pip install semantic-version-tools

Using poetry

To add the package to your poetry project, you can run the command:

poetry add semantic-versioning-tools

Usage

To use the library it's necessary import the class Vers, than you can comapare or manipulate the version numbers.

Initialize and print version

>>> from semantic_version_tools import Vers

>>> main_ver=Vers('1.0')
>>> print(main_ver)

Version 1.0

The version number could be a string or a tuple, whit 2 or 5 elements:

  • the major version number
  • the minor version number
  • the patch number
  • pre-release type
  • build number

For the pre-release are used letters as reported below:

  • d: developing version
  • a: alpha release
  • b: beta release
  • rc: release candidate
  • f: final release
>>> main_version = Vers((0,1,0,'d',1))
>>> print(main_version)

Version 0.1.0-devel.1

>>> main_version = Vers('0.1.0-a.1')
>>> print(main_version)

Version 0.1.0-alpha.1

Compare versions

In the class Vers are implemented the main comparison operators. For example:

>>> a=Vers('1.0.0')
>>> b=Vers('1.0.1')

>>> a>b
False
>>> a==b
False
>>> a<b
True
a<=b
True

Sum and increase

It's possible sum tro version number or icrease it.

>>> a = Vers('1.0.0')
>>> b = Vers('1.0.1')
>>> c=a+b
>>> c
Version 2.0.1


>>> a = Vers('1.0.0')
>>> a=a+1
>>> a
Version 1.1.0
# equivalent to
>>> a +=1
>>> a
Version 1.1.0

The summ add a minor version. To add a major version you must add a float

>>> a = Vers('1.0.0')
>>> a += 1.0
>>> a
Version 2.0.0

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_version_tools-1.4.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

semantic_version_tools-1.4.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file semantic_version_tools-1.4.0.tar.gz.

File metadata

  • Download URL: semantic_version_tools-1.4.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.7 Darwin/24.6.0

File hashes

Hashes for semantic_version_tools-1.4.0.tar.gz
Algorithm Hash digest
SHA256 dc33c7883bb7101f3ab858b7a39bbcb4c9fdea1972108411d65d1d1fda18b1dd
MD5 de029c9b164b51a0f87d35403e261f7a
BLAKE2b-256 163f804230a78d9fa7107a8c21c06c5faf81b3e7037eec85ba0714363c6ddadc

See more details on using hashes here.

File details

Details for the file semantic_version_tools-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for semantic_version_tools-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d40e0be1b5522d01e622a771fade0b424cbd92a575278e8dc6d77ccbe7a6ede
MD5 5d9841a5ad9745b10d54c878e0e0a541
BLAKE2b-256 493333d62dfa50e00e6ff218bc21bc121588d0df5edad8a63afe97d0f8c94baf

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