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.3.3.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.3.3-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: semantic_version_tools-1.3.3.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.14.2 Linux/6.18.5-200.fc43.x86_64

File hashes

Hashes for semantic_version_tools-1.3.3.tar.gz
Algorithm Hash digest
SHA256 64b15f3bb151a0f39c49ecc923892ad7a9fc8550d44d4daf4aaa1dfcfa64eee4
MD5 9bfe85484bcdd5164db695f036b26491
BLAKE2b-256 ac4b69fdd40e16e48087767c48c2d745c1afa22788d998fc5fac7550f75ee1cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for semantic_version_tools-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 498c801a50f1f13dea2a2b5bf2c4a5b900ff5b4270b1fc29abe0cac38bd65e9d
MD5 58588ce2be019c881ed90bb6db97acb2
BLAKE2b-256 63f6938a629b4fceca73b7583cc9e42eb41742ecff872261106d42f72eb7322a

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