hbutils.system.python

python_version

hbutils.system.python.python_version() → packaging.version.Version[source]
Overview:

Get version of python.

Returns:

Version of python.

Examples::
>>> from hbutils.system import python_version
>>>
>>> python_version()
Version('3.8.1')  # for example

is_cpython

hbutils.system.python.is_cpython() → bool[source]
Overview:

Return True is current python is CPython, otherwise return False.

Returns:

Current python is CPython or not.

is_ironpython

hbutils.system.python.is_ironpython() → bool[source]
Overview:

Return True is current python is IronPython, otherwise return False.

Returns:

Current python is IronPython or not.

is_jython

hbutils.system.python.is_jython() → bool[source]
Overview:

Return True is current python is Jython, otherwise return False.

Returns:

Current python is Jython or not.

is_pypy

hbutils.system.python.is_pypy() → bool[source]
Overview:

Return True is current python is PyPy, otherwise return False.

Returns:

Current python is PyPy or not.

package_version

hbutils.system.python.package_version(name: str) → Optional[packaging.version.Version][source]
Overview:

Get version of package with given name.

Parameters:

name – Name of the package, case is not sensitive.

Returns:

A packing.version.Version object. If the package is not installed, return None.

Examples::
>>> from hbutils.system import package_version
>>>
>>> package_version('pip')
<Version('21.3.1')>
>>> package_version('setuptools')
<Version('59.6.0')>
>>> package_version('not_a_package')
None