From 6005f149e85372c9ede09a4df02c940d05926d83 Mon Sep 17 00:00:00 2001 From: Zach Burnett Date: Mon, 29 Aug 2022 15:46:22 -0400 Subject: [PATCH] move build configuration into `pyproject.toml` --- .flake8 | 9 +++++ docs/conf.py | 10 +++--- pyproject.toml | 81 +++++++++++++++++++++++++++++++++++++++++- setup.cfg | 95 -------------------------------------------------- setup.py | 6 ---- 5 files changed, 93 insertions(+), 108 deletions(-) create mode 100644 .flake8 delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.flake8 b/.flake8 new file mode 100644 index 000000000..e16c9db98 --- /dev/null +++ b/.flake8 @@ -0,0 +1,9 @@ +# flake8 does not support pyproject.toml (https://github.com/PyCQA/flake8/issues/234) + +[flake8] +select = F, W, E101, E111, E112, E113, E401, E402, E501, E711, E722 +# We should set max line length to 88 eventually +max-line-length = 130 +exclude = + docs, +ignore = E203, W503, W504, W605 diff --git a/docs/conf.py b/docs/conf.py index a8f6264ac..e14126e46 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -21,7 +21,7 @@ import sphinx import stsci_rtd_theme import sphinx_astropy - +import tomli def setup(app): try: @@ -30,8 +30,6 @@ def setup(app): app.add_stylesheet("stsci.css") -conf = ConfigParser() - # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -40,8 +38,8 @@ def setup(app): sys.path.insert(0, os.path.abspath('roman_datamodels/')) # -- General configuration ------------------------------------------------ -conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')]) -setup_cfg = dict(conf.items('metadata')) +conf = tomli.load('../pyproject.toml') +setup_cfg = conf['project'] # If your documentation needs a minimal Sphinx version, state it here. # needs_sphinx = '1.3' @@ -127,7 +125,7 @@ def check_sphinx_version(expected_version): # General information about the project project = setup_cfg['name'] -author = setup_cfg['author'] +author = setup_cfg['authors'][0]['name'] copyright = '{0}, {1}'.format(datetime.datetime.now().year, author) # The version info for the project you're documenting, acts as replacement for diff --git a/pyproject.toml b/pyproject.toml index 47304ce4d..272fd9084 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,85 @@ +[project] +name = 'roman_datamodels' +description = 'data models supporting calibration of the Nancy Grace Roman Space Telescope' +readme = 'README.md' +requires-python = '>=3.8' +license = { file = 'LICENSE' } +authors = [{ name = 'STScI', email = 'help@stsci.edu' }] +classifiers = [ + 'Intended Audience :: Science/Research', + 'Topic :: Scientific/Engineering :: Astronomy', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: Python :: 3', +] +dependencies = [ + 'asdf >=2.13.0', + 'asdf-astropy >=0.2.0', + 'psutil >=5.7.2', + 'numpy', + 'astropy >=5.0.4', + 'rad >=0.13.1', + 'asdf-standard >=1.0.3', +] +dynamic = ['version'] + +[project.optional-dependencies] +test = [ + 'pytest >=6.0.0', + 'pytest-doctestplus', + 'pytest-openfiles >=0.5.0', + 'pytest-doctestplus >=0.10.0', +] +aws = [ + 'stsci-aws-utils >= 0.1.2', +] + +[project.urls] +'issues' = 'https://github.com/spacetelescope/roman_datamodels/issues' +'repository' = 'https://github.com/spacetelescope/roman_datamodels' + +[project.entry-points] +'asdf.extensions' = { roman_datamodels = 'roman_datamodels.integration:get_extensions' } + [build-system] -requires = ["setuptools>=42", "setuptools_scm[toml]>=3.4", "wheel"] +requires = ["setuptools >=60", "setuptools_scm[toml] >=3.4", "wheel"] build-backend = "setuptools.build_meta" [tool.setuptools_scm] write_to = "src/roman_datamodels/_version.py" + +[tool.setuptools.packages.find] +where = ['src'] + +[tool.pytest.ini_options] +minversion = 4.6 +doctest_plus = true +doctest_rst = true +text_file_format = 'rst' +addopts = '--show-capture=no --open-files' +testpaths = ['tests'] + +[tool.coverage.run] +omit = [ + 'roman_datamodels/pyproject.toml', + 'roman_datamodels/tests', + 'roman_datamodels/src/roman_datamodels/stnode_test.py', + # And list these again for running against installed version + '*/roman_datamodels/pyproject.toml', + '*/roman_datamodels/tests', + '*/roman_datamodels/src/roman_datamodels/mktest.py', + '*/roman_datamodels/src/roman_datamodels/stnode_test.py', +] + +[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\(.*\):', + 'if __name__ == \'__main__\':', +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 9e088c5c5..000000000 --- a/setup.cfg +++ /dev/null @@ -1,95 +0,0 @@ -[metadata] -name = roman_datamodels -description = Roman Datamodels -long_description = file: README.md -long_description_content_type = text/markdown -author = STScI -license = BSD-3-Clause -url = https://github.com/spacetelescope/roman_datamodels -project_urls = - Bug Tracker = https://github.com/spacetelescope/roman_datamodels/issues - Source Code = https://github.com/spacetelescope/roman_datamodels -classifiers = - Intended Audience :: Science/Research - Topic :: Scientific/Engineering :: Astronomy - License :: OSI Approved :: BSD License - Programming Language :: Python :: 3 - -[options] -zip_safe = True -python_requires = >=3.8 -setup_requires = - setuptools_scm -install_requires = - asdf>=2.13.0 - asdf-astropy>=0.2.0 - psutil>=5.7.2 - numpy - astropy>=5.0.4 - rad>=0.13.1 - asdf-standard>=1.0.3 -package_dir = - =src -packages = find: - -[options.entry_points] -asdf.extensions = - roman_datamodels = roman_datamodels.integration:get_extensions - -[options.packages.find] -where = src - -[options.extras_require] -test = - pytest>=6.0.0 - pytest-doctestplus - pytest-openfiles>=0.5.0 - pytest-doctestplus>=0.10.0 -aws = - stsci-aws-utils>=0.1.2 -docs = - sphinx - sphinx-automodapi - sphinx-rtd-theme - stsci-rtd-theme - sphinx-astropy - sphinx-asdf - -[flake8] -select = F, W, E101, E111, E112, E113, E401, E402, E501, E711, E722 -# We should set max line length to 88 eventually -max-line-length = 130 -exclude = - docs, -ignore = E203, W503, W504, W605 - -[tool:pytest] -minversion = 4.6 -doctest_plus = true -doctest_rst = true -text_file_format = rst -addopts = --show-capture=no --open-files -testpaths = - tests - -[coverage:run] -omit = - roman_datamodels/setup.cfg - roman_datamodels/setup.py - roman_datamodels/tests - roman_datamodels/src/roman_datamodels/stnode_test.py - # And list these again for running against installed version - */roman_datamodels/setup.cfg - */roman_datamodels/setup.py - */roman_datamodels/tests - */roman_datamodels/src/roman_datamodels/mktest.py - */roman_datamodels/src/roman_datamodels/stnode_test.py - -[coverage:report] -exclude_lines = - pragma: no cover - if self.debug: - except ImportError - raise AssertionError - raise NotImplementedError - if __name__ == '__main__': diff --git a/setup.py b/setup.py deleted file mode 100644 index 17def5f9b..000000000 --- a/setup.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env python3 -from setuptools import setup - -# This should be enabled by pyproject.toml, but that doesn't seem -# to work with pip 21.2.4. -setup(use_scm_version={"write_to": "src/roman_datamodels/_version.py"})