module installhelper.module_install_version

Short summary

module pymyinstall.installhelper.module_install_version

Functions to get module version, license, dependencies

source on GitHub

Functions

function

truncated documentation

_get_pypi_version_memoize_op

choose_most_recent

Chooses the most recent version for a list of module names.

compare_version

Compares two versions.

get_module_dependencies

Returns the dependencies for a module.

get_module_metadata

Returns a dictionary { module: metadata }.

get_module_version

Returns a dictionary { module: version }.

get_pypi_version

Returns the version of a package on pypi, we skip alpha, beta or dev version.

get_wheel_version

extract the version from a wheel file, return 2.6.0 for rpy2-2.6.0-cp34-none-win_amd64.whl

is_installed

Tells if a module is installed or not.

numeric_version

convert a string into a tuple with numbers wherever possible

version_consensus

v1 and v2 are two versions of the same module, which one to keep?

Documentation

Functions to get module version, license, dependencies

source on GitHub

pymyinstall.installhelper.module_install_version._get_pypi_version_memoize_op(f)
pymyinstall.installhelper.module_install_version.choose_most_recent(list_name)

Chooses the most recent version for a list of module names.

Parameters:

list_name – list of names

Returns:

most recent version or None if the input list is empty

In the following case, we would choose the first option:

numpy-1.10.0+mkl-cp34-none-win_amd64.whl
numpy-1.9.1.0+mkl-cp34-none-win_amd64.whl

source on GitHub

pymyinstall.installhelper.module_install_version.compare_version(num, vers)

Compares two versions.

Parameters:
  • num – first version

  • vers – second version

Returns:

-1, 0, 1

source on GitHub

pymyinstall.installhelper.module_install_version.get_module_dependencies(module, use_cmd=False, deep=False, collapse=True, use_pip=None, refresh_cache=False)

Returns the dependencies for a module.

Parameters:
  • module – unused, None

  • use_cmd – use command line

  • deep – dig into dependencies of dependencies

  • collapse – only one row per module

  • use_pip – use pip to discover dependencies or not (parse metadata)

  • refresh_cache – refresh the cache (see below)

Returns:

list of tuple (module, version, required by as a str) or dictionary { module: (version, required by as a list) } if collapse is True

The function which uses use_pip=True is not fully tested, it does not return contraints (== 2.4). The function caches the results to avoid doing it again during a second execution unless refresh_cache is True. This function is not tested on Python 2.7.

source on GitHub

pymyinstall.installhelper.module_install_version.get_module_metadata(module, use_cmd=False, refresh_cache=False)

Returns a dictionary { module: metadata }.

Parameters:
  • module – unused, None

  • refresh_cache – refresh the cache before getting metadata

Returns:

dictionary

source on GitHub

pymyinstall.installhelper.module_install_version.get_module_version(module, use_cmd=False)

Returns a dictionary { module: version }.

Parameters:
  • module – unused, None

  • use_cmd – use command line

Returns:

dictionary

source on GitHub

pymyinstall.installhelper.module_install_version.get_pypi_version(module_name, full_list=False, url='https://pypi.python.org/pypi', skip_betas=True)

Returns the version of a package on pypi, we skip alpha, beta or dev version.

Parameters:
  • module_name – module name

  • url – pypi server

  • full_list – results as a list or return the last stable version

  • skip_betas – skip the intermediate functions

Returns:

version (str or list)

See also installing_python_packages_programatically.py, pkgtools.pypi: PyPI interface.

It the function fails, check the status of Python Infrastructure. It can return errors:

ProtocolError: ProtocolError for pypi.python.org/pypi: 503 No healthy backends

source on GitHub

pymyinstall.installhelper.module_install_version.get_wheel_version(whlname)

extract the version from a wheel file, return 2.6.0 for rpy2-2.6.0-cp34-none-win_amd64.whl

Parameters:

whlname – file name

Returns:

string

source on GitHub

pymyinstall.installhelper.module_install_version.is_installed(name)

Tells if a module is installed or not.

Parameters:

name – module name

Returns:

boolean

source on GitHub

pymyinstall.installhelper.module_install_version.numeric_version(vers)

convert a string into a tuple with numbers wherever possible

Parameters:

vers – string

Returns:

tuple

source on GitHub

pymyinstall.installhelper.module_install_version.version_consensus(v1, v2)

v1 and v2 are two versions of the same module, which one to keep?

Parameters:
  • v1 – version 1

  • v2 – version 2

Returns:

consensus

  • v1=None, v2='(>=1.5)' –> v='>=1.5'

To improve:

  • v1='<=1.6', v2='(>=1.5)' –> v='==1.6'

source on GitHub