1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
# -----------------------------------------------------------------------------
# Copyright (c) 2011-2017, The BIOM Format Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
# -----------------------------------------------------------------------------
from __future__ import division
import sys
import click
from biom.cli import cli
@cli.command(name='show-install-info')
def show_install_info():
"""Provide information about the biom-format installation.
Provide information about the biom-format installation, including settings
pulled from the configuration file. For more details, see
http://biom-format.org
Example usage:
Display biom-format installation information:
$ biom show-install-info
"""
click.echo(_show_install_info())
def _show_install_info():
lines = []
lines.extend(_get_formatted_system_info())
lines.extend(_get_formatted_dependency_version_info())
lines.extend(_get_formatted_package_info())
lines.append('')
return '\n'.join(lines)
def _get_formatted_system_info():
return _format_info(_get_system_info(), 'System information')
def _get_formatted_dependency_version_info():
return _format_info(_get_dependency_version_info(), 'Dependency versions')
def _get_formatted_package_info():
return _format_info(_get_package_info(), 'biom-format package information')
def _get_system_info():
return (("Platform", sys.platform),
("Python version", sys.version.replace('\n', ' ')),
("Python executable", sys.executable))
def _get_dependency_version_info():
not_installed_msg = "Not installed"
try:
from click import __version__ as click_lib_version
except ImportError:
click_lib_version = not_installed_msg
try:
from numpy import __version__ as numpy_lib_version
except ImportError:
numpy_lib_version = ("ERROR: Not installed - this is required! "
"(This will also cause the BIOM library to "
"not be importable.)")
try:
from scipy import __version__ as scipy_lib_version
except ImportError:
scipy_lib_version = not_installed_msg
try:
from h5py import __version__ as h5py_lib_version
except ImportError:
h5py_lib_version = ("WARNING: Not installed - this is an optional "
"dependency. It is strongly recommended for "
"large datasets.")
return (("click version", click_lib_version),
("NumPy version", numpy_lib_version),
("SciPy version", scipy_lib_version),
("h5py version", h5py_lib_version))
def _get_package_info():
import_error_msg = ("ERROR: Can't find the BIOM library code (or "
"numpy) - is it installed and in your "
"$PYTHONPATH?")
try:
from biom import __version__ as biom_lib_version
except ImportError:
biom_lib_version = import_error_msg
return (("biom-format version", biom_lib_version),)
def _format_info(info, title):
max_len = _get_max_length(info)
lines = ['']
lines.append(title)
lines.append('=' * len(title))
for e in info:
lines.append("%*s:\t%s" % (max_len, e[0], e[1]))
return lines
def _get_max_length(info):
return max([len(e[0]) for e in info])
|