From d992f45690edb2ffe28c678c8ae64252f821da71 Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 09:06:48 -0400 Subject: [PATCH 01/17] Move configuration to pyproject.toml --- pyproject.toml | 142 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 139 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0889579..fea6bcf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,141 @@ +[project] +name = 'lacosmic' +description = 'Laplacian Cosmic Ray Identification' +readme = 'README.rst' +license = {file = 'LICENSE.rst'} +authors = [ + {name = 'Larry Bradley', email = 'larry.bradley@gmail.com'}, +] +keywords = [ + 'astronomy', + 'astrophysics', + 'images', + 'cosmic rays', + 'cosmic-ray removal', + 'filtering', +] +classifiers = [ + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: BSD License', + 'Natural Language :: English', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Topic :: Scientific/Engineering :: Astronomy', +] +dynamic = ['version'] +requires-python = '>=3.9' +dependencies = [ + 'numpy>=1.22', + 'astropy>=5.0', + 'scipy>=1.7.2', +] + +[project.urls] +Homepage = 'https://github.com/larrybradley/lacosmic' +Documentation = 'https://lacosmic.readthedocs.io/en/stable/' + +[project.optional-dependencies] +all = [ + 'matplotlib>=3.5', +] +test = [ + 'pytest-astropy>=0.10', +] +docs = [ + 'lacosmic[all]', + 'sphinx', + 'sphinx-astropy>=1.6', + 'tomli; python_version < "3.11"', +] + [build-system] -requires = ["setuptools", - "setuptools_scm", - "wheel"] +requires = [ + 'setuptools>=61.2', + 'setuptools_scm>=6.2', +] build-backend = 'setuptools.build_meta' + +[tool.setuptools_scm] +write_to = 'lacosmic/version.py' + +[tool.setuptools] +zip-safe = false +include-package-data = false + +[tool.setuptools.packages.find] +namespaces = false + +[tool.setuptools.package-data] +'lacosmic' = [ + 'data/*', +] + +[tool.pytest.ini_options] +minversion = 7.0 +testpaths = [ + 'lacosmic', + 'docs', +] +norecursedirs = [ + 'docs/_build', + 'extern', +] +astropy_header = true +doctest_plus = 'enabled' +text_file_format = 'rst' +addopts = '--color=yes --doctest-rst' +xfail_strict = true +remote_data_strict = true +filterwarnings = [ + 'ignore:numpy.ufunc size changed:RuntimeWarning', +] + +[tool.coverage.run] +omit = [ + 'lacosmic/_astropy_init*', + 'lacosmic/conftest.py', + 'lacosmic/*setup_package*', + 'lacosmic/tests/*', + 'lacosmic/*/tests/*', + 'lacosmic/extern/*', + 'lacosmic/version*', + '*/lacosmic/_astropy_init*', + '*/lacosmic/conftest.py', + '*/lacosmic/*setup_package*', + '*/lacosmic/tests/*', + '*/lacosmic/*/tests/*', + '*/lacosmic/extern/*', + '*/lacosmic/version*', +] + +[tool.coverage.report] +exclude_lines = [ + 'pragma: no cover', + 'except ImportError', + 'raise AssertionError', + 'raise NotImplementedError', + 'def main\\(.*\\):', + 'pragma: py{ignore_python_version}', + 'def _ipython_key_completions_', +] + +[tool.build-sphinx] +github_project = 'spacetelescope/lacosmic' + +[tool.isort] +skip_glob = [ + 'lacosmic/*__init__.py*', +] +known_first_party = [ + 'lacosmic', + 'extension_helpers', +] +use_parentheses = true + +[tool.black] +force-exclude = """ +( + .* +) +""" From ae422611b5e68e0bacc9714e83567e2ba6b16035 Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 09:06:58 -0400 Subject: [PATCH 02/17] Remove setup files --- setup.cfg | 85 ------------------------------------------------------- setup.py | 78 -------------------------------------------------- 2 files changed, 163 deletions(-) delete mode 100644 setup.cfg delete mode 100755 setup.py diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 8654f39..0000000 --- a/setup.cfg +++ /dev/null @@ -1,85 +0,0 @@ -[metadata] -name = lacosmic -author = Larry Bradley -author_email = larry.bradley@gmail.com -license = BSD 3-Clause -license_file = LICENSE.rst -url = https://github.com/larrybradley/lacosmic -github_project = larrybradley/lacosmic -edit_on_github = False -description = Laplacian Cosmic Ray Identification -long_description = file: README.rst -long_description_content_type = text/x-rst -keywords = astronomy, astrophysics, images, cosmic rays -classifiers = - Intended Audience :: Science/Research - License :: OSI Approved :: BSD License - Natural Language :: English - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3 - Topic :: Scientific/Engineering :: Astronomy - -[options] -zip_safe = False -packages = find: -python_requires = >=3.8 -setup_requires = setuptools_scm -install_requires = - astropy>=4.1 - numpy>=1.18 - scipy>=1.6.0 - -[options.extras_require] -test = - pytest-astropy -docs = - sphinx - sphinx-astropy - matplotlib>=3.1 - -[options.package_data] -lacosmic = data/* - -[tool:pytest] -testpaths = "lacosmic" "docs" -norecursedirs = "docs[\/]_build" "docs[\/]generated" "lacosmic[\/]extern" -astropy_header = true -doctest_plus = enabled -text_file_format = rst -addopts = --doctest-rst -filterwarnings = - ignore:numpy.ufunc size changed:RuntimeWarning - -[coverage:run] -omit = - lacosmic/_astropy_init* - lacosmic/conftest.py - lacosmic/*setup_package* - lacosmic/tests/* - lacosmic/*/tests/* - lacosmic/extern/* - lacosmic/version* - */lacosmic/_astropy_init* - */lacosmic/conftest.py - */lacosmic/*setup_package* - */lacosmic/tests/* - */lacosmic/*/tests/* - */lacosmic/extern/* - */lacosmic/version* - -[coverage:report] -exclude_lines = - # Have to re-enable the standard pragma - pragma: no cover - # Don't complain about packages we have installed - except ImportError - # Don't complain if tests don't hit assertions - raise AssertionError - raise NotImplementedError - # Don't complain about script hooks - def main\(.*\): - # Ignore branches that don't pertain to this version of Python - pragma: py{ignore_python_version} - # Don't complain about IPython completion helper - def _ipython_key_completions_ diff --git a/setup.py b/setup.py deleted file mode 100755 index c2760d1..0000000 --- a/setup.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python -# Licensed under a 3-clause BSD style license - see LICENSE.rst - -# NOTE: The configuration for the package, including the name, version, and -# other information are set in the setup.cfg file. - -import os -import sys - -from setuptools import setup - - -# First provide helpful messages if contributors try and run legacy commands -# for tests or docs. - -TEST_HELP = """ -Note: running tests is no longer done using 'python setup.py test'. Instead -you will need to run: - - tox -e test - -If you don't already have tox installed, you can install it with: - - pip install tox - -If you only want to run part of the test suite, you can also use pytest -directly with:: - - pip install -e .[test] - pytest - -For more information, see: - - http://docs.astropy.org/en/latest/development/testguide.html#running-tests -""" - -if 'test' in sys.argv: - print(TEST_HELP) - sys.exit(1) - -DOCS_HELP = """ -Note: building the documentation is no longer done using -'python setup.py build_docs'. Instead you will need to run: - - tox -e build_docs - -If you don't already have tox installed, you can install it with: - - pip install tox - -You can also build the documentation with Sphinx directly using:: - - pip install -e .[docs] - cd docs - make html - -For more information, see: - - http://docs.astropy.org/en/latest/install.html#builddocs -""" - -if 'build_docs' in sys.argv or 'build_sphinx' in sys.argv: - print(DOCS_HELP) - sys.exit(1) - -VERSION_TEMPLATE = """ -# Note that we need to fall back to the hard-coded version if either -# setuptools_scm can't be imported or setuptools_scm can't determine the -# version, so we catch the generic 'Exception'. -try: - from setuptools_scm import get_version - version = get_version(root='..', relative_to=__file__) -except Exception: - version = '{version}' -""".lstrip() - -setup(use_scm_version={'write_to': os.path.join('lacosmic', 'version.py'), - 'write_to_template': VERSION_TEMPLATE}) From 2325eaec9f854155ad08e8db660f6d8404241454 Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 09:08:05 -0400 Subject: [PATCH 03/17] Update RTD config --- .readthedocs.yml => .readthedocs.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) rename .readthedocs.yml => .readthedocs.yaml (61%) diff --git a/.readthedocs.yml b/.readthedocs.yaml similarity index 61% rename from .readthedocs.yml rename to .readthedocs.yaml index b9cf008..58c10a1 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yaml @@ -5,7 +5,12 @@ build: apt_packages: - graphviz tools: - python: "3.10" + python: "3.11" + jobs: + post_checkout: + - git fetch --shallow-since=2022-04-01 || true + pre_install: + - git update-index --assume-unchanged docs/conf.py sphinx: builder: html From c412c5e971e0da90cbb7191a52b5f93092ce1e16 Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 09:08:33 -0400 Subject: [PATCH 04/17] Update .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e16eaf8..003dafd 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,7 @@ __pycache__ */cython_version.py MANIFEST htmlcov -.coverage +.coverage* .ipynb_checkpoints .pytest_cache @@ -41,6 +41,7 @@ pip-wheel-metadata # Other .cache .tox +.tmp .*.sw[op] *~ From cdb2cd11a3c89dc2b9da9206ac6e5a3db41a6a0a Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 09:10:20 -0400 Subject: [PATCH 05/17] Remove manifest --- MANIFEST.in | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 180a526..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,14 +0,0 @@ -include CHANGES.rst -include LICENSE.rst -include README.rst -include pyproject.toml -include setup.cfg - -recursive-include lacosmic *.pyx *.pxd *.c -recursive-include docs * - -prune build -prune docs/_build -prune docs/api - -global-exclude *.pyc *.o From 2a54c32291355df1d5053a720b600899fe8b8ced Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 09:14:19 -0400 Subject: [PATCH 06/17] Update tox config --- tox.ini | 93 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 38 deletions(-) diff --git a/tox.ini b/tox.ini index 0b84917..284a60f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,30 +1,31 @@ [tox] envlist = - py{38,39,310}-test{,-alldeps,-devdeps}{,-cov} - py{38,39,310}-test-numpy{118,119,120,121,122} - py{38,39,310}-test-astropy{41,50,lts} + py{39,310,311}-test{,-alldeps,-devdeps,-oldestdeps,-devinfra}{,-cov} + py{39,310,311}-test-numpy{122,123,124,125,126} build_docs linkcheck codestyle + pep517 bandit requires = - setuptools >= 30.3.0 + setuptools >= 61.2 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 + devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/scientific-python-nightly-wheels/simple https://pypi.anaconda.org/astropy/simple + # Pass through the following environment variables which may be needed # for the CI -passenv = HOME WINDIR LC_ALL LC_CTYPE CC CI +passenv = HOME,WINDIR,LC_ALL,LC_CTYPE,CC,CI # Run the tests in a temporary directory to make sure that we don't # import this package from the source tree changedir = .tmp/{envname} - - # tox environments are constructed with so-called 'factors' (or terms) # separated by hyphens, e.g., test-devdeps-cov. Lines below starting # with factor: will only take effect if that factor is included in the @@ -37,40 +38,45 @@ description = run tests alldeps: with all optional dependencies devdeps: with the latest developer version of key dependencies + devinfra: like devdeps but also dev version of infrastructure oldestdeps: with the oldest supported version of key dependencies cov: and test coverage - numpy118: with numpy 1.18.* - numpy119: with numpy 1.19.* - numpy120: with numpy 1.20.* - numpy121: with numpy 1.21.* numpy122: with numpy 1.22.* - astropy41: with astropy 4.1.* - astropy50: with astropy 5.0.* - astropylts: with the latest astropy LTS + numpy123: with numpy 1.23.* + numpy124: with numpy 1.24.* + numpy125: with numpy 1.25.* + numpy126: with numpy 1.26.* # The following provides some specific pinnings for key packages deps = - cov: coverage + cov: pytest-cov - numpy118: numpy==1.18.* - numpy119: numpy==1.19.* - numpy120: numpy==1.20.* - numpy121: numpy==1.21.* numpy122: numpy==1.22.* - - astropy41: astropy==4.1.* - astropy50: astropy==5.0.* - astropylts: astropy==4.1.* - - devdeps: :NIGHTLY:numpy - devdeps: git+https://github.com/astropy/astropy.git#egg=astropy - - oldestdeps: numpy==1.18 - oldestdeps: astropy==4.1 - oldestdeps: scipy==1.6.0 - -# The following indicates which extras_require from setup.cfg will be -# installed + numpy123: numpy==1.23.* + numpy124: numpy==1.24.* + numpy125: numpy==1.25.* + numpy126: numpy==1.26.* + + oldestdeps: numpy==1.22 + oldestdeps: scipy==1.7.2 + oldestdeps: matplotlib==3.5 + + devdeps: numpy>=0.0.dev0 + devdeps: scipy>=0.0.dev0 + devdeps: matplotlib>=0.0.dev0 + + # Latest developer version of infrastructure packages. + devinfra: git+https://github.com/pytest-dev/pytest.git + devinfra: git+https://github.com/astropy/extension-helpers.git + devinfra: git+https://github.com/astropy/pytest-doctestplus.git + devinfra: git+https://github.com/astropy/pytest-remotedata.git + devinfra: git+https://github.com/astropy/pytest-astropy-header.git + devinfra: git+https://github.com/astropy/pytest-arraydiff.git + devinfra: git+https://github.com/astropy/pytest-filter-subpackage.git + devinfra: git+https://github.com/astropy/pytest-astropy.git + +# The following indicates which [project.optional-dependencies] from +# pyproject.toml will be installed extras = test: test alldeps: all @@ -78,9 +84,9 @@ extras = commands = pip freeze - !cov: pytest --pyargs lacosmic {toxinidir}/docs {posargs} - cov: pytest --pyargs lacosmic {toxinidir}/docs --cov lacosmic --cov-config={toxinidir}/setup.cfg {posargs} - cov: coverage xml -o {toxinidir}/coverage.xml + pytest --pyargs lacosmic {toxinidir}/docs \ + cov: --cov lacosmic --cov-config={toxinidir}/pyproject.toml --cov-report xml:{toxinidir}/coverage.xml --cov-report term-missing \ + {posargs} [testenv:build_docs] changedir = docs @@ -105,6 +111,17 @@ description = check code style with flake8 deps = flake8 commands = flake8 lacosmic --count --max-line-length=100 +[testenv:pep517] +skip_install = true +changedir = . +description = PEP 517 +deps = + build + twine +commands = + python -m build --sdist . + twine check dist/* --strict + [testenv:bandit] skip_install = true changedir = . From a9772c7c85881e2fc6f4b2fa9458f86785d11aab Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 09:15:07 -0400 Subject: [PATCH 07/17] Add codecov config --- codecov.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..35ce45d --- /dev/null +++ b/codecov.yml @@ -0,0 +1,10 @@ +comment: off +codecov: + branch: main +coverage: + status: + project: + default: + target: auto + # this allows a small drop from the previous base commit coverage + threshold: 0.05% From 7979c9f520b1fa65e77164db487f5500d94233a0 Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 09:19:51 -0400 Subject: [PATCH 08/17] Update sphinx makefile; remove unneeded templates --- docs/Makefile | 2 +- docs/_templates/autosummary/base.rst | 2 -- docs/_templates/autosummary/class.rst | 2 -- docs/_templates/autosummary/module.rst | 2 -- 4 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 docs/_templates/autosummary/base.rst delete mode 100644 docs/_templates/autosummary/class.rst delete mode 100644 docs/_templates/autosummary/module.rst diff --git a/docs/Makefile b/docs/Makefile index fb03f26..03886de 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -129,5 +129,5 @@ linkcheck: "or in $(BUILDDIR)/linkcheck/output.txt." doctest: - @echo "Run 'python setup.py test' in the root directory to run doctests " \ + @echo "Run 'pytest' in the root directory to run doctests " \ @echo "in the documentation." diff --git a/docs/_templates/autosummary/base.rst b/docs/_templates/autosummary/base.rst deleted file mode 100644 index 9cabaf5..0000000 --- a/docs/_templates/autosummary/base.rst +++ /dev/null @@ -1,2 +0,0 @@ -{% extends "autosummary_core/base.rst" %} -{# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #} \ No newline at end of file diff --git a/docs/_templates/autosummary/class.rst b/docs/_templates/autosummary/class.rst deleted file mode 100644 index 6b214a5..0000000 --- a/docs/_templates/autosummary/class.rst +++ /dev/null @@ -1,2 +0,0 @@ -{% extends "autosummary_core/class.rst" %} -{# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #} \ No newline at end of file diff --git a/docs/_templates/autosummary/module.rst b/docs/_templates/autosummary/module.rst deleted file mode 100644 index f38315b..0000000 --- a/docs/_templates/autosummary/module.rst +++ /dev/null @@ -1,2 +0,0 @@ -{% extends "autosummary_core/module.rst" %} -{# The template this is inherited from is in astropy/sphinx/ext/templates/autosummary_core. If you want to modify this template, it is strongly recommended that you still inherit from the astropy template. #} \ No newline at end of file From f4c34cd176c3e71677bebc2e3a1f7ac7a8e32e3c Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 09:30:59 -0400 Subject: [PATCH 09/17] Update sphinx config --- docs/conf.py | 81 +++++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 94148d9..9677553 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst # # Documentation build configuration file. @@ -13,39 +12,48 @@ # the global Astropy configuration which is loaded here before anything # else. See astropy.sphinx.conf for which values are set there. -from configparser import ConfigParser -from datetime import datetime import os import sys +from datetime import datetime +from pathlib import Path + +if sys.version_info < (3, 11): + import tomli as tomllib +else: + import tomllib try: - from sphinx_astropy.conf.v1 import * # noqa + from sphinx_astropy.conf.v1 import * # noqa: F403 except ImportError: print('ERROR: the documentation requires the sphinx-astropy package to ' 'be installed') sys.exit(1) -# Get configuration information from setup.cfg -conf = ConfigParser() -conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')]) -setup_cfg = dict(conf.items('metadata')) - +# Get configuration information from pyproject.toml +with (Path(__file__).parents[1] / 'pyproject.toml').open('rb') as fh: + conf = tomllib.load(fh) + project_meta = conf['project'] # -- General configuration ---------------------------------------------------- # By default, highlight as Python 3. highlight_language = 'python3' # If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = '1.7' +# needs_sphinx = '3.0' + +# To perform a Sphinx version check that needs to be more specific than +# major.minor, call `check_sphinx_version("x.y.z")` here. +# check_sphinx_version("1.2.1") + +# Extend astropy intersphinx_mapping with packages we use here +# intersphinx_mapping['skimage'] = ('https://scikit-image.org/docs/stable/', None) noqa: F405 # Exclude astropy intersphinx_mapping for unused packages -del intersphinx_mapping['h5py'] # noqa +del intersphinx_mapping['h5py'] # noqa: F405 # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns.append('_templates') # noqa -# Exclude dev releasing docs -#exclude_patterns.append('dev/*') # noqa +# exclude_patterns.append('_templates') plot_formats = ['png', 'hires.png', 'pdf', 'svg'] @@ -55,14 +63,17 @@ .. _Astropy: https://www.astropy.org/ """ +# Turn off table of contents entries for functions and classes +# toc_object_entries = False # -- Project information ------------------------------------------------------ -project = setup_cfg['name'] -author = setup_cfg['author'] +project = project_meta['name'] +author = project_meta['authors'][0]['name'] copyright = f'2014-{datetime.utcnow().year}, {author}' -# The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the -# built documents. +# The version info for the project you're documenting, acts as +# replacement for |version| and |release|, also used in various other +# places throughout the built documents. __import__(project) package = sys.modules[project] @@ -71,14 +82,14 @@ # The full version, including alpha/beta/rc tags. release = package.__version__ - # -- Options for HTML output -------------------------------------------------- +# A NOTE ON HTML THEMES # The global astropy configuration uses a custom theme, -# 'bootstrap-astropy', which is installed along with astropy. A different -# theme can be used or the options for this theme can be modified by -# overriding some of the variables set in the global configuration. The -# variables set in the global configuration are listed below, commented -# out. +# 'bootstrap-astropy', which is installed along with astropy. A +# different theme can be used or the options for this theme can be +# modified by overriding some of the variables set in the global +# configuration. The variables set in the global configuration are +# listed below, commented out. # Add any paths that contain custom themes here, relative to this # directory. @@ -89,7 +100,7 @@ # to the name of a builtin theme or the name of a custom theme in # html_theme_path. # html_theme = None -# Customized theme options + html_theme_options = { 'logotext1': 'lacosmic', # white, semi-bold 'logotext2': '', # orange, light @@ -104,9 +115,9 @@ # html_logo = '' # The name of an image file (within the static path) to use as favicon -# of the docs. This file should be a Windows icon file (.ico) being 16x16 -# or 32x32 pixels large. -# html_favicon = +# of the docs. This file should be a Windows icon file (.ico) being +# 16x16 or 32x32 pixels large. +# html_favicon = '' # A "Last built" timestamp is inserted at every page bottom, using the # given strftime format. Set to '' to omit this timestamp. @@ -118,29 +129,23 @@ # Output file base name for HTML help builder. htmlhelp_basename = project + 'doc' -# Static files to copy after template files -#html_static_path = ['_static'] - # -- Options for LaTeX output ------------------------------------------------- # Grouping the document tree into LaTeX files. List of tuples (source # start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [('index', project + '.tex', project + u' Documentation', +latex_documents = [('index', project + '.tex', project + ' Documentation', author, 'manual')] - # -- Options for manual page output ------------------------------------------- # One entry per manual page. List of tuples (source start file, name, # description, authors, manual section). -man_pages = [('index', project.lower(), project + u' Documentation', +man_pages = [('index', project.lower(), project + ' Documentation', [author], 1)] - # -- Resolving issue number to links in changelog ----------------------------- -github_project = setup_cfg['github_project'] +github_project = conf['tool']['build-sphinx']['github_project'] github_issues_url = f'https://github.com/{github_project}/issues/' - # -- Turn on nitpicky mode for sphinx (to warn about references not found) ---- nitpicky = True nitpick_ignore = [] @@ -167,8 +172,6 @@ target = target.strip() nitpick_ignore.append((dtype, target)) - - # -- Options for linkcheck output --------------------------------------------- linkcheck_retry = 5 linkcheck_ignore = ['http://data.astropy.org', From 0eb9b402d2a6e7ce1ce1cbc8439b75f0327438b6 Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 09:34:28 -0400 Subject: [PATCH 10/17] Update install docs --- docs/index.rst | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 3cd68bf..922b41f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -15,17 +15,16 @@ Requirements ``lacosmic`` has the following requirements: -* `Python `_ 3.8 or later +* `Python `_ 3.9 or later -* `Numpy `_ 1.18 or later +* `NumPy `_ 1.22 or later -* `Scipy `_ 1.6.0 or later +* `Scipy `_ 1.7.2 or later -* `Astropy`_ 4.1 or later +* `Astropy`_ 5.0 or later -``lacosmic`` also depends on `pytest-astropy -`_ (0.4 or later) to run the -test suite. +`pytest-astropy `_ (0.10 or +later) is required to run the test suite. Installation @@ -36,11 +35,6 @@ The latest released (stable) version of lacosmic can be installed with pip install lacosmic -If you want to make sure that none of your existing dependencies get -upgraded, instead you can do:: - - pip install lacosmic --no-deps - .. _pip: https://pip.pypa.io/en/latest/ From 8acb1ac19fbd50f6e666c3eac4ba0528bd030578 Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 09:35:22 -0400 Subject: [PATCH 11/17] isort imports --- lacosmic/_astropy_init.py | 1 + lacosmic/core.py | 2 +- lacosmic/tests/test_core.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lacosmic/_astropy_init.py b/lacosmic/_astropy_init.py index bd45324..55510a7 100644 --- a/lacosmic/_astropy_init.py +++ b/lacosmic/_astropy_init.py @@ -10,4 +10,5 @@ # Create the test function for self test from astropy.tests.runner import TestRunner + test = TestRunner.make_test_runner_in(os.path.dirname(__file__)) diff --git a/lacosmic/core.py b/lacosmic/core.py index 605d216..b5858e2 100644 --- a/lacosmic/core.py +++ b/lacosmic/core.py @@ -4,9 +4,9 @@ L.A.Cosmic algorithm (van Dokkum 2001; PASP 113, 1420). """ +import numpy as np from astropy import log from astropy.nddata import block_reduce, block_replicate -import numpy as np from scipy import ndimage __all__ = ['lacosmic'] diff --git a/lacosmic/tests/test_core.py b/lacosmic/tests/test_core.py index 687ccdb..2871711 100644 --- a/lacosmic/tests/test_core.py +++ b/lacosmic/tests/test_core.py @@ -4,8 +4,8 @@ """ import numpy as np -from numpy.testing import assert_array_equal, assert_allclose import pytest +from numpy.testing import assert_allclose, assert_array_equal from ..core import lacosmic From 13c3e9fb8d2969006e968befbc788670f07a1271 Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 09:36:20 -0400 Subject: [PATCH 12/17] Update conftest --- lacosmic/conftest.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lacosmic/conftest.py b/lacosmic/conftest.py index 8490eec..8714514 100644 --- a/lacosmic/conftest.py +++ b/lacosmic/conftest.py @@ -3,12 +3,20 @@ # get picked up when running the tests inside an interpreter using # packagename.test +import numpy as np +from astropy.utils import minversion + try: - from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS + from pytest_astropy_header.display import (PYTEST_HEADER_MODULES, + TESTED_VERSIONS) ASTROPY_HEADER = True except ImportError: ASTROPY_HEADER = False +# do not remove until we drop support for NumPy < 2.0 +if minversion(np, "2.0.0.dev0+git20230726"): + np.set_printoptions(legacy='1.25') + def pytest_configure(config): if ASTROPY_HEADER: @@ -17,10 +25,10 @@ def pytest_configure(config): # 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' # noqa - PYTEST_HEADER_MODULES['Scipy'] = 'scipy' # noqa - PYTEST_HEADER_MODULES.pop('Pandas', None) # noqa - PYTEST_HEADER_MODULES.pop('h5py', None) # noqa + PYTEST_HEADER_MODULES.clear() + deps = ['NumPy', 'SciPy', 'Matplotlib'] + for dep in deps: + PYTEST_HEADER_MODULES[dep] = dep.lower() from lacosmic import __version__ TESTED_VERSIONS['lacosmic'] = __version__ From 67c74c860570517481ea9e1f083a53384e458dab Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 09:41:54 -0400 Subject: [PATCH 13/17] Add pre-commit config --- .pre-commit-config.yaml | 86 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a0ce8ae --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,86 @@ +ci: + autofix_prs: false + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-added-large-files + # Prevent giant files from being committed. + - id: check-ast + # Simply check whether files parse as valid python. + - id: check-case-conflict + # Check for files with names that would conflict on a case-insensitive + # filesystem like MacOS HFS+ or Windows FAT. + - id: check-json + # Attempts to load all json files to verify syntax. + - id: check-merge-conflict + # Check for files that contain merge conflict strings. + - id: check-symlinks + # Checks for symlinks which do not point to anything. + - id: check-toml + # Attempts to load all TOML files to verify syntax. + - id: check-xml + # Attempts to load all xml files to verify syntax. + - id: check-yaml + # Attempts to load all yaml files to verify syntax. + - id: debug-statements + # Check for debugger imports and py37+ breakpoint() calls in python + # source. + - id: detect-private-key + # Checks for the existence of private keys. + - id: end-of-file-fixer + # Makes sure files end in a newline and only a newline. + exclude: ".*(svg.*|extern.*|_templates.*)$" + - id: trailing-whitespace + # Trims trailing whitespace. + exclude: ".*(data.*|extern.*)$" + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.10.0 + hooks: + - id: python-check-mock-methods + # Prevent common mistakes of assert mck.not_called(), assert + # mck.called_once_with(...) and mck.assert_called. + - id: rst-directive-colons + # Detect mistake of rst directive not ending with double colon. + - id: rst-inline-touching-normal + # Detect mistake of inline code touching normal text in rst. + - id: text-unicode-replacement-char + # Forbid files which have a UTF-8 Unicode replacement character. + - id: python-check-blanket-noqa + # Enforce that all noqa annotations always occur with specific codes. + + - repo: https://github.com/asottile/pyupgrade + rev: v3.11.0 + hooks: + - id: pyupgrade + args: ["--py39-plus"] + exclude: ".*(extern.*)$" + + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + name: isort (python) + additional_dependencies: [toml] + - id: isort + name: isort (cython) + types: [cython] + additional_dependencies: [toml] + + - repo: https://github.com/PyCQA/flake8 + rev: 6.1.0 + hooks: + - id: flake8 + args: ["--ignore", "E501,W503"] + + - repo: https://github.com/asottile/yesqa + rev: v1.5.0 + hooks: + - id: yesqa + + # - repo: https://github.com/MarcoGorelli/absolufy-imports + # rev: v0.3.1 + # hooks: + # - id: absolufy-imports From da222070470cb2e30ad59ef2b75ab627cb99ac47 Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 09:44:09 -0400 Subject: [PATCH 14/17] Update CI workflow --- .github/workflows/ci_tests.yml | 100 ++++++++++++++++++++++++--------- 1 file changed, 74 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 6b6552c..c7ae700 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -2,11 +2,15 @@ name: CI Tests on: push: - branches: [ main ] + branches: + - main + tags: + - '*' pull_request: schedule: - # run every Monday at 6am UTC - - cron: '0 6 * * 1' + # run every Monday at 5am UTC + - cron: '0 5 * * 1' + workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -15,54 +19,98 @@ concurrency: env: TOXARGS: '-v' +permissions: + contents: read + jobs: - ci-tests: - name: ${{ matrix.os }}, ${{ matrix.tox_env }} + tests: + name: ${{ matrix.prefix }} ${{ matrix.os }}, ${{ matrix.tox_env }} runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.allow_failure }} strategy: matrix: include: - - os: ubuntu-latest - python: '3.8' - tox_env: 'py38-test-alldeps' - os: ubuntu-latest python: '3.9' tox_env: 'py39-test-alldeps' + allow_failure: false + prefix: '' + - os: ubuntu-latest python: '3.10' tox_env: 'py310-test-alldeps' + allow_failure: false + prefix: '' + + - os: ubuntu-latest + python: '3.11' + tox_env: 'py311-test-alldeps-cov' + toxposargs: --remote-data=any + allow_failure: false + prefix: '' + - os: macos-latest - python: '3.10' - tox_env: 'py310-test-alldeps' + python: '3.11' + tox_env: 'py311-test-alldeps' + allow_failure: false + prefix: '' + - os: windows-latest - python: '3.10' - tox_env: 'py310-test-alldeps' + python: '3.11' + tox_env: 'py311-test-alldeps' + allow_failure: false + prefix: '' + - os: ubuntu-latest - python: '3.10' - tox_env: 'py310-test' + python: '3.11' + tox_env: 'py311-test' + allow_failure: false + prefix: '' + - os: ubuntu-latest - python: '3.10' + python: '3.11' + tox_env: 'linkcheck' + allow_failure: false + prefix: '' + + - os: ubuntu-latest + python: '3.11' tox_env: 'codestyle' + allow_failure: false + prefix: '' + - os: ubuntu-latest - python: '3.10' - tox_env: 'linkcheck' + python: '3.11' + tox_env: 'pep517' + allow_failure: false + prefix: '' + - os: ubuntu-latest - python: '3.10' + python: '3.11' tox_env: 'bandit' + allow_failure: false + prefix: '' + - os: ubuntu-latest - python: '3.8' - tox_env: 'py38-test-alldeps-astropylts-numpy118' + python: '3.9' + tox_env: 'py39-test-oldestdeps' + allow_failure: false + prefix: '' + - os: ubuntu-latest - python: '3.10' - tox_env: 'py310-test-alldeps-devdeps' + python: '3.11' + tox_env: 'py311-test-devdeps' + toxposargs: --remote-data=any + allow_failure: true + prefix: '(Allowed failure)' steps: - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} - name: Install base dependencies @@ -78,8 +126,8 @@ jobs: - name: Run tests run: tox -e ${{ matrix.tox_env }} -- ${{ matrix.toxposargs }} - name: Upload coverage to codecov - if: "contains(matrix.tox_env, '-cov')" + if: ${{ contains(matrix.tox_env, '-cov') }} uses: codecov/codecov-action@v3 with: - file: ./coverage.xml + files: ./coverage.xml verbose: true From 466390805a70adbbd72e2d88dba12c89d4c2e62c Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 09:45:14 -0400 Subject: [PATCH 15/17] Add publish workflow --- .github/workflows/publish.yml | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..5d040bd --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,46 @@ +name: Wheel building + +on: + schedule: + # run every Monday at 5am UTC + - cron: '0 5 * * 1' + pull_request: + # We also want this workflow triggered if the 'Build all wheels' + # label is added or present when PR is updated + types: + - synchronize + - labeled + push: + branches: + - '*' + tags: + - '*' + - '!*dev*' + - '!*pre*' + - '!*post*' + workflow_dispatch: + +permissions: + contents: read + +jobs: + build_and_publish: + # This job builds the wheels and publishes them to PyPI for all + # tags, except those ending in ".dev". For PRs with the "Build all + # wheels" label, wheels are built, but are not uploaded to PyPI. + + permissions: + contents: none + + uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@v1 + + if: (github.repository == 'larrybradley/lacosmic' && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'Build all wheels'))) + with: + # We upload to PyPI for all tag pushes, except tags ending in .dev + upload_to_pypi: ${{ startsWith(github.ref, 'refs/tags/') && !endsWith(github.ref, '.dev') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }} + + test_extras: test + test_command: pytest -p no:warnings --pyargs lacosmic + + secrets: + pypi_token: ${{ secrets.pypi_token }} From 7ffa805e1f4e1e73eacbc92ab60c96ed63bae060 Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 10:15:26 -0400 Subject: [PATCH 16/17] Add noqa codes --- lacosmic/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lacosmic/__init__.py b/lacosmic/__init__.py index 3dafe09..9d76a31 100644 --- a/lacosmic/__init__.py +++ b/lacosmic/__init__.py @@ -7,7 +7,7 @@ # Packages may add whatever they like to this file, but # should keep this content at the top. # ---------------------------------------------------------------------------- -from ._astropy_init import * # noqa +from ._astropy_init import * # noqa: F401, F403 # ---------------------------------------------------------------------------- -from .core import * # noqa +from .core import * # noqa: F401, F403 From 857e6ce216b31645c2fd822e1b023c0cc4209744 Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Tue, 19 Sep 2023 10:22:15 -0400 Subject: [PATCH 17/17] Add changelog entry --- CHANGES.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 73ee406..6c6c5c7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,7 +1,19 @@ 1.1.0 (unreleased) ------------------ -- No changes yet +General +^^^^^^^ + +- The minimum required Python version is 3.9. [#19] + +- The minimum required Numpy version is 1.22. [#19] + +- The minimum required Scipy version is 1.7.2. [#19] + +- The minimum required Astropy version is 5.0. [#19] + +- The project metadata is now stored in ``pyproject.toml`` (PEP 621). + [#19] 1.0.0 (2022-04-19)