From 693a4f2063952d1c0cbfaf89521687e3f4dac2b7 Mon Sep 17 00:00:00 2001 From: Nicholas Earl Date: Mon, 2 Nov 2020 13:09:59 -0600 Subject: [PATCH] Update template to latest --- .gitignore | 3 + .travis.yml | 43 +++++++++----- docs/conf.py | 16 +++++- licenses/LICENSE.rst | 45 +++++++-------- licenses/README.rst | 2 +- licenses/TEMPLATE_LICENCE.rst | 4 +- specutils/__init__.py | 2 +- specutils/_astropy_init.py | 6 +- specutils/conftest.py | 102 +++++++++++++++++----------------- tox.ini | 6 +- 10 files changed, 129 insertions(+), 100 deletions(-) diff --git a/.gitignore b/.gitignore index bc8f81b74..c5cab7903 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,9 @@ docs/_build .floo .flooignore +# Visual Studio Code project files +.vscode + # Packages/installer info *.egg *.egg-info diff --git a/.travis.yml b/.travis.yml index 656bd2dae..4ec54e64a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -120,13 +120,6 @@ matrix: stage: Comprehensive tests env: TOXENV=py37-test-astropy30-numpy117 - # Run tests using external dependencies to e.g. check specific loaders - - os: linux - python: 3.8 - name: External dependencies - stage: Comprehensive tests - env: TOXENV=py38-test-external - # Do a code style check - os: linux python: 3.8 @@ -134,6 +127,17 @@ matrix: stage: Initial tests env: TOXENV=codestyle + # Run documentation link check in a cron job. + - language: python + python: 3.8 + name: Documentation link check + stage: Cron tests + env: TOXENV=linkcheck + addons: + apt: + packages: + - graphviz + allow_failures: # Do a PEP8 test with flake8 # (do allow to fail unless your code completely compliant) @@ -143,6 +147,13 @@ matrix: # stage: Initial tests # env: TOXENV=codestyle + +before_install: + # Create a coverage.xml for use by coveralls or codecov + - if [[ $TOXENV == *-cov ]]; then + export TOXPOSARGS=$TOXPOSARGS" --cov-report=xml:"$TRAVIS_BUILD_DIR"/coverage.xml"; + fi + install: # We now use the ci-helpers package to set up our Python environment @@ -152,7 +163,7 @@ install: - if [[ $TRAVIS_OS_NAME != linux ]]; then git clone --depth 1 git://github.com/astropy/ci-helpers.git; - source ci-helpers/travis/setup_conda.sh; + source ci-helpers/travis/setup_python.sh; fi script: @@ -161,9 +172,13 @@ script: - tox $TOXARGS -- $TOXPOSARGS after_success: - # If coveralls.io is set up for this package, uncomment the two lines below. - # pip install coveralls - # coveralls - # If codecov is set up for this package, uncomment the two lines below - # pip install codecov - # codecov + # if either coveralls or codecov is used, uncomment the if and fi statements + # and the appropriate two lines inside the if statement + # - if [[ $TOXENV == *-cov ]]; then + # # If coveralls.io is set up for this package, uncomment the two lines below. + # pip install coveralls; + # coveralls; + # # If codecov is set up for this package, uncomment the two lines below + # pip install codecov; + # codecov; + # fi diff --git a/docs/conf.py b/docs/conf.py index 6fd4e16f7..5357f8699 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -52,7 +52,7 @@ #needs_sphinx = '1.2' # To perform a Sphinx version check that needs to be more specific than -# major.minor, call `check_sphinx_version("x.y.z")` here. +# major.minor, call `check_sphinx_version("X.Y.Z")` here. # check_sphinx_version("1.2.1") # Include other packages to link against @@ -142,6 +142,9 @@ # Output file base name for HTML help builder. htmlhelp_basename = project + 'doc' +# Prefixes that are ignored for sorting the Python module index +modindex_common_prefix = ["specutils."] + # -- Options for LaTeX output ------------------------------------------------- @@ -174,6 +177,15 @@ # -- Resolving issue number to links in changelog ----------------------------- github_issues_url = 'https://github.com/{0}/issues/'.format(setup_cfg['github_project']) + +# -- Options for linkcheck output ------------------------------------------- +linkcheck_retry = 5 +linkcheck_ignore = [ + r'https://github\.com/astropy/specutils/(?:issues|pull)/\d+', +] +linkcheck_timeout = 180 +linkcheck_anchors = False + # -- Turn on nitpicky mode for sphinx (to warn about references not found) ---- # nitpicky = True @@ -198,4 +210,4 @@ continue dtype, target = line.split(None, 1) target = target.strip() - nitpick_ignore.append((dtype, target)) + nitpick_ignore.append((dtype, six.u(target))) diff --git a/licenses/LICENSE.rst b/licenses/LICENSE.rst index 8b09e9b11..0c120c834 100644 --- a/licenses/LICENSE.rst +++ b/licenses/LICENSE.rst @@ -1,25 +1,26 @@ -Copyright (c) 2020, Specutils Developers -All rights reserved. +Copyright 2020 Specutils Developers -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. -* Neither the name of the Astropy Team nor the names of its contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/licenses/README.rst b/licenses/README.rst index 67b82f693..fa84ca8e1 100644 --- a/licenses/README.rst +++ b/licenses/README.rst @@ -4,6 +4,6 @@ Licenses This directory holds license and credit information for the package, works the package is derived from, and/or datasets. -Ensure that you pick a package licence which is in this folder and it matches +Ensure that you pick a package license which is in this folder and it matches the one mentioned in the top level README.rst file. If you are using the pre-rendered version of this template check for the word 'Other' in the README. diff --git a/licenses/TEMPLATE_LICENCE.rst b/licenses/TEMPLATE_LICENCE.rst index f29177b0b..a460a728f 100644 --- a/licenses/TEMPLATE_LICENCE.rst +++ b/licenses/TEMPLATE_LICENCE.rst @@ -1,6 +1,6 @@ This project is based upon the Astropy package template -(https://github.com/astropy/package-template/) which is licenced under the terms -of the following licence. +(https://github.com/astropy/package-template/) which is licensed under the terms +of the following license. --- diff --git a/specutils/__init__.py b/specutils/__init__.py index 7c5bf6189..457f920b3 100644 --- a/specutils/__init__.py +++ b/specutils/__init__.py @@ -6,7 +6,7 @@ # Packages may add whatever they like to this file, but # should keep this content at the top. # ---------------------------------------------------------------------------- -from ._astropy_init import * +from ._astropy_init import * # noqa from astropy import config as _config # ---------------------------------------------------------------------------- diff --git a/specutils/_astropy_init.py b/specutils/_astropy_init.py index 0c81000b7..2dffe8fd0 100644 --- a/specutils/_astropy_init.py +++ b/specutils/_astropy_init.py @@ -6,11 +6,7 @@ try: _ASTROPY_SETUP_ except NameError: - from sys import version_info - if version_info[0] >= 3: - import builtins - else: - import __builtin__ as builtins + import builtins builtins._ASTROPY_SETUP_ = False try: diff --git a/specutils/conftest.py b/specutils/conftest.py index 9e26a147c..057c7a37b 100644 --- a/specutils/conftest.py +++ b/specutils/conftest.py @@ -1,57 +1,55 @@ -# this contains imports plugins that configure py.test for astropy tests. -# by importing them here in conftest.py they are discoverable by py.test -# no matter how it is invoked within the source tree. +# This file is used to configure the behavior of pytest when using the Astropy +# test infrastructure. It needs to live inside the package in order for it to +# get picked up when running the tests inside an interpreter using +# packagename.test -from importlib.util import find_spec +import os from astropy.version import version as astropy_version -from astropy.tests.plugins.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS -from astropy.tests.helper import enable_deprecations_as_exceptions - -## Uncomment the following line to treat all DeprecationWarnings as -## exceptions -enable_deprecations_as_exceptions() -# Uncomment and customize the following lines to add/remove entries from -# the list of packages for which version numbers are displayed when running -# the tests. Making it pass for KeyError is essential in some cases when -# the package uses other astropy affiliated packages. -try: - PYTEST_HEADER_MODULES['Astropy'] = 'astropy' - PYTEST_HEADER_MODULES['gwcs'] = 'gwcs' - del PYTEST_HEADER_MODULES['h5py'] - del PYTEST_HEADER_MODULES['Pandas'] - del PYTEST_HEADER_MODULES['Matplotlib'] -except (NameError, KeyError): # NameError is needed to support Astropy < 1.0 - pass - -# Use ASDF schema tester plugin if ASDF is installed -if find_spec('asdf') is not None: - PYTEST_HEADER_MODULES['Asdf'] = 'asdf' - -# Uncomment the following lines to display the version number of the -# package rather than the version number of Astropy in the top line when -# running the tests. -import os - -# This is to figure out the affiliated package version, rather than -# using Astropy's -try: - from .version import version -except ImportError: - version = 'dev' - -try: - packagename = os.path.basename(os.path.dirname(__file__)) - TESTED_VERSIONS[packagename] = version -except NameError: # Needed to support Astropy <= 1.0.0 - pass - - -# makes sure matplotlib doesn't try to pop up plots -try: - import matplotlib -except ImportError: - pass +# For Astropy 3.0 and later, we can use the standalone pytest plugin +if astropy_version < '3.0': + from astropy.tests.pytest_plugins import * # noqa + del pytest_report_header + ASTROPY_HEADER = True else: - matplotlib.use('Agg') + try: + from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS + ASTROPY_HEADER = True + except ImportError: + ASTROPY_HEADER = False + + +def pytest_configure(config): + + if ASTROPY_HEADER: + + config.option.astropy_header = True + + # Customize the following lines to add/remove entries from the list of + # packages for which version numbers are displayed when running the tests. + PYTEST_HEADER_MODULES.pop('Pandas', None) + PYTEST_HEADER_MODULES['gwcs'] = 'gwcs' + del PYTEST_HEADER_MODULES['h5py'] + del PYTEST_HEADER_MODULES['Matplotlib'] + # Use ASDF schema tester plugin if ASDF is installed + from importlib.util import find_spec + if find_spec('asdf') is not None: + PYTEST_HEADER_MODULES['Asdf'] = 'asdf' + + from . import __version__ + packagename = os.path.basename(os.path.dirname(__file__)) + TESTED_VERSIONS[packagename] = __version__ + +# Uncomment the last two lines in this block to treat all DeprecationWarnings as +# exceptions. For Astropy v2.0 or later, there are 2 additional keywords, +# as follow (although default should work for most cases). +# To ignore some packages that produce deprecation warnings on import +# (in addition to 'compiler', 'scipy', 'pygments', 'ipykernel', and +# 'setuptools'), add: +# modules_to_ignore_on_import=['module_1', 'module_2'] +# To ignore some specific deprecation warning messages for Python version +# MAJOR.MINOR or later, add: +# warnings_to_ignore_by_pyver={(MAJOR, MINOR): ['Message to ignore']} +from astropy.tests.helper import enable_deprecations_as_exceptions # noqa +enable_deprecations_as_exceptions() diff --git a/tox.ini b/tox.ini index 5b61276af..d1a60cd0c 100644 --- a/tox.ini +++ b/tox.ini @@ -11,9 +11,13 @@ requires = setuptools >= 30.3.0 pip >= 19.3.1 isolated_build = true +indexserver = + NIGHTLY = https://pypi.anaconda.org/scipy-wheels-nightly/simple [testenv] +# Suppress display of matplotlib plots generated during docs build setenv = + MPLBACKEND=agg # Disable the accelerate linear algebra library when running on macos as # latest numpy versions do not work with it NPY_BLAS_ORDER= @@ -59,7 +63,7 @@ deps = astropy40: astropy==4.0.* astropylts: astropy==4.0.* - devdeps: git+https://github.com/numpy/numpy.git#egg=numpy + devdeps: :NIGHTLY:numpy devdeps: git+https://github.com/astropy/astropy.git#egg=astropy external: asdf