Skip to main content

License Travis CI Build Status Latest Version

compatibleversion

compatibleversion takes two parameters, a version and a specifier (i.e., version constraints), and returns a Boolean value indicating compatibility.

NOTE: compatibleversion wraps packaging in order to simplify and test its use. Versions and specifiers provided to compatibleversion must conform to PEP 440 as required by packaging.

install

$ pip install compatibleversion

usage

Use compatibleversion in Python code:

from compatibleversion import check_version

check_version('1.3.0', '> 1.2, < 3.3')          # True
check_version('2.1', '~= 2.2')                  # False

check_version('1.1.dev0', '>=1.0')              # True
check_version('1.1.dev0', '>=1.0', False)       # False, not allowing pre/dev-final comparison

check_version('1.1.dev0', '>=1.0.dev0')         # True, dev-dev compare
check_version('1.1.dev0', '>=1.0.dev0', False)  # True, doesn't affect since dev-dev

version parameter

The version parameter must conform to PEP 440. These are examples of valid version parameters:

1.2.0
0.0.0
0.9
0.9.1
0.9.2
0.9.10
0.9.11
1.0
1.0.1
1.1
2.0
2.0.1
1.0a1
1.0a2
1.0b1
1.0rc1
1.0.dev1
1.0.dev2
1.0.dev3
1.0.dev4
1.0b2.post345.dev456
1.0b2.post345
1.0rc1.dev456

specifier parameter

The version specifier parameter must conform to PEP 440. The specifier consists of one or more version clauses separated by commas.

For example, these are valid version specifiers (the last two are approximately equivalent):

==1.0.1
< 1.2, > 1.3
~= 0.9, >= 1.0, != 1.3.4.*, < 2.0
~= 1.4.5.0
== 1.1.post1
~= 2.2
>= 2.2, == 2.*

Here are more helpful specifier examples from PEP 440 and an explanation of their meaning:

  • ~=3.1: version 3.1 or later, but not version 4.0 or later.
  • ~=3.1.2: version 3.1.2 or later, but not version 3.2.0 or later.
  • ~=3.1a1: version 3.1a1 or later, but not version 4.0 or later.
  • == 3.1: specifically version 3.1 (or 3.1.0), excludes all pre-releases, post releases, developmental releases and any 3.1.x maintenance releases.
  • == 3.1.*: any version that starts with 3.1. Equivalent to the ~=3.1.0 compatible release clause.
  • ~=3.1.0, != 3.1.3: version 3.1.0 or later, but not version 3.1.3 and not version 3.2.0 or later.

Changelog

0.2.0

Commit Delta: Change from 0.1.3 release

Released: 2020.03.04

Summary:

  • Allow comparison between prerelease and dev releases (e.g., 1.0.dev0) and final releases (e.g., 1.0)

0.1.3

Commit Delta: Change from 0.1.2 release

Released: 2020.01.28

Summary:

  • Update dependencies
  • Update Python compatibility versions in PyPI/wheel package

0.1.2

Commit Delta: Change from 0.1.1 release

Released: 2019.10.24

Summary:

  • Improve compatibility with Py2.6

0.1.1

Commit Delta: Change from 0.1.0 release

Released: 2019.10.24

Summary:

  • Minor CI changes
  • Add documentation

0.1.0

Commit Delta: Change from 0.0.0 release

Released: 2019.10.22

Summary:

  • Initial release

Release files for compatibleversion 0.2.17

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

Source distribution (sdist)

Source distribution for compatibleversion 0.2.17
File Size Uploaded
compatibleversion-0.2.17.tar.gz 8.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for compatibleversion 0.2.17
File Interpreter ABI Platform
compatibleversion-0.2.17-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 12.8 kB

Release files / compatibleversion-0.2.17.tar.gz

Download URL compatibleversion-0.2.17.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
73097fa9fade3c8345b7957d4d5c66ae53215dbdc84d618f18ec64a64fb3d413
BLAKE2b-256 checksum
How to use checksums
222133b22041ee8c185defa123a1ac32ef46ba0e350ac8b749d328551dea46c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.7

Release files / compatibleversion-0.2.17-py2.py3-none-any.whl

Download URL compatibleversion-0.2.17-py2.py3-none-any.whl
Size 4.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
59bb671f3e6e5f6b91647715ad2009e2fb3ceee4b6052532c0887997bf43ccfd
BLAKE2b-256 checksum
How to use checksums
42643c5cfb2e7a319b4f0a89cc249386bc71142aec6d7729ded6fbe007cc3702
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.7

Release history Release notifications | RSS feed

This release

0.2.17 This release

2 release files

0.2.16

2 release files

0.2.13

2 release files

0.2.12

2 release files

0.2.11

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

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