Commit 76e01201 authored by Ole Streicher's avatar Ole Streicher

New upstream version 0.6

parent 9873112c
This diff is collapsed.
Metadata-Version: 1.1
Name: gammapy
Version: 0.5
Version: 0.6
Summary: A Python package for gamma-ray astronomy
Home-page: https://github.com/gammapy/gammapy
Author: The Gammapy developers
......@@ -31,6 +31,7 @@ Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering :: Astronomy
Classifier: Development Status :: 3 - Alpha
......@@ -5,15 +5,12 @@ A Python Package for Gamma-ray Astronomy.
* Code: https://github.com/gammapy/gammapy
* Docs: http://docs.gammapy.org/
* Tutorials: https://nbviewer.jupyter.org/github/gammapy/gammapy-extra/blob/master/index.ipynb
* License: BSD-3
.. image:: http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat
:target: http://www.astropy.org/
Try Gammapy online in the browser via http://mybinder.org/ :
.. image:: http://mybinder.org/badge.svg
:target: http://mybinder.org/repo/gammapy/gammapy-extra
Status shields
++++++++++++++
......
......@@ -23,9 +23,12 @@ env:
- PYTHON_VERSION=3.3
- PYTHON_VERSION=3.4
- PYTHON_VERSION=3.5
- PYTHON_VERSION=3.6 EVENT_TYPE='push pull_request cron'
global:
- CONDA_DEPENDENCIES="setuptools pytest sphinx cython numpy"
- PIP_DEPENDENCIES="coveralls pytest-cov"
- EVENT_TYPE='push pull_request'
matrix:
include:
......@@ -54,7 +57,7 @@ install:
# pip tries to remove the previous version of setuptools before the
# installation is complete, which causes issues. Instead, we just install
# setuptools manually.
- if [[ $SETUPTOOLS_VERSION == dev ]]; then git clone http://github.com/pypa/setuptools.git; cd setuptools; python setup.py install; cd ..; fi
- if [[ $SETUPTOOLS_VERSION == dev ]]; then git clone http://github.com/pypa/setuptools.git; cd setuptools; python bootstrap.py; python setup.py install; cd ..; fi
before_script:
# Some of the tests use git commands that require a user to be configured
......
astropy-helpers Changelog
=========================
1.2 (2016-06-19)
1.3.1 (2017-03-18)
------------------
- Fixed the missing button to hide output in documentation code
blocks. [#287]
- Fixed bug when ``build_docs`` when running with the clean (-l) option. [#289]
- Add alternative location for various intersphinx inventories to fall back
to. [#293]
1.3 (2016-12-16)
----------------
- ``build_sphinx`` has been deprecated in favor of the ``build_docs`` command.
[#246]
- Force the use of Cython's old ``build_ext`` command. A new ``build_ext``
command was added in Cython 0.25, but it does not work with astropy-helpers
currently. [#261]
1.2 (2016-06-18)
----------------
- Added sphinx configuration value ``automodsumm_inherited_members``.
......@@ -22,6 +45,7 @@ astropy-helpers Changelog
- ``astropy_helpers`` now require Sphinx 1.3 or later. [#226]
1.1.2 (2016-03-9)
-----------------
......@@ -75,7 +99,7 @@ astropy-helpers Changelog
option, the output from Sphinx is streamed as it runs instead of silently
buffering until the doc build is complete. [#197]
1.0.7 (2016-06-09)
1.0.7 (unreleased)
------------------
- Fix missing import in ``astropy_helpers/utils.py``. [#196]
......
astropy-helpers
===============
* Stable versions: https://pypi.org/project/astropy-helpers/
* Development version, issue tracker: https://github.com/astropy/astropy-helpers
This project provides a Python package, ``astropy_helpers``, which includes
many build, installation, and documentation-related tools used by the Astropy
project, but packaged separately for use by other projects that wish to
......@@ -8,6 +11,7 @@ leverage this work. The motivation behind this package and details of its
implementation are in the accepted
`Astropy Proposal for Enhancement (APE) 4 <https://github.com/astropy/astropy-APEs/blob/master/APE4.rst>`_.
``astropy_helpers`` includes a special "bootstrap" module called
``ah_bootstrap.py`` which is intended to be used by a project's setup.py in
order to ensure that the ``astropy_helpers`` package is available for
......
......@@ -36,14 +36,12 @@ install:
- git config --global user.name "A U Thor"
- git config --global user.email "author@example.com"
# For now we skip the installation of the graphviz package because the
# graphviz.org website seems to be unresponsive intermittently, which
# causes timeouts in downloads.
# - cinst graphviz.portable
# Install graphviz
- cinst graphviz.portable
# Not a .NET project, we build SunPy in the install step instead
# Not a .NET project, we build the package in the install step instead
build: false
test_script:
- "%CMD_IN_ENV% py.test"
- "%CMD_IN_ENV% py.test astropy_helpers"
......@@ -8,7 +8,6 @@ import sys
import textwrap
from distutils import log, ccompiler, sysconfig
from distutils.cmd import Command
from distutils.core import Extension
from distutils.ccompiler import get_default_compiler
from setuptools.command.build_ext import build_ext as SetuptoolsBuildExt
......@@ -48,7 +47,7 @@ def should_build_with_cython(package, release=None):
# from the repository
have_cython = False
try:
import Cython
import Cython # noqa
have_cython = True
except ImportError:
pass
......@@ -192,7 +191,10 @@ def generate_build_ext_command(packagename, release):
# We need to decide late on whether or not to use Cython's
# build_ext (since Cython may not be available earlier in the
# setup.py if it was brought in via setup_requires)
from Cython.Distutils import build_ext as base_cls
try:
from Cython.Distutils.old_build_ext import old_build_ext as base_cls
except ImportError:
from Cython.Distutils import build_ext as base_cls
else:
base_cls = SetuptoolsBuildExt
......@@ -255,8 +257,8 @@ def generate_build_ext_command(packagename, release):
if extensions:
src_path = os.path.relpath(
os.path.join(os.path.dirname(__file__), 'src'))
shutil.copy2(os.path.join(src_path, 'compiler.c'),
os.path.join(self.package_name, '_compiler.c'))
shutil.copy(os.path.join(src_path, 'compiler.c'),
os.path.join(self.package_name, '_compiler.c'))
ext = Extension(self.package_name + '._compiler',
[os.path.join(self.package_name, '_compiler.c')])
extensions.insert(0, ext)
......
......@@ -8,6 +8,7 @@ import shutil
import subprocess
import sys
import textwrap
import warnings
from distutils import log
from distutils.cmd import DistutilsOptionError
......@@ -15,15 +16,15 @@ from distutils.cmd import DistutilsOptionError
import sphinx
from sphinx.setup_command import BuildDoc as SphinxBuildDoc
from ..utils import minversion
from ..utils import minversion, AstropyDeprecationWarning
PY3 = sys.version_info[0] >= 3
class AstropyBuildSphinx(SphinxBuildDoc):
class AstropyBuildDocs(SphinxBuildDoc):
"""
A version of the ``build_sphinx`` command that uses the version of Astropy
A version of the ``build_docs`` command that uses the version of Astropy
that is built by the setup ``build`` command, rather than whatever is
installed on the system. To build docs against the installed version, run
``make html`` in the ``astropy/docs`` directory.
......@@ -69,6 +70,9 @@ class AstropyBuildSphinx(SphinxBuildDoc):
self.warnings_returncode = False
def finalize_options(self):
SphinxBuildDoc.finalize_options(self)
# Clear out previous sphinx builds, if requested
if self.clean_docs:
dirstorm = [os.path.join(self.source_dir, 'api'),
......@@ -85,8 +89,7 @@ class AstropyBuildSphinx(SphinxBuildDoc):
else:
log.info('Not cleaning directory ' + d + ' because '
'not present or not a directory')
SphinxBuildDoc.finalize_options(self)
def run(self):
# TODO: Break this method up into a few more subroutines and
......@@ -112,7 +115,7 @@ class AstropyBuildSphinx(SphinxBuildDoc):
staticdir = os.path.join(basedir, '_static')
if os.path.isfile(staticdir):
raise DistutilsOptionError(
'Attempted to build_sphinx in a location where' +
'Attempted to build_docs in a location where' +
staticdir + 'is a file. Must be a directory.')
self.mkpath(staticdir)
......@@ -186,7 +189,7 @@ class AstropyBuildSphinx(SphinxBuildDoc):
retcode = 1
with proc.stdout:
for line in iter(proc.stdout.readline, b''):
line = line.strip(b'\n')
line = line.strip(b'\r\n')
print(line.decode('utf-8'))
if 'build succeeded.' == line.decode('utf-8'):
retcode = 0
......@@ -198,11 +201,11 @@ class AstropyBuildSphinx(SphinxBuildDoc):
if os.environ.get('TRAVIS', None) == 'true':
# this means we are in the travis build, so customize
# the message appropriately.
msg = ('The build_sphinx travis build FAILED '
msg = ('The build_docs travis build FAILED '
'because sphinx issued documentation '
'warnings (scroll up to see the warnings).')
else: # standard failure message
msg = ('build_sphinx returning a non-zero exit '
msg = ('build_docs returning a non-zero exit '
'code because sphinx issued documentation '
'warnings.')
log.warn(msg)
......@@ -234,5 +237,11 @@ class AstropyBuildSphinx(SphinxBuildDoc):
sys.exit(retcode)
class AstropyBuildDocs(AstropyBuildSphinx):
description = 'alias to the build_sphinx command'
class AstropyBuildSphinx(AstropyBuildDocs): # pragma: no cover
description = 'deprecated alias to the build_docs command'
def run(self):
warnings.warn(
'The "build_sphinx" command is now deprecated. Use'
'"build_docs" instead.', AstropyDeprecationWarning)
AstropyBuildDocs.run(self)
......@@ -133,11 +133,16 @@ def get_debug_option(packagename):
def register_commands(package, version, release, srcdir='.'):
if _module_state['registered_commands'] is not None:
return _module_state['registered_commands']
if _module_state['have_sphinx']:
from .commands.build_sphinx import AstropyBuildSphinx, AstropyBuildDocs
try:
from .commands.build_sphinx import (AstropyBuildSphinx,
AstropyBuildDocs)
except ImportError:
AstropyBuildSphinx = AstropyBuildDocs = FakeBuildSphinx
else:
AstropyBuildSphinx = AstropyBuildDocs = FakeBuildSphinx
......@@ -724,7 +729,9 @@ class FakeBuildSphinx(Command):
def initialize_options(self):
try:
raise RuntimeError("Sphinx must be installed for build_sphinx")
raise RuntimeError("Sphinx and its dependencies must be installed "
"for build_docs.")
except:
log.error('error: Sphinx must be installed for build_sphinx')
log.error('error: Sphinx and its dependencies must be installed '
'for build_docs.')
sys.exit(1)
......@@ -19,7 +19,6 @@ import sphinx
from distutils.version import LooseVersion
# -- General configuration ----------------------------------------------------
# The version check in Sphinx itself can only compare the major and
......@@ -44,18 +43,24 @@ def check_sphinx_version(expected_version):
# Configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'python': ('http://docs.python.org/3/', None),
'python': ('http://docs.python.org/3/',
(None, 'http://data.astropy.org/intersphinx/python3.inv')),
'pythonloc': ('http://docs.python.org/',
path.abspath(path.join(path.dirname(__file__),
'local/python3_local_links.inv'))),
'numpy': ('http://docs.scipy.org/doc/numpy/', None),
'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None),
'matplotlib': ('http://matplotlib.org/', None),
'numpy': ('https://docs.scipy.org/doc/numpy/',
(None, 'http://data.astropy.org/intersphinx/numpy.inv')),
'scipy': ('https://docs.scipy.org/doc/scipy/reference/',
(None, 'http://data.astropy.org/intersphinx/scipy.inv')),
'matplotlib': ('http://matplotlib.org/',
(None, 'http://data.astropy.org/intersphinx/matplotlib.inv')),
'astropy': ('http://docs.astropy.org/en/stable/', None),
'h5py': ('http://docs.h5py.org/en/latest/', None)}
if sys.version_info[0] == 2:
intersphinx_mapping['python'] = ('http://docs.python.org/2/', None)
intersphinx_mapping['python'] = (
'http://docs.python.org/2/',
(None, 'http://data.astropy.org/intersphinx/python2.inv'))
intersphinx_mapping['pythonloc'] = (
'http://docs.python.org/',
path.abspath(path.join(path.dirname(__file__),
......@@ -281,7 +286,7 @@ html_last_updated_fmt = '%d %b %Y'
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
latex_use_parts = True
latex_toplevel_sectioning = 'part'
# If true, show page references after internal links.
#latex_show_pagerefs = False
......@@ -289,8 +294,10 @@ latex_use_parts = True
# If true, show URL addresses after external links.
#latex_show_urls = False
latex_elements = {}
# Additional stuff for the LaTeX preamble.
latex_preamble = r"""
latex_elements['preamble'] = r"""
% Use a more modern-looking monospace font
\usepackage{inconsolata}
......
......@@ -91,6 +91,7 @@ This extension also adds two sphinx configuration options:
# actually built.
import inspect
import io
import os
import re
import sys
......@@ -330,8 +331,9 @@ def automodapi_replace(sourcestr, app, dotoctree=True, docname=None,
ustr = newsourcestr.decode(app.config.source_encoding)
if docname is None:
with open(os.path.join(app.srcdir, 'unknown.automodapi'), 'a') as f:
f.write('\n**NEW DOC**\n\n')
with io.open(os.path.join(app.srcdir, 'unknown.automodapi'),
'a', encoding='utf8') as f:
f.write(u'\n**NEW DOC**\n\n')
f.write(ustr)
else:
env = app.builder.env
......@@ -340,7 +342,8 @@ def automodapi_replace(sourcestr, app, dotoctree=True, docname=None,
filename = docname + os.path.splitext(env.doc2path(docname))[1]
filename += '.automodapi'
with open(os.path.join(app.srcdir, filename), 'w') as f:
with io.open(os.path.join(app.srcdir, filename), 'w',
encoding='utf8') as f:
f.write(ustr)
return newsourcestr
......
from __future__ import division, absolute_import, print_function
import sys, re, inspect, textwrap, pydoc
import sys
import re
import inspect
import textwrap
import pydoc
import sphinx
import collections
from .docscrape import NumpyDocString, FunctionDoc, ClassDoc
if sys.version_info[0] >= 3:
......@@ -46,12 +51,12 @@ class SphinxDocString(NumpyDocString):
def _str_extended_summary(self):
return self['Extended Summary'] + ['']
def _str_returns(self):
def _str_returns(self, name='Returns'):
out = []
if self['Returns']:
out += self._str_field_list('Returns')
if self[name]:
out += self._str_field_list(name)
out += ['']
for param, param_type, desc in self['Returns']:
for param, param_type, desc in self[name]:
if param_type:
out += self._str_indent(['**%s** : %s' % (param.strip(),
param_type)])
......@@ -130,7 +135,7 @@ class SphinxDocString(NumpyDocString):
maxlen_0 = max(3, max([len(x[0]) for x in others]))
hdr = sixu("=")*maxlen_0 + sixu(" ") + sixu("=")*10
fmt = sixu('%%%ds %%s ') % (maxlen_0,)
out += ['', hdr]
out += ['', '', hdr]
for param, param_type, desc in others:
desc = sixu(" ").join(x.strip() for x in desc).strip()
if param_type:
......@@ -171,7 +176,7 @@ class SphinxDocString(NumpyDocString):
if len(idx) == 0:
return out
out += ['.. index:: %s' % idx.get('default','')]
out += ['.. index:: %s' % idx.get('default', '')]
for section, references in idx.items():
if section == 'default':
continue
......@@ -192,9 +197,9 @@ class SphinxDocString(NumpyDocString):
# Latex collects all references to a separate bibliography,
# so we need to insert links to it
if sphinx.__version__ >= "0.6":
out += ['.. only:: latex','']
out += ['.. only:: latex', '']
else:
out += ['.. latexonly::','']
out += ['.. latexonly::', '']
items = []
for line in self['References']:
m = re.match(r'.. \[([a-z0-9._-]+)\]', line, re.I)
......@@ -224,7 +229,8 @@ class SphinxDocString(NumpyDocString):
out += self._str_summary()
out += self._str_extended_summary()
out += self._str_param_list('Parameters')
out += self._str_returns()
out += self._str_returns('Returns')
out += self._str_returns('Yields')
for param_list in ('Other Parameters', 'Raises', 'Warns'):
out += self._str_param_list(param_list)
out += self._str_warnings()
......@@ -234,25 +240,29 @@ class SphinxDocString(NumpyDocString):
out += self._str_examples()
for param_list in ('Attributes', 'Methods'):
out += self._str_member_list(param_list)
out = self._str_indent(out,indent)
out = self._str_indent(out, indent)
return '\n'.join(out)
class SphinxFunctionDoc(SphinxDocString, FunctionDoc):
def __init__(self, obj, doc=None, config={}):
self.load_config(config)
FunctionDoc.__init__(self, obj, doc=doc, config=config)
class SphinxClassDoc(SphinxDocString, ClassDoc):
def __init__(self, obj, doc=None, func_doc=None, config={}):
self.load_config(config)
ClassDoc.__init__(self, obj, doc=doc, func_doc=None, config=config)
class SphinxObjDoc(SphinxDocString):
def __init__(self, obj, doc=None, config={}):
self._f = obj
self.load_config(config)
SphinxDocString.__init__(self, doc, config=config)
def get_doc_object(obj, what=None, doc=None, config={}):
if what is None:
if inspect.isclass(obj):
......
......@@ -10,14 +10,17 @@ It will:
- Convert Parameters etc. sections to field lists.
- Convert See Also section to a See also entry.
- Renumber references.
- Extract the signature from the docstring, if it can't be determined otherwise.
- Extract the signature from the docstring, if it can't be determined
otherwise.
.. [1] https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt
"""
from __future__ import division, absolute_import, print_function
import os, sys, re, pydoc
import sys
import re
import pydoc
import sphinx
import inspect
import collections
......@@ -37,26 +40,28 @@ else:
def mangle_docstrings(app, what, name, obj, options, lines,
reference_offset=[0]):
cfg = dict(use_plots=app.config.numpydoc_use_plots,
show_class_members=app.config.numpydoc_show_class_members,
class_members_toctree=app.config.numpydoc_class_members_toctree,
)
cfg = {'use_plots': app.config.numpydoc_use_plots,
'show_class_members': app.config.numpydoc_show_class_members,
'show_inherited_class_members':
app.config.numpydoc_show_inherited_class_members,
'class_members_toctree': app.config.numpydoc_class_members_toctree}
u_NL = sixu('\n')
if what == 'module':
# Strip top title
title_re = re.compile(sixu('^\\s*[#*=]{4,}\\n[a-z0-9 -]+\\n[#*=]{4,}\\s*'),
re.I|re.S)
lines[:] = title_re.sub(sixu(''), sixu("\n").join(lines)).split(sixu("\n"))
pattern = '^\\s*[#*=]{4,}\\n[a-z0-9 -]+\\n[#*=]{4,}\\s*'
title_re = re.compile(sixu(pattern), re.I | re.S)
lines[:] = title_re.sub(sixu(''), u_NL.join(lines)).split(u_NL)
else:
doc = get_doc_object(obj, what, sixu("\n").join(lines), config=cfg)
doc = get_doc_object(obj, what, u_NL.join(lines), config=cfg)
if sys.version_info[0] >= 3:
doc = str(doc)
else:
doc = unicode(doc)
lines[:] = doc.split(sixu("\n"))
lines[:] = doc.split(u_NL)
if app.config.numpydoc_edit_link and hasattr(obj, '__name__') and \
obj.__name__:
if (app.config.numpydoc_edit_link and hasattr(obj, '__name__') and
obj.__name__):
if hasattr(obj, '__module__'):
v = dict(full_name=sixu("%s.%s") % (obj.__module__, obj.__name__))
else:
......@@ -89,24 +94,30 @@ def mangle_docstrings(app, what, name, obj, options, lines,
reference_offset[0] += len(references)
def mangle_signature(app, what, name, obj, options, sig, retann):
# Do not try to inspect classes that don't define `__init__`
if (inspect.isclass(obj) and
(not hasattr(obj, '__init__') or
'initializes x; see ' in pydoc.getdoc(obj.__init__))):
'initializes x; see ' in pydoc.getdoc(obj.__init__))):
return '', ''
if not (isinstance(obj, collections.Callable) or hasattr(obj, '__argspec_is_invalid_')): return
if not hasattr(obj, '__doc__'): return
if not (isinstance(obj, collections.Callable) or
hasattr(obj, '__argspec_is_invalid_')):
return
if not hasattr(obj, '__doc__'): <