Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method that show base installation info about gensim & related packages. Fix #1902 #1903

Merged
merged 10 commits into from
Feb 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/apiref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Modules:
topic_coherence/probability_estimation
topic_coherence/segmentation
topic_coherence/text_analysis
scripts/package_info
scripts/glove2word2vec
scripts/make_wikicorpus
scripts/word2vec_standalone
Expand Down
9 changes: 9 additions & 0 deletions docs/src/scripts/package_info.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:mod:`scripts.package_info` -- Information about gensim package
===============================================================

.. automodule:: gensim.scripts.package_info
:synopsis: Information about gensim package.
:members:
:inherited-members:
:undoc-members:
:show-inheritance:
7 changes: 3 additions & 4 deletions gensim/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""
This package contains interfaces and functionality to compute pair-wise document
similarities within a corpus of documents.
"""
"""This package contains interfaces and functionality to compute pair-wise document similarities within a corpus
of documents.

"""
from gensim import parsing, matutils, interfaces, corpora, models, similarities, summarization, utils # noqa:F401
import logging

Expand Down
60 changes: 60 additions & 0 deletions gensim/scripts/package_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"""Get basic information about gensim & dependencies (useful for bug-reporting).

Examples
--------
You can use it through python

>>> from gensim.scripts.package_info import package_info
>>>
>>> info = package_info()

or using CLI interface

::

python -m gensim.scripts.package_info --info


.. program-output:: python -m gensim.scripts.package_info --help
:ellipsis: 0, -4
"""
import argparse
import platform
import sys
import os
import numpy
import scipy
import gensim
from gensim.models.word2vec import FAST_VERSION


def package_info():
"""Get the versions of Gensim and its dependencies,
the location where Gensim is installed and platform on which the system is running.

Returns
-------
dict of (str, str)
Dictionary containing the versions of Gensim, Python, NumPy, SciPy and platform information.

"""
return {
"Platform": platform.platform(),
"Python": sys.version.replace("\n", ', '),
"NumPy": numpy.__version__,
"SciPy": scipy.__version__,
"Gensim": gensim.__version__,
"Location": os.path.abspath(__file__),
"FAST_VERSION": FAST_VERSION
}


if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__[:-65], formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("--info", help="Information about Gensim package", action="store_true")
args = parser.parse_args()

if args.info:
print("Gensim installation information\n")
for (k, v) in sorted(package_info().items()):
print("{}: {}".format(k, v))