Skip to main content

Parsing, inspecting and specifying versions.

Project description

versions

License Version Downloads Discord

Documentation Check Test Coverage

Parsing, inspecting and specifying versions.

Installing

Python 3.7 or above is required.

pip

Installing the library with pip is quite simple:

$ pip install versions

Alternatively, the library can be installed from source:

$ git clone https://github.com/nekitdev/versions.git
$ cd versions
$ python -m pip install .

poetry

You can add versions as a dependency with the following command:

$ poetry add versions

Or by directly specifying it in the configuration like so:

[tool.poetry.dependencies]
versions = "^1.1.0"

Alternatively, you can add it directly from the source:

[tool.poetry.dependencies.versions]
git = "https://github.com/nekitdev/versions.git"

Examples

Versions

parse_version is used to parse versions:

from versions import parse_version

version = parse_version("1.0.0-dev.1+build.1")

print(version)  # 1.0.0-dev.1+build.1

Segments

All version segments can be fetched with their respective names:

>>> print(version.release)
1.0.0
>>> version.release.parts
(1, 0, 0)
>>> print(version.dev)
dev.1
>>> (version.dev.phase, version.dev.value)
("dev", 1)
>>> print(version.local)
build.1
>>> version.local.parts
("build", 1)

Comparison

Versions support total ordering:

>>> v1 = parse_version("1.0.0")
>>> v2 = parse_version("2.0.0")
>>> v1 == v2
False
>>> v1 != v2
True
>>> v1 >= v2
False
>>> v1 <= v2
True
>>> v1 > v2
False
>>> v1 < v2
True

Specification

versions also supports specifying version requirements and matching version against them:

Since versions support total ordering, they can be checked using version sets (via parse_version_set):

>>> from versions import parse_version, parse_version_set
>>> version_set = parse_version_set("^1.0.0")
>>> version_set
<VersionRange (>= 1.0.0, < 2.0.0)>
>>> version = parse_version("1.3.0")
>>> version
<Version (1.3.0)>
>>> version.matches(version_set)
True
>>> another = parse_version("2.2.0")
>>> another.matches(version_set)
False

Documentation

You can find the documentation here.

Support

If you need support with the library, you can send an email or refer to the official Discord server.

Changelog

You can find the changelog here.

Security Policy

You can find the Security Policy of versions here.

Contributing

If you are interested in contributing to versions, make sure to take a look at the Contributing Guide, as well as the Code of Conduct.

License

versions is licensed under the MIT License terms. See License for details.

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

versions-1.1.0.tar.gz (32.4 kB view details)

Uploaded Source

Built Distribution

versions-1.1.0-py3-none-any.whl (35.8 kB view details)

Uploaded Python 3

File details

Details for the file versions-1.1.0.tar.gz.

File metadata

  • Download URL: versions-1.1.0.tar.gz
  • Upload date:
  • Size: 32.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0b3 CPython/3.10.5 Linux/5.15.0-1014-azure

File hashes

Hashes for versions-1.1.0.tar.gz
Algorithm Hash digest
SHA256 b435015c0acbaa6150ba58ecca38ad6bc22d14e4d3a482092646bc62f0ca0bcf
MD5 7f22f53fe44563e1c49a902917f2de1f
BLAKE2b-256 03630177689fa7eab766f66e9ea741d6c0bcf7d8924316b5bf3eb7e9e9dd520e

See more details on using hashes here.

File details

Details for the file versions-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: versions-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 35.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0b3 CPython/3.10.5 Linux/5.15.0-1014-azure

File hashes

Hashes for versions-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7341e9c8c82182eef31de26eff5f2e9942e4b521aebe0a3a576af66eef745d8b
MD5 b39e07e0583602f2b8dfe4cf13b9799e
BLAKE2b-256 f820ab2c3bfd1fc4d56114b733258b3875da91049ae4cbc823070974a76b738c

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