iscompatible

Python versioning with requirements.txt syntax


License
MIT
Install
pip install iscompatible==0.1.1

Documentation

Python versioning with requirements.txt syntax

Build Status PyPI version Coverage Status

iscompatible gives you the power of the pip requirements.txt syntax for everyday python packages, modules, classes or arbitrary functions. Supports Python 2.6-2.7 and Python 3.2-3.3, licensed under MIT.

Example

The requirements.txt syntax allows you to specify inexact matches between a set of requirements and a version. For example, let's assume that the single package foo-5.6.1 exists on disk. The following requirements are all compatible with foo-5.6.1.

Requirement Description
foo any version of foo
foo>=5 any version of foo, above or equal to 5
foo>=5.6 any version of foo, above or equal to 5.6
foo==5.6.1 exact match
foo>5 foo-5 or greater, including minor and patch
foo>5, <5.7 foo-5 or greater, but less than foo-5.7
foo>0, <5.7 any foo version less than foo-5.7

Usage

>>> iscompatible("foo>=5", (5, 6, 1))
True
>>> iscompatible("foo>=5.6.1, <5.7", (5, 0, 0))
False
>>> MyPlugin = type("MyPlugin", (), {'version': (5, 6, 1)})
>>> iscompatible("foo==5.6.1", MyPlugin.version)
True