From 02bce76dbe17884b715a4a1d92589dd0193d90fd Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Tue, 14 Jan 2020 20:36:57 -0700 Subject: [PATCH] Squash commits for rebase on master --- .gitignore | 1 + .travis.yml | 17 ++++++-- licenses/LICENSE.rst => LICENSE.rst | 0 MANIFEST.in | 12 ++++-- README.rst | 44 ++++++++------------ docs/conf.py | 12 ++---- docs/licenses.rst | 2 +- licenses/README.rst | 5 --- pydl/conftest.py | 63 +++++++++++++---------------- pydl/setup_package.py | 18 --------- pyproject.toml | 5 +++ setup.cfg | 46 ++++++++++++--------- setup.py | 34 +++++++--------- tox.ini | 31 ++++++++++++++ 14 files changed, 149 insertions(+), 141 deletions(-) rename licenses/LICENSE.rst => LICENSE.rst (100%) delete mode 100644 licenses/README.rst delete mode 100644 pydl/setup_package.py create mode 100644 pyproject.toml create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 2a4f9ff5..fe0f57b1 100644 --- a/.gitignore +++ b/.gitignore @@ -54,6 +54,7 @@ distribute-*.tar.gz # Other .cache +.tmp .tox .*.sw[op] *~ diff --git a/.travis.yml b/.travis.yml index d86fa95d..4e7639f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,11 @@ language: c os: - linux +# Disable cloning with --depth=50 (the default). This should grab the tags +# needed for setuptools_scm to work. +git: + depth: false + # The apt packages below are needed for sphinx builds. A full list of packages # that can be included can be found here: # @@ -45,8 +50,8 @@ env: # For this package-template, we include examples of Cython modules, # so Cython is required for testing. If your package does not include # Cython code, you can set CONDA_DEPENDENCIES='' - - CONDA_DEPENDENCIES='scipy matplotlib pytest-mock' - - CONDA_DEPENDENCIES_DOC='scipy matplotlib sphinx-astropy' + - CONDA_DEPENDENCIES='tox setuptools_scm scipy matplotlib pytest-mock' + - CONDA_DEPENDENCIES_DOC='tox setuptools_scm scipy matplotlib sphinx-astropy' # List other runtime dependencies for the package that are available as # pip packages here. @@ -92,15 +97,19 @@ matrix: # Check for sphinx doc build warnings - we do this first because it # may run for a long time - os: linux - env: SETUP_CMD='build_docs -w' + env: MAIN_CMD='tox -e' + SETUP_CMD='build_docs' CONDA_DEPENDENCIES=$CONDA_DEPENDENCIES_DOC + # env: MAIN_CMD='sphinx-build' + # SETUP_CMD='docs docs/_build/html -W --keep-going -b html' + # CONDA_DEPENDENCIES=$CONDA_DEPENDENCIES_DOC # Now try Astropy dev with the latest Python and LTS with and 3.x. - os: linux env: ASTROPY_VERSION=development EVENT_TYPE='pull_request push cron' - os: linux - env: PYTHON_VERSION=3.6 ASTROPY_VERSION=lts NUMPY_VERSION=1.14 PYTEST_VERSION='<3.7' + env: PYTHON_VERSION=3.6 ASTROPY_VERSION=2.0.16 NUMPY_VERSION=1.14 PYTEST_VERSION='<3.7' # Add a job that runs from cron only and tests against astropy dev and # numpy dev to give a change for early discovery of issues and feedback diff --git a/licenses/LICENSE.rst b/LICENSE.rst similarity index 100% rename from licenses/LICENSE.rst rename to LICENSE.rst diff --git a/MANIFEST.in b/MANIFEST.in index aabb3e62..5ad372c8 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,15 +1,19 @@ include README.rst +include LICENSE.rst # include CHANGES.rst include ah_bootstrap.py +include pyproject.toml include setup.cfg include pydl/tests/coveragerc -recursive-include pydl *.pyx *.c *.pxd +# recursive-include pydl *.pyx *.c *.pxd recursive-include docs * -recursive-include licenses * -recursive-include cextern * -recursive-include scripts * +recursive-include pydl/*/data/* * +recursive-include pydl/tests/t * +recursive-include pydl/*/tests/t * +# recursive-include cextern * +# recursive-include scripts * prune build prune docs/_build diff --git a/README.rst b/README.rst index af550751..443ff5e7 100644 --- a/README.rst +++ b/README.rst @@ -6,6 +6,10 @@ PyDL :target: http://www.astropy.org :alt: Powered by Astropy Badge +.. image:: https://img.shields.io/pypi/l/pydl.svg + :target: https://pypi.python.org/pypi/pydl + :alt: License + .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.2575874.svg :target: https://doi.org/10.5281/zenodo.2575874 :alt: DOI: 10.5281/zenodo.2575874 @@ -14,6 +18,18 @@ PyDL :target: https://pypi.python.org/pypi/pydl :alt: PyPI Badge +.. image:: https://img.shields.io/travis/weaverba137/pydl.svg + :target: https://travis-ci.org/weaverba137/pydl + :alt: Travis Build Status + +.. image:: https://coveralls.io/repos/weaverba137/pydl/badge.svg?branch=master&service=github + :target: https://coveralls.io/github/weaverba137/pydl?branch=master + :alt: Test Coverage Status + +.. image:: https://readthedocs.org/projects/pydl/badge/?version=latest + :target: http://pydl.readthedocs.org/en/latest/ + :alt: Documentation Status + Description ----------- @@ -36,11 +52,6 @@ Full Documentation Please visit `PyDL on Read the Docs`_ -.. image:: https://readthedocs.org/projects/pydl/badge/?version=latest - :target: http://pydl.readthedocs.org/en/latest/ - :alt: Documentation Status - - History ------- @@ -48,32 +59,11 @@ This package was initially developed on the SDSS-III_ `svn repository`_. It was moved to the new GitHub_ repository on 2013-03-06. The present location of the repository is http://github.com/weaverba137/pydl . - -Travis Build Status -------------------- - -.. image:: https://img.shields.io/travis/weaverba137/pydl.svg - :target: https://travis-ci.org/weaverba137/pydl - :alt: Travis Build Status - - -Test Coverage Status --------------------- - -.. image:: https://coveralls.io/repos/weaverba137/pydl/badge.svg?branch=master&service=github - :target: https://coveralls.io/github/weaverba137/pydl?branch=master - :alt: Test Coverage Status - - License ------- -.. image:: https://img.shields.io/pypi/l/pydl.svg - :target: https://pypi.python.org/pypi/pydl - :alt: License PyDL is free software licensed under a 3-clause BSD-style license. For details see -the ``licenses/LICENSE.rst`` file. - +the ``LICENSE.rst`` file. Legal ----- diff --git a/docs/conf.py b/docs/conf.py index 0dc9640e..6d0a6188 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -28,7 +28,7 @@ import os import sys import datetime -from importlib import import_module +from pkg_resources import get_distribution try: from sphinx_astropy.conf.v1 import * # noqa @@ -76,13 +76,9 @@ # |version| and |release|, also used in various other places throughout the # built documents. -import_module(setup_cfg['name']) -package = sys.modules[setup_cfg['name']] - -# The short X.Y version. -version = package.__version__.split('-', 1)[0] -# The full version, including alpha/beta/rc tags. -release = package.__version__ +release = get_distribution(setup_cfg['name']).version +# for example take major/minor +version = '.'.join(release.split('.')[:2]) # -- Options for HTML output -------------------------------------------------- diff --git a/docs/licenses.rst b/docs/licenses.rst index d7d746c3..e8eed3b9 100644 --- a/docs/licenses.rst +++ b/docs/licenses.rst @@ -7,7 +7,7 @@ PyDL License PyDL is licensed under a 3-clause BSD style license: -.. include:: ../licenses/LICENSE.rst +.. include:: ../LICENSE.rst .. Other Licenses .. ============== diff --git a/licenses/README.rst b/licenses/README.rst deleted file mode 100644 index 20c7cd4d..00000000 --- a/licenses/README.rst +++ /dev/null @@ -1,5 +0,0 @@ -Licenses -======== - -This directory holds license and credit information for the affiliated package, -works the affiliated package is derived from, and/or datasets. diff --git a/pydl/conftest.py b/pydl/conftest.py index f7490bf8..8cd90036 100644 --- a/pydl/conftest.py +++ b/pydl/conftest.py @@ -1,17 +1,24 @@ +# Licensed under a 3-clause BSD style license - see LICENSE.rst +# -*- coding: utf-8 -*- +# # This file is used to configure the behavior of pytest when using the Astropy # test infrastructure. +# +import os from astropy.version import version as astropy_version if astropy_version < '3.0': + # # With older versions of Astropy, we actually need to import the pytest # plugins themselves in order to make them discoverable by pytest. + # from astropy.tests.pytest_plugins import * + del pytest_report_header else: - # As of Astropy 3.0, the pytest plugins provided by Astropy are - # automatically made available when Astropy is installed. This means it's - # not necessary to import them here, but we still need to import global - # variables that are used for configuration. - from astropy.tests.plugins.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS + # As of Astropy 4.0, the pytest plugins provided by Astropy are + # now in the pytest-astropy-header package. This is backward-compatible + # with Astropy 3. + from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS from astropy.tests.helper import enable_deprecations_as_exceptions @@ -27,38 +34,24 @@ ## warnings_to_ignore_by_pyver={(MAJOR, MINOR): ['Message to ignore']} # 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: +def pytest_configure(config): + + 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['Astropy'] = 'astropy' PYTEST_HEADER_MODULES['PyDL'] = 'pydl' - try: - del PYTEST_HEADER_MODULES['h5py'] - except KeyError: - pass - try: - del PYTEST_HEADER_MODULES['Pandas'] - except KeyError: - pass -except (NameError, KeyError): # NameError is needed to support Astropy < 1.0 - pass - -## 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 package version, rather than -## using Astropy's -try: - from .version import version -except ImportError: - version = 'dev' + PYTEST_HEADER_MODULES.pop('Pandas', None) + PYTEST_HEADER_MODULES.pop('h5py', None) -try: + from .version import version #, astropy_helpers_version packagename = os.path.basename(os.path.dirname(__file__)) + # + # Display the version number of the package rather than the version number + # of Astropy in the top line when running the tests. + # TESTED_VERSIONS[packagename] = version -except NameError: # Needed to support Astropy <= 1.0.0 - pass + # TESTED_VERSIONS['astropy_helpers'] = astropy_helpers_version diff --git a/pydl/setup_package.py b/pydl/setup_package.py deleted file mode 100644 index a8173b2b..00000000 --- a/pydl/setup_package.py +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed under a 3-clause BSD style license -# -*- coding: utf-8 -*- - - -def get_package_data(): - # Installs the testing data files. Unable to get package_data - # to deal with a directory hierarchy of files, so just explicitly list. - return { - 'pydl.tests': ['coveragerc', 't/*'], - 'pydl.photoop.tests': ['t/*'], - 'pydl.pydlspec2d.tests': ['t/*'], - 'pydl.pydlutils': ['data/cooling/*', 'data/filters/*'], - 'pydl.pydlutils.tests': ['t/*'], - } - - -# def requires_2to3(): -# return False diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..0889579c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,5 @@ +[build-system] +requires = ["setuptools", + "setuptools_scm", + "wheel"] +build-backend = 'setuptools.build_meta' diff --git a/setup.cfg b/setup.cfg index b0596b89..2ce976c7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,28 +1,19 @@ [metadata] name = pydl # version should be PEP440 compatible (http://www.python.org/dev/peps/pep-0440) -version = 1.0.0.dev +# version = 1.0.0.dev author = Benjamin Alan Weaver author_email = baweaver@lbl.gov description = Astropy affiliated package -long_description = ==== - pydl - ==== - - Python replacements for functions that are part of the IDL_ built-in library, or - part of astronomical IDL libraries. The emphasis is on reproducing results of - the astronomical library functions. Only the bare minimum of IDL_ built-in - functions are implemented to support this. - - .. _IDL: http://www.harrisgeospatial.com/SoftwareTechnology/IDL.aspx - -license = BSD +long_description = file: README.rst +license = BSD 3-Clause License url = http://github.com/weaverba137/pydl edit_on_github = False github_project = weaverba137/pydl # Note: you will also need to change this in your package's __init__.py python_requires = ">=3.5" -classifiers = Development Status :: 5 - Production/Stable +classifiers = + Development Status :: 5 - Production/Stable Environment :: Console Intended Audience :: Science/Research License :: OSI Approved :: BSD License @@ -34,22 +25,39 @@ classifiers = Development Status :: 5 - Production/Stable [options] # install_requires should be formatted as a semicolon-separated list, e.g.: # install_requires = astropy; scipy; matplotlib -install_requires = astropy; scipy; matplotlib +setup_requires = + setuptools_scm +install_requires = + astropy + scipy + matplotlib zip_safe = False use_2to3 = False +packages = find: +include_package_data = True [options.entry_points] console_scripts = - get_juldate = pydl.goddard.astro:get_juldate_main hogg_iau_name = pydl.pydlutils.misc:hogg_iau_name_main compute_templates = pydl.pydlspec2d.spec1d:template_input_main +[options.extras_require] +test = + pytest-astropy + pytest-mock + pytest-cov +docs = + sphinx-astropy # [options.package_data] # * = *.c -# packagename = data/* -# packagename.tests = coveragerc +# pydl.tests = coveragerc, t/* +# pydl.goddard.tests = t/* +# pydl.photoop.tests = t/* +# pydl.pydlspec2d.tests = t/* +# pydl.pydlutils = data/cooling/*, data/filters/* +# pydl.pydlutils.tests = t/* [build_sphinx] source-dir = docs @@ -69,7 +77,7 @@ show-response = 1 minversion = 3.0 norecursedirs = build docs/_build doctest_plus = enabled -addopts = -p no:warnings +addopts = -p no:warnings --doctest-rst [ah_bootstrap] auto_use = True diff --git a/setup.py b/setup.py index c7715256..b7a2ea34 100755 --- a/setup.py +++ b/setup.py @@ -1,33 +1,27 @@ #!/usr/bin/env python - +# -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst -import builtins +# Needed to import local helpers when pyproject.toml exists. +import sys +sys.path.append(".") # Ensure that astropy-helpers is available import ah_bootstrap # noqa from setuptools import setup -from setuptools.config import read_configuration - -from astropy_helpers.setup_helpers import register_commands, get_package_info -from astropy_helpers.version_helpers import generate_version_py -# Store the package name in a built-in variable so it's easy -# to get from other parts of the setup infrastructure -builtins._ASTROPY_PACKAGE_NAME_ = read_configuration('setup.cfg')['metadata']['name'] +from astropy_helpers.setup_helpers import register_commands +# from distutils.command.sdist import sdist as DistutilsSdist # Create a dictionary with setup command overrides. Note that this gets # information about the package (name and version) from the setup.cfg file. cmdclass = register_commands() - -# Freeze build information in version.py. Note that this gets information -# about the package (name and version) from the setup.cfg file. -version = generate_version_py() - -# Get configuration information from all of the various subpackages. -# See the docstring for setup_helpers.update_package_files for more -# details. -package_info = get_package_info() - -setup(version=version, cmdclass=cmdclass, **package_info) +# cmdclass = {'sdist': DistutilsSdist} +cmdclass.pop('build_sphinx', None) +cmdclass.pop('build_docs', None) +# cmdclass.pop('sdist', None) +cmdclass.pop('build_ext', None) +# print(cmdclass) + +setup(use_scm_version={"write_to": "pydl/version.py"}, cmdclass=cmdclass) diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..e6b5e480 --- /dev/null +++ b/tox.ini @@ -0,0 +1,31 @@ +[tox] +requires = + setuptools >= 30.3.0 + pip >= 19.3.1 + setuptools_scm +# isolated_build = true + +[testenv] +extras = test +changedir = + test: .tmp/{envname} + +[testenv:test] +commands = + pytest --pyargs pydl {toxinidir}/docs {posargs} + +[testenv:coverage] +requires = + pytest-cov + coverage +commands = + pytest --cov pydl + +[testenv:build_docs] +description = Invoke sphinx-build to build the HTML docs. +extras = docs +# setenv = +# HOME = {envtmpdir} +changedir = docs +commands = + sphinx-build . ./_build/html -W --keep-going -b html {posargs}