diff --git a/.gitignore b/.gitignore index 71b51f82..37a9b111 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ __pycache__ # Other generated files */version.py +*/_version.py */cython_version.py htmlcov .coverage diff --git a/docs/conf.py b/docs/conf.py index 65aa22ad..cef63e81 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -26,8 +26,9 @@ # be accessible, and the documentation will not build correctly. import datetime -import os import sys +from importlib import import_module +from pathlib import Path try: from sphinx_astropy.conf.v1 import * # noqa @@ -35,15 +36,16 @@ print('ERROR: the documentation requires the sphinx-astropy package to be installed') sys.exit(1) -# Get configuration information from setup.cfg -try: - from ConfigParser import ConfigParser -except ImportError: - from configparser import ConfigParser -conf = ConfigParser() +if sys.version_info < (3, 11): + import tomli as tomllib +else: + import tomllib + +# Grab minversion from pyproject.toml +with (Path(__file__).parents[1] / "pyproject.toml").open("rb") as f: + pyproject = tomllib.load(f) -conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')]) -setup_cfg = dict(conf.items('metadata')) +__minimum_python_version__ = pyproject["project"]["requires-python"].replace(">=", "") # -- General configuration ---------------------------------------------------- @@ -68,20 +70,26 @@ # -- Project information ------------------------------------------------------ # This does not *have* to match the package name, but typically does -project = setup_cfg['name'] -author = setup_cfg['author'] -copyright = '{0}, {1}'.format( - datetime.datetime.now().year, setup_cfg['author']) +project = pyproject["project"]["name"] +author = ", ".join(v["name"] for v in pyproject["project"]["authors"]) +copyright = f"{datetime.datetime.now().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. -__import__(project) -package = sys.modules[project] -ver = package.__version__ -version = '.'.join(ver.split('.'))[:5] -release = ver +import_module(pyproject["project"]["name"]) +package = sys.modules[pyproject["project"]["name"]] + +# The short X.Y version. +version = package.__version__.split("-", 1)[0] +# The full version, including alpha/beta/rc tags. +release = package.__version__ + +# Only include dev docs in dev version. +dev = "dev" in release +if not dev: + exclude_patterns += ["development/*"] # -- Options for HTML output -------------------------------------------------- @@ -157,18 +165,18 @@ # -- Options for the edit_on_github extension --------------------------------- -if eval(setup_cfg.get('edit_on_github')): - extensions += ['sphinx_astropy.ext.edit_on_github'] +# if eval(setup_cfg.get('edit_on_github')): +# extensions += ['sphinx_astropy.ext.edit_on_github'] - versionmod = __import__(setup_cfg['name'] + '.version') - edit_on_github_project = setup_cfg['github_project'] - if versionmod.version.release: - edit_on_github_branch = "v" + versionmod.version.version - else: - edit_on_github_branch = "main" +# versionmod = __import__(setup_cfg['name'] + '.version') +# edit_on_github_project = setup_cfg['github_project'] +# if versionmod.version.release: +# edit_on_github_branch = "v" + versionmod.version.version +# else: +# edit_on_github_branch = "main" - edit_on_github_source_root = "" - edit_on_github_doc_root = "docs" +# edit_on_github_source_root = "" +# edit_on_github_doc_root = "docs" # -- Resolving issue number to links in changelog ----------------------------- github_issues_url = 'https://github.com/astropy/ccdproc/issues/' diff --git a/pyproject.toml b/pyproject.toml index 0889579c..3e93aaf6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,107 @@ [build-system] -requires = ["setuptools", - "setuptools_scm", - "wheel"] -build-backend = 'setuptools.build_meta' +requires = ["hatchling", +"hatch-vcs"] +build-backend = "hatchling.build" + +[project] +name = "ccdproc" +dynamic = ["version"] +description = "Astropy affiliated package" +readme = "README.rst" +license = "BSD-3-clause" +requires-python = ">=3.8" +authors = [ + { name = "Steve Crawford", email = "ccdproc@gmail.com" }, + { name = "Matt Craig" }, + { name = "and Michael Seifert" }, +] +dependencies = [ + "astropy>=5.0.1", + "astroscrappy>=1.0.8", + "numpy>=1.21", + "reproject>=0.7", + "scikit-image", + "scipy", +] + +[project.optional-dependencies] +docs = [ + "matplotlib", + "sphinx-astropy", +] +test = [ + "memory_profiler", + "pytest-astropy>=0.10.0", +] + +[project.urls] +Homepage = "http://ccdproc.readthedocs.io/" + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "ccdproc/_version.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/ccdproc", +] + +[tool.coverage] + [tool.coverage.run] + source = ["ccdproc"] + omit = [ + "*/ccdproc/__init__*", + "*/ccdproc/conftest.py", + "*/ccdproc/*setup*", + "*/ccdproc/*/tests/*", + "*/ccdproc/tests/*", + ] + + [tool.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}", + ] + +[tool.pytest.ini_options] +minversion = 7.0 +testpaths = [ + "ccdproc", + "docs", +] +norecursedirs = [ + "docs[\\/]_build", + "docs[\\/]generated", +] +astropy_header = true +doctest_plus = "enabled" +text_file_format = "rst" +remote_data_strict = true +addopts = [ + "--doctest-rst", + "--color=yes", +] +log_cli_level = "info" +xfail_strict = true +filterwarnings= [ + "error", + "ignore:numpy\\.ufunc size changed:RuntimeWarning", + "ignore:numpy.ndarray size changed:RuntimeWarning", + "ignore:`np.bool` is a deprecated alias for the builtin `bool`:DeprecationWarning", +] +markers = [ + "data_size(N): set dimension of square data array for ccd_data fixture", + "data_scale(s): set the scale of the normal distribution used to generate data", + "data_mean(m): set the center of the normal distribution used to generate data", +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 93c3b091..00000000 --- a/setup.cfg +++ /dev/null @@ -1,117 +0,0 @@ - -[tool:pytest] -minversion = 2.2 -testpaths = "ccdproc" "docs" -norecursedirs = build docs/_build -doctest_plus = enabled -addopts = --doctest-rst --color=yes -filterwarnings= - error - ignore:numpy\.ufunc size changed:RuntimeWarning - ignore:numpy.ndarray size changed:RuntimeWarning - ignore:`np.bool` is a deprecated alias for the builtin `bool`:DeprecationWarning -markers = - data_size(N): set dimension of square data array for ccd_data fixture - data_scale(s): set the scale of the normal distribution used to generate data - data_mean(m): set the center of the normal distribution used to generate data - -[metadata] -name = ccdproc -description = Astropy affiliated package -long_description = This is a package for reducing optical/IR CCD data that relies on astropy -author = Steve Crawford, Matt Craig, and Michael Seifert -author_email = ccdproc@gmail.com -license = BSD -url = http://ccdproc.readthedocs.io/ -edit_on_github = False -github_project = astropy/ccdproc - -[options] -packages = find: -zip_safe = False -setup_requires = setuptools_scm -install_requires = numpy>=1.21 - astropy>=5.0.1 - scipy - astroscrappy>=1.0.8 - reproject>=0.7 - scikit-image -python_requires = >=3.8 - -[options.package_data] -* = data/* - -[options.extras_require] -test = - pytest-astropy>=0.10.0 - memory_profiler -docs = - sphinx-astropy - matplotlib - - -[pycodestyle] -# PEP8 errors/warnings: -# (partially) taken from -# https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes -# E101 - mix of tabs and spaces -# E111 - 4 spaces per indentation level -# E112 - 4 spaces per indentation level -# E113 - 4 spaces per indentation level -# E221 - multiple spaces before operator -# E222 - multiple spaces after operator -# E223 - tab before operator -# E224 - tab after operator -# E225 - missing whitespace around operator -# E241 - multiple whitespace after ',' -# E242 - tab after ',' -# E251 - unexpected spaces around keyword / parameter equals -# E271 - multiple spaces after keyword -# E272 - multiple spaces before keyword -# E303 - too many blank lines -# E304 - blank lines found after function decorator -# E502 - the backslash is redundant between brackets -# E703 - statement ends with a semicolon -# E901 - SyntaxError or IndentationError -# E902 - IOError -# W191 - indentation contains tabs -# W291 - trailing whitespace -# W292 - no newline at end of file -# W293 - blank line contains whitespace -# W391 - blank line at end of file -select = E101,E111,E112,E113,E221,E222,E223,E224,E225,E241,E242,E251,E271,E272,E303,E304,E502,E703,E901,E902,W191,W291,W292,W293,W391 - -# PEP errors to ignore -# ignore = ... - -# Excluding files that are directly copied from the package template or -# generated -exclude = _astropy_init.py,version.py - -[entry_points] - -[flake8] -max-line-length = 100 - -[coverage:run] -source = ccdproc -omit = - */ccdproc/__init__* - */ccdproc/conftest.py - */ccdproc/*setup* - */ccdproc/*/tests/* - */ccdproc/tests/* - -[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} diff --git a/tox.ini b/tox.ini index 43bee19b..6f003f49 100644 --- a/tox.ini +++ b/tox.ini @@ -62,7 +62,7 @@ deps = commands = pip freeze !cov-!oldestdeps: pytest --pyargs ccdproc {toxinidir}/docs {posargs} - cov: pytest --pyargs ccdproc {toxinidir}/docs --cov ccdproc --cov-config={toxinidir}/setup.cfg {posargs} + cov: pytest --pyargs ccdproc {toxinidir}/docs --cov ccdproc --cov-config={toxinidir}/pyproject.toml {posargs} cov: coverage xml -o {toxinidir}/coverage.xml # install astroscrappy after numpy oldestdeps: python -m pip install astroscrappy==1.0.8 @@ -71,10 +71,6 @@ commands = [testenv:build_docs] extras = docs -deps = - sphinx-automodapi<=0.13 -setenv = - HOME = {envtmpdir} changedir = docs commands = pip freeze @@ -86,3 +82,41 @@ changedir = . description = check code style with pycodestyle deps = pycodestyle commands = pycodestyle ccdproc --count --show-source --show-pep8 + +[pycodestyle] +# PEP8 errors/warnings: +# (partially) taken from +# https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes +# E101 - mix of tabs and spaces +# E111 - 4 spaces per indentation level +# E112 - 4 spaces per indentation level +# E113 - 4 spaces per indentation level +# E221 - multiple spaces before operator +# E222 - multiple spaces after operator +# E223 - tab before operator +# E224 - tab after operator +# E225 - missing whitespace around operator +# E241 - multiple whitespace after ',' +# E242 - tab after ',' +# E251 - unexpected spaces around keyword / parameter equals +# E271 - multiple spaces after keyword +# E272 - multiple spaces before keyword +# E303 - too many blank lines +# E304 - blank lines found after function decorator +# E502 - the backslash is redundant between brackets +# E703 - statement ends with a semicolon +# E901 - SyntaxError or IndentationError +# E902 - IOError +# W191 - indentation contains tabs +# W291 - trailing whitespace +# W292 - no newline at end of file +# W293 - blank line contains whitespace +# W391 - blank line at end of file +select = "E101,E111,E112,E113,E221,E222,E223,E224,E225,E241,E242,E251,E271,E272,E303,E304,E502,E703,E901,E902,W191,W291,W292,W293,W391" + +# PEP errors to ignore +# ignore = ... + +# Excluding files that are directly copied from the package template or +# generated +exclude = "_astropy_init.py,version.py"