Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: show_config documentation #9312

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

Closed
wants to merge 19 commits into from
Closed
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
4 changes: 3 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
# for source files.
exclude_dirs = []

# A list of glob-style patterns that should be excluded when looking for source files.
exclude_patterns = ['reference/_*.rst']

# If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = False

Expand All @@ -76,7 +79,6 @@
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'


# -----------------------------------------------------------------------------
# HTML output
# -----------------------------------------------------------------------------
Expand Down
33 changes: 33 additions & 0 deletions doc/source/reference/_show_config.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.. currentmodule:: numpy

.. py:function:: show_config()

Print information about various resources (libraries, library directories,
include directories, etc.) in the system on which NumPy was built.

See Also
--------
:func:`numpy.lib.get_include` : Returns the include directory containing NumPy \\*.h header files.

Notes
-----
Classes specifying the information to be printed are defined
in the ``numpy.distutils.system_info`` module.

Information may include:

* ``language``: language used to write the libraries (mostly C or f77)
* ``libraries``: names of libraries found in the system
* ``library_dirs``: directories containing the libraries
* ``include_dirs``: directories containing library header files
* ``src_dirs``: directories containing library source files
* ``define_macros``: preprocessor macros used by ``distutils.setup``

Examples
--------
>>> np.show_config()
blas_opt_info:
language = c
define_macros = [('HAVE_CBLAS', None)]
libraries = ['openblas', 'openblas']
library_dirs = ['/usr/local/lib']
11 changes: 11 additions & 0 deletions doc/source/reference/distutils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ Other modules
log.set_verbosity
exec_command

System resource information
===========================

.. include:: _show_config.rst

.. currentmodule:: numpy.lib

.. autofunction:: get_include


Building Installable C libraries
================================

Expand Down Expand Up @@ -203,6 +213,7 @@ Info are easily retrieved from the `get_info` function in

An additional list of paths to look for .ini files can be given to `get_info`.


Conversion of ``.src`` files
============================

Expand Down
3 changes: 1 addition & 2 deletions doc/source/reference/routines.help.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ Finding help

lookfor


Reading help
------------

.. autosummary::
:toctree: generated/

info
source
source
2 changes: 1 addition & 1 deletion doc/source/reference/routines.other.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ NumPy version comparison
.. autosummary::
:toctree: generated/

lib.NumpyVersion
lib.NumpyVersion
32 changes: 28 additions & 4 deletions numpy/distutils/misc_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2294,7 +2294,32 @@ def get_info(name):
g = globals()
return g.get(name, g.get(name + "_info", {}))

def show():
''')

# Write `show_config` documentation to `__config__.py`
filename = '_show_config.rst'
from functools import reduce
path = reduce(os.path.join, ['doc', 'source', 'reference', filename])

with open(path, 'r') as rst_file:
rst = rst_file.read()

# Locate the start of the function description
docstart = rst.find("Print")
rst = rst[docstart:]

# Split, indent and rejoin the lines to indent the docstring
# 4 spaces below function signature.
tab = 4
lines = rst.split("\n")
doc = " "*tab + "\n ".join(lines)
# remove the sphinx role from the docstring
doc = doc.replace(':func:`numpy.lib.get_include`', 'get_include')
quotes = ' '*tab + '"""'
f.write("def show():\n" + quotes + '\n' + doc + '\n' + quotes + '\n')

# `show_config` body
f.write(r'''
for name,info_dict in globals().items():
if name[0] == "_" or type(info_dict) is not type({}): continue
print(name + ":")
Expand All @@ -2305,8 +2330,7 @@ def show():
if k == "sources" and len(v) > 200:
v = v[:60] + " ...\n... " + v[-60:]
print(" %s = %s" % (k,v))
''')

''')
f.close()
return target

Expand All @@ -2316,4 +2340,4 @@ def msvc_version(compiler):
if not compiler.compiler_type == "msvc":
raise ValueError("Compiler instance is not msvc (%s)"\
% compiler.compiler_type)
return compiler._MSVCCompiler__version
return compiler._MSVCCompiler__version