From 3c302e17b8612209fa600d00a379b4599466af33 Mon Sep 17 00:00:00 2001 From: Zach Burnett Date: Wed, 26 Oct 2022 09:41:36 -0400 Subject: [PATCH] move build configuration into `pyproject.toml` --- .flake8 | 11 +++++ docs/conf.py | 23 +++++----- pyproject.toml | 114 +++++++++++++++++++++++++++++++++++++++++++++++-- setup.cfg | 105 --------------------------------------------- setup.py | 21 +++------ tox.ini | 2 +- 6 files changed, 138 insertions(+), 138 deletions(-) create mode 100644 .flake8 delete mode 100644 setup.cfg mode change 100755 => 100644 setup.py diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..2920c319 --- /dev/null +++ b/.flake8 @@ -0,0 +1,11 @@ +# flake8 does not support pyproject.toml (https://github.com/PyCQA/flake8/issues/234) + +[flake8] +select = F, W, E, C +# We should set max line length lower eventually +max-line-length = 130 +exclude = + docs, + .tox, + .eggs, + build diff --git a/docs/conf.py b/docs/conf.py index 95bb6092..9c7f7426 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,12 +1,10 @@ -from pathlib import Path -import os +import importlib import sys -from configparser import ConfigParser from datetime import datetime -import importlib +from pathlib import Path -import sphinx import stsci_rtd_theme +import tomli def setup(app): @@ -20,19 +18,20 @@ def setup(app): # Modules that automodapi will document need to be available # in the path: -sys.path.insert(0, str(REPO_ROOT/"romanisim")) +sys.path.insert(0, str(REPO_ROOT / "romanisim")) -# Read the package's setup.cfg so that we can use relevant +# Read the package's metadata so that we can use relevant # values here: -conf = ConfigParser() -conf.read(REPO_ROOT/"setup.cfg") -setup_metadata = dict(conf.items("metadata")) +with open(REPO_ROOT / "pyproject.toml", "rb") as configuration_file: + conf = tomli.load(configuration_file) +setup_metadata = conf["project"] project = setup_metadata["name"] -author = setup_metadata["author"] +primary_author = setup_metadata["authors"][0] +author = f'{primary_author["name"]} <{primary_author["email"]}>' copyright = f"{datetime.now().year}, {author}" -package = importlib.import_module(setup_metadata['name']) +package = importlib.import_module(project) try: version = package.__version__.split('-', 1)[0] release = package.__version__ diff --git a/pyproject.toml b/pyproject.toml index 77f4478c..56f44ad6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,111 @@ -# pyproject.toml +[project] +name = 'romanisim' +description = 'Nancy Grace Roman Space Telescope WFI Simulator' +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', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: POSIX', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', +] +dependencies = [ + 'astropy>=5.0.4', + 'asdf>=2.9.2', + 'crds>=10.3.1', + 'gwcs>=0.16.1', + 'jsonschema>=3.0.2', + 'galsim>=2.3', + 'romancal>=0.7', +] +dynamic = ['version'] + +[project.optional-dependencies] +docs = [ + 'sphinx', + 'sphinx-automodapi', + 'sphinx-rtd-theme', + 'stsci-rtd-theme', + 'sphinx-astropy', + 'sphinx-asdf >=0.1.1', + 'tomli; python_version <"3.11"' +] +test = [ + 'ci-watson >=0.3.0', + 'colorama >=0.4.1', + 'getch >=1.0.0', + 'pytest >=4.6.0', + 'pytest-openfiles >=0.5.0', + 'pytest-doctestplus >=0.10.0', + 'pytest-cov >=2.9.0', + 'codecov >=1.6.0', + 'flake8 >=3.6.0', +] + +[project.urls] +'Tracker' = 'https://github.com/spacetelescope/romanisim/issues' +'Documentation' = 'https://romanisim.readthedocs.io/en/stable/' +'Source Code' = 'https://github.com/spacetelescope/romanisim' + +[project.entry-points] +'asdf.extensions' = { jwst_pipeline = 'jwst.transforms.integration:get_extensions' } +asdf_extensions = { jwst_datamodel = 'jwst.datamodels.extension:DataModelExtension' } +'asdf.resource_mappings' = { jwst_pipeline = 'jwst.transforms.integration:get_resource_mappings' } +'stpipe.steps' = { jwst = 'jwst.stpipe.integration:get_steps' } +pytest11 = { report_crds_context = 'pytest_crds.plugin' } + [build-system] -requires = ["setuptools>=38.2.5", - "wheel", - "setuptools_scm"] +requires = [ + 'setuptools >=61', + 'setuptools_scm[toml] >=3.4', + 'wheel', +] +build-backend = 'setuptools.build_meta' + +[tool.setuptools_scm] + +[tool.setuptools] +zip-safe = false + +[tool.setuptools.packages.find] +exclude = ['examples'] + +[tool.pytest.ini_options] +minversion = 4.6 +norecursedirs = [ + 'docs/_build', + 'docs/exts', + 'scripts', + '.tox', +] +doctest_plus = 'enabled' +doctest_rst = 'enabled' + +[tool.coverage] +run = { omit = [ + 'romanisim/conftest.py', + 'romanisim/setup.py', + 'romanisim/tests/test*', + 'docs/*', + # And list these again for running against installed version + '*/romanisim/conftest.py', + '*/romanisim/tests/test*', + '*/romanisim/regtest/test*', + '*/romanisim/*/tests/*', + '*/docs/*', +] } +report = { exclude_lines = [ + 'pragma: no cover', + 'if self.debug:', + 'except ImportError', + 'raise AssertionError', + 'raise NotImplementedError', + 'if __name__ == "__main__":', +] } diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index c84b0105..00000000 --- a/setup.cfg +++ /dev/null @@ -1,105 +0,0 @@ -[metadata] -name = romanisim -description = Roman WFI Simulator -long_description = Nancy Grace Roman Space Telescope WFI Simulator -long_description_content_type = text/plain -author = romanisim Develeopers -license = BSD-3-Clause -url = https://github.com/spacetelescope/romanisim -project_urls = - Tracker = https://github.com/spacetelescope/romanisim/issues - Documentation = https://romanisim.readthedocs.io/en/stable/ - Source Code = https://github.com/spacetelescope/romanisim -classifiers = - Intended Audience :: Science/Research - Topic :: Scientific/Engineering :: Astronomy - License :: OSI Approved :: BSD License - Operating System :: MacOS :: MacOS X - Operating System :: POSIX - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - -[options] -zip_safe = False -python_requires = >=3.8 -setup_requires = - setuptools_scm -install_requires = - astropy>=5.0.4 - asdf>=2.9.2 - crds>=10.3.1 - gwcs>=0.16.1 - jsonschema>=3.0.2 - galsim>=2.3 - romancal>=0.7 - -[options.extras_require] -docs = - sphinx - sphinx-automodapi - sphinx-rtd-theme - stsci-rtd-theme - sphinx-astropy - sphinx-asdf>=0.1.1 -test = - ci-watson>=0.3.0 - colorama>=0.4.1 - getch>=1.0.0 - pytest>=4.6.0 - pytest-openfiles>=0.5.0 - pytest-doctestplus>=0.10.0 - pytest-cov>=2.9.0 - codecov>=1.6.0 - flake8>=3.6.0 - -[build-sphinx] - source-dir = docs - build-dir = docs - all_files = 1 - -[upload_docs] - upload-dir = docs/_build/html - show-response = 1 - -[flake8] -select = F, W, E, C -# We should set max line length lower eventually -max-line-length = 130 -exclude = - docs, - .tox, - .eggs, - build -[tool:pytest] -minversion = 4.6 -norecursedirs = - docs/_build - docs/exts - scripts - .tox -doctest_plus = enabled -doctest_rst = enabled - -[coverage:run] -omit = - romanisim/conftest.py - romanisim/setup.py - romanisim/tests/test* - docs/* - # And list these again for running against installed version - */romanisim/conftest.py - */romanisim/tests/test* - */romanisim/regtest/test* - */romanisim/*/tests/* - */docs/* - -[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 old mode 100755 new mode 100644 index a06548ee..6fb807c9 --- a/setup.py +++ b/setup.py @@ -1,18 +1,7 @@ -#!/usr/bin/env python -import os -import pkgutil -import subprocess -import sys -from setuptools import setup, find_packages, Extension, Command -from setuptools.command.test import test as TestCommand -from glob import glob -from os.path import basename +from pathlib import Path -scripts = [s for s in glob('scripts/*') if basename(s) != '__pycache__'] +from setuptools import setup -setup( - setup_requires=["setuptools_scm"], - packages=find_packages(exclude=["examples"]), - scripts=scripts, - use_scm_version=True, - include_package_data=True,) +scripts = [str(s) for s in Path('scripts/').iterdir() if s.is_file() and s.name != '__pycache__'] + +setup(scripts=scripts) diff --git a/tox.ini b/tox.ini index 541c90cb..cb0e2311 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,7 @@ passenv = commands= !cov: pytest {posargs} - cov: pytest --cov-report=xml --cov=romanisim --cov-config=setup.cfg {posargs} + cov: pytest --cov-report=xml --cov=romanisim --cov-config=pyproject.toml {posargs} [testenv:style] deps=