Skip to content
This repository has been archived by the owner on Dec 5, 2018. It is now read-only.

alexandrevicenzi/pycompat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pycompat Build Status Build Version

Library to check Python and System version in a easy way

Note

This repository is archived because you should use Python 3 only. There's no reason to write code that runs on Python 2 and 3 anymore.

Compatibility

Works with all major versions of Python.

Tested on Python 1.5, 2.2, 2.3, 2.4, 2.6, 2.7, 3.0, 3.2, 3.3, 3.4 and PyPy.

Install

pip install pycompat

or

python setup.py install

How to use?

from pycompat import python as py
py.is2xx
>>> True
py.is27x
>>> True
py.is3xx
>>> False
py.is_gt(2, 5)
>>> True
py.is_lt(3)
>>> True
py.is_eq(2, 7, 5)
>>> True
py.is_cpython
>>> True
py.is_pypy
>>> False
from pycompat import system as sys
sys.is_64bits
>>> True
sys.is_linux
>>> True
sys.is_linux2
>>> True
sys.is_linux3
>>> False

List of all attributes/methods

import pycompat
from pycompat import python, system

# Constants
pycompat.WIN_32
pycompat.CYGWIN
pycompat.LINUX
pycompat.LINUX2
pycompat.LINUX3
pycompat.MAC_OS_X
pycompat.OS2
pycompat.OS2_EMX
pycompat.CPYTHON
pycompat.IRONPYTHON
pycompat.JYTHON
pycompat.PYPY
pycompat.MAX_SIZE

# Python version
pycompat.major
pycompat.minor
pycompat.micro
pycompat.release

# Python info
python.is1xx
python.is10x
python.is15x
python.is16x
python.is2xx
python.is20x
python.is21x
python.is22x
python.is23x
python.is24x
python.is25x
python.is26x
python.is27x
python.is3xx
python.is30x
python.is31x
python.is32x
python.is33x
python.is34x
python.is35x
python.is36x
python.is37x

python.is_pypy
python.is_ironpython
python.is_jython
python.is_cpython

python.is_32bits
python.is_64bits

python.is_gt(2, 7, 5)
python.is_lt(2, 7, 5)
python.is_eq(2, 7, 5)

python.is_alpha
python.is_beta
python.is_candidate
python.is_final

# System info
system.is_windows
system.is_cygwin
system.is_linux
system.is_linux2
system.is_linux3
system.is_mac_os

system.is_32bits
system.is_64bits

Changelog

0.3.0

  • Fix #5.
  • Add checks for Python 3.6 and 3.7.

0.2.1

0.2

  • Better approach for is_lt, is_gt and is_eq.
  • Add Python release info.

Want more?

Feel free to request more functions or contribute in this project.