Skip to main content

SemaVer

SemaVer is a simple library for Python that helps to work with versions using semantic versioning notation.

Build status

Build Status Coverage

Requirements

Python >=3.5

Installation

pip install semaver

Usage

Version objects

To create version, instantiate Version class passing version identifier as a constructor argument:

from semaver import Version

v1_0_0 = Version('1.0.0')

Valid version identifiers can be found as [https://semver.org/] except that currently SemaVer does not support pre-release and [build metadata] specs.

All non-specified parts of the version identifier counted as zeroes, i. e. '1' == '1.0' == '1.0.0'.

Compare versions

You may compare versions using regular Python comparison operators:

from semaver import Version

v1_0 = Version('1.0')
v1_0_0 = Version('1.0.0')
v1_0_1 = Version('1.0.1')

assert v1_0 == v1_0_0  # True
assert v1_0 != v1_0_0  # False

assert v1_0 < v1_0_1  # True
assert v1_0 <= v1_0_1  # True
assert v1_0 > v1_0_1  # False
assert v1_0 >= v1_0_1  # False

# Or using plain strings

assert v1_0 == '1'  # True
assert v1_0 == '1.0'  # True
assert v1_0 == '1.0.0'  # True

Also it is possible to compare versions against strings:

from semaver import Version

v1_0 = Version('1.0')
v1_0_0 = Version('1.0.0')
v1_0_1 = Version('1.0.1')

Adding and subtracting versions

from semaver import Version

print(Version('1.0.0') + Version('0.1.1'))  # '1.1.1'
from semaver import Version

print(Version('2.0.1') - Version('1.0.1'))  # '1.0.0'

Version range objects

Instance of VersionRange represents a version range. First argument of constructor is a version range identifier.

from semaver import VersionRange

VersionRange('1.x')

Following formats are supported.

For example, each item of the following list shows equal version range identifiers:

  • 1.x, 1.*, ^1, >=1,<2.
  • ^1.1, >=1.1,<2.
  • 1.0.x, 1.0.*, ~1, ~1.0.

Checking if a version is in a range

from semaver import Version, VersionRange

v1_2_3 = Version('1.2.3')
v1_x = VersionRange('1.x')
v2_x = VersionRange('2.x')

assert v1_2_3 in v1_x  # True
assert v1_2_3 in v2_x  # False

# Or using plain strings

assert '1.2.3' in v1_x  # True
assert '1.2.3' in v2_x  # False

Checking if a range is in a range

from semaver import VersionRange

v1_to_3 = VersionRange('>=1,<=3')
v2_x = VersionRange('2.x')

assert v2_x in v1_to_3  # True
assert v1_to_3 in v2_x  # False

# Or using plain strings

assert '2.x' in v1_to_3  # True
assert '>=1,<=3' in v2_x  # False

Testing

tox

Contributing

See the CONTRIBUTING.md file for details.

Changelog

See the CHANGELOG.md file for details.

Support

If you have any issues or enhancement proposals feel free to report them via project's Issue Tracker.

Authors

License

This project is licensed under the MIT License. See the LICENSE.md file for details.

to-specify-update-types-your-package-can-accept

Metadata

Release files for semaver 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for semaver 0.2.1
File Interpreter ABI Platform Actions
semaver-0.2.1-1-py3-none-any.whl Python 3 none any Details for semaver-0.2.1-1-py3-none-any.whl

Release files / semaver-0.2.1-1-py3-none-any.whl

Download URL semaver-0.2.1-1-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d04ddc59e14fbc36de6c26de0d06ab3d96292262da3e8952f54ccd3c8634374c
BLAKE2b-256 checksum
How to use checksums
29ac42f8c6094a028f3a8387db279a41d9dc2b974cd1d6d89fd320afc6b66c8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.4

Security for semaver 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page