From 1b99f2d237a492a1991365bde9b3e58bb5fa5102 Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Mon, 16 May 2022 13:36:40 -0400 Subject: [PATCH] move build configuration from `setup.cfg` to `pyproject.toml` --- docs/conf.py | 11 ++- pyproject.toml | 177 +++++++++++++++++++++++++++++++++++++++++++++++-- setup.cfg | 173 ----------------------------------------------- setup.py | 155 +++++++++++++++++++++---------------------- tox.ini | 4 +- 5 files changed, 254 insertions(+), 266 deletions(-) delete mode 100644 setup.cfg diff --git a/docs/conf.py b/docs/conf.py index 271642b7d06..3c67fdb7832 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -15,6 +15,8 @@ import importlib import sys import os + +import toml from packaging.version import Version from configparser import ConfigParser @@ -28,9 +30,6 @@ def setup(app): except AttributeError: 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 # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -39,8 +38,8 @@ def setup(app): sys.path.insert(0, os.path.abspath('exts/')) # -- General configuration ------------------------------------------------ -conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')]) -setup_cfg = dict(conf.items('metadata')) +conf = toml.load('../pyproject.toml') +setup_cfg = conf['project'] # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.3' @@ -130,7 +129,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 242c2ae32f7..7b01161a229 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,177 @@ +[project] +name = 'jwst' +version = '0.0.0' +description = 'Library for calibration of science observations from the James Webb Space Telescope' +readme = 'README.md' +requires-python = '>=3.8' +license = { file = 'LICENSE' } +authors = [{ name = 'JWST calibration pipeline developers' }] +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 = [ + 'asdf >=2.11.1', + 'asdf-astropy >=0.2.1', + 'astropy >=5.0.4', + 'BayesicFitting >=2.7.2', + 'crds >=11.13.1', + 'drizzle >=1.13.4', + 'gwcs >=0.18.0', + 'jsonschema >=4.0.1', + 'numpy >=1.20', + 'photutils >=1.4.0', + 'psutil >=5.7.2', + 'poppy >=1.0.2', + 'pyparsing >=2.2.1', + 'requests >=2.22', + 'scikit-image >=0.17.2', + 'scipy >=1.6.0', + 'spherical-geometry >=1.2.22', + 'stcal >=0.7', + 'stdatamodels >=0.4.2, <1.0', + 'stpipe >=0.3.3, <1.0', + 'stsci.image >=2.3.5', + 'stsci.imagestats >=1.6.3', + 'tweakwcs >=0.7.2', +] + +[project.optional-dependencies] +aws = ['stsci-aws-utils >=0.1.2'] +docs = [ + 'packaging', + 'matplotlib', + 'mistune ~=0.8.4', + 'sphinx', + 'sphinx-asdf >=0.1.1', + 'sphinx-astropy', + 'sphinx-automodapi', + 'sphinx-rtd-theme', + 'stsci-rtd-theme', + 'toml', +] +sdp = [ + 'jplephem >=2.9', + 'pymssql', + 'pysiaf', +] +test = [ + 'ci-watson >=0.5.0', + 'codecov >=1.6.0', + 'colorama >=0.4.1', + 'flake8 >=3.6.0', + 'getch >=1.0.0', + 'pyproject-flake8', + 'pytest >=6.0.0', + 'pytest-cov >=2.9.0', + 'pytest-doctestplus >=0.10.0', + 'pytest-openfiles >=0.5.0', + 'requests_mock >=1.0', +] + +[project.urls] +'documentation' = 'https://jwst-pipeline.readthedocs.io/en/stable/' +'repository' = 'https://github.com/spacetelescope/jwst' +'tracker' = 'https://github.com/spacetelescope/jwst/issues' + +[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>=42", - "setuptools_scm[toml]>=3.4", - "wheel", - "oldest-supported-numpy", + 'setuptools>=42', + 'setuptools_scm[toml]>=3.4', + 'wheel', + 'oldest-supported-numpy', ] -build-backend = "setuptools.build_meta" +build-backend = 'setuptools.build_meta' [tool.setuptools_scm] + +[tool.setuptools] +packages = ['jwst'] + +[tool.flake8] +select = ['F', 'W', 'E', 'C'] +# We should set max line length lower eventually +max-line-length = 130 +exclude = [ + 'jwst/extern', + 'docs', + 'jwst/associations', + 'jwst/fits_generator', + '.tox', + '.eggs', + 'build', +] +per-file-ignores = [ + 'jwst/ramp_fitting/tests/compare_cr_navg_files.py:E', + 'jwst/ramp_fitting/tests/compare_crs.py:E', + 'jwst/ramp_fitting/tests/compare_cr_files.py:E', + 'jwst/ramp_fitting/tests/create_cube.py:E', + 'jwst/ramp_fitting/tests/mc_3d.py:E', +] +ignore = [ + 'E231', # Missing whitespace after ',', ';', or ':' + 'E241', # Multiple spaces after ',' + 'W503', # Line break occurred before a binary operator + 'W504', # Line break occurred after a binary operator +] + +[tool.pytest] +minversion = 6.0 +norecursedirs = [ + 'docs/_build', + 'docs/exts', + 'jwst/timeconversion', + 'jwst/associations/tests/data', + 'scripts', + '.tox', +] +asdf_schema_tests_enabled = true +asdf_schema_validate_default = false +asdf_schema_root = 'jwst/transforms/resources/schemas jwst/datamodels/schemas' +junit_family = 'xunit2' +inputs_root = 'jwst-pipeline' +results_root = 'jwst-pipeline-results' +text_file_format = 'rst' +doctest_plus = 'enabled' +doctest_rst = 'enabled' +addopts = '--show-capture=no --open-files --report-crds-context' +filterwarnings = ['ignore:Models in math_functions:astropy.utils.exceptions.AstropyUserWarning'] + +[tool.coverage] +run = { omit = [ + 'jwst/conftest.py', + 'jwst/setup.py', + 'jwst/tests/test*', + 'jwst/regtest/test*', + 'jwst/*/tests/*', + 'docs/*', + # And list these again for running against installed version + '*/jwst/conftest.py', + '*/jwst/setup.py', + '*/jwst/tests/test*', + '*/jwst/regtest/test*', + '*/jwst/*/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 907b857b871..00000000000 --- a/setup.cfg +++ /dev/null @@ -1,173 +0,0 @@ -[metadata] -name = jwst -description = Library for calibration of science observations from the James Webb Space Telescope -long_description = Library for calibration of science observations from the James Webb Space Telescope -long_description_content_type = text/plain -author = JWST calibration pipeline developers -license = BSD-3-Clause -url = https://github.com/spacetelescope/jwst -project_urls = - Tracker = https://github.com/spacetelescope/jwst/issues - Documentation = https://jwst-pipeline.readthedocs.io/en/stable/ - Source Code = https://github.com/spacetelescope/jwst -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 = - asdf>=2.11.1 - astropy>=5.0.4 - BayesicFitting>=2.7.2 - crds>=11.13.1 - drizzle>=1.13.4 - gwcs>=0.18.0 - jsonschema>=4.0.1 - numpy>=1.20 - photutils>=1.4.0 - psutil>=5.7.2 - poppy>=1.0.2 - pyparsing>=2.2.1 - requests>=2.22 - scikit-image>=0.17.2 - scipy>=1.6.0 - spherical-geometry>=1.2.22 - stcal>=0.7 - stdatamodels>=0.4.2,<1.0 - stpipe>=0.3.3,<1.0 - stsci.image>=2.3.5 - stsci.imagestats>=1.6.3 - tweakwcs>=0.7.2 - asdf-astropy>=0.2.1 - -[options.extras_require] -aws = - stsci-aws-utils>=0.1.2 -docs = - packaging - matplotlib - sphinx - sphinx-asdf>=0.1.1 - sphinx-astropy - sphinx-automodapi - sphinx-rtd-theme - stsci-rtd-theme - mistune~=0.8.4 -sdp = - jplephem>=2.9 - pymssql>=2.1.6 - pysiaf>=0.13.0 -test = - ci-watson>=0.5.0 - codecov>=1.6.0 - colorama>=0.4.1 - flake8>=3.6.0 - getch>=1.0.0 - pytest>=6.0.0 - pytest-cov>=2.9.0 - pytest-doctestplus>=0.10.0 - pytest-openfiles>=0.5.0 - requests_mock>=1.0 - -[options.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-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 = - jwst/extern, - docs, - jwst/associations, - jwst/fits_generator, - .tox, - .eggs, - build -per-file-ignores = - jwst/ramp_fitting/tests/compare_cr_navg_files.py:E - jwst/ramp_fitting/tests/compare_crs.py:E - jwst/ramp_fitting/tests/compare_cr_files.py:E - jwst/ramp_fitting/tests/create_cube.py:E - jwst/ramp_fitting/tests/mc_3d.py:E -ignore = - E231, # Missing whitespace after ',', ';', or ':' - E241, # Multiple spaces after ',' - W503, # Line break occurred before a binary operator - W504, # Line break occurred after a binary operator - -[tool:pytest] -minversion = 6.0 -norecursedirs = - docs/_build - docs/exts - jwst/timeconversion - jwst/associations/tests/data - scripts - .tox -asdf_schema_tests_enabled = true -asdf_schema_validate_default = false -asdf_schema_root = jwst/transforms/resources/schemas jwst/datamodels/schemas -junit_family = xunit2 -inputs_root = jwst-pipeline -results_root = jwst-pipeline-results -text_file_format = rst -doctest_plus = enabled -doctest_rst = enabled -addopts = --show-capture=no --open-files --report-crds-context -filterwarnings = - ignore:Models in math_functions:astropy.utils.exceptions.AstropyUserWarning - -[coverage:run] -omit = - jwst/conftest.py - jwst/setup.py - jwst/tests/test* - jwst/regtest/test* - jwst/*/tests/* - docs/* - # And list these again for running against installed version - */jwst/conftest.py - */jwst/setup.py - */jwst/tests/test* - */jwst/regtest/test* - */jwst/*/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 index 2cbaddafb2d..b6976b988e1 100644 --- a/setup.py +++ b/setup.py @@ -1,97 +1,92 @@ -from os.path import basename -from setuptools import setup, find_packages, Extension from glob import glob +from os.path import basename + import numpy +from setuptools import Extension, setup +scripts = [s for s in glob('scripts/*') if basename(s) != '__pycache__'] + +# Setup C module include directories +include_dirs = [numpy.get_include()] + +# Setup C module macros +define_macros = [('NUMPY', '1')] + +extensions = [ + Extension( + 'jwst.lib.winclip', + ['jwst/lib/src/winclip.c'], + include_dirs=include_dirs, + define_macros=define_macros + ), + Extension( + 'jwst.cube_build.cube_match_internal', + ['jwst/cube_build/src/cube_match_internal.c', 'jwst/cube_build/src/cube_utils.c'], + include_dirs=include_dirs, + define_macros=define_macros + ), + Extension( + 'jwst.cube_build.cube_match_sky_pointcloud', + ['jwst/cube_build/src/cube_match_sky_pointcloud.c', 'jwst/cube_build/src/cube_utils.c', + 'jwst/cube_build/src/cube_dq_utils.c'], + include_dirs=include_dirs, + define_macros=define_macros + ), + Extension( + 'jwst.cube_build.cube_match_sky_driz', + ['jwst/cube_build/src/cube_match_sky_driz.c', 'jwst/cube_build/src/cube_utils.c', + 'jwst/cube_build/src/cube_dq_utils.c'], + include_dirs=include_dirs, + define_macros=define_macros + ), + Extension( + 'jwst.cube_build.blot_median', + ['jwst/cube_build/src/blot_median.c'], + include_dirs=include_dirs, + define_macros=define_macros + ) +] -scripts = [s for s in glob("scripts/*") if basename(s) != "__pycache__"] -# package_data values are glob patterns relative to each specific subpackage. package_data = { - "": [ - "*.asdf", - "*.cfg", - "tests/data/*.csv", - "tests/data/*.ecsv", - "tests/data/*.fits", - "tests/data/**/*.fits", - "*.json", - "tests/data/*.json", - "tests/data/**/*.json", - "tests/data/*.txt", - "*.yaml", - "*.cat", - "*.hdr", + # package_data values are glob patterns relative to each specific subpackage. + '': [ + '*.asdf', + '*.cfg', + 'tests/data/*.csv', + 'tests/data/*.ecsv', + 'tests/data/*.fits', + 'tests/data/**/*.fits', + '*.json', + 'tests/data/*.json', + 'tests/data/**/*.json', + 'tests/data/*.txt', + '*.yaml', + '*.cat', + '*.hdr', ], - - "jwst.fits_generator": [ - "templates/*.inc", - "templates/*.txt", - "tests/okfile/*.prop", + 'jwst.fits_generator': [ + 'templates/*.inc', + 'templates/*.txt', + 'tests/okfile/*.prop', ], - - "jwst.lib": [ - "tests/data/*.asdf", - "tests/data/*.db", - "tests/data/*.ecsv", - "tests/data/*.fits", + 'jwst.lib': [ + 'tests/data/*.asdf', + 'tests/data/*.db', + 'tests/data/*.ecsv', + 'tests/data/*.fits', ], - # Include the rules .py files in associations test data - "jwst.associations": ["tests/data/*.py"], - + 'jwst.associations': ['tests/data/*.py'], # Include C extensions - "jwst.lib.src": ["*.c"], - "jwst.cube_build.src": ["*.c"], - + 'jwst.lib.src': ['*.c'], + 'jwst.cube_build.src': ['*.c'], # Include the transforms schemas - "jwst.transforms": ["resources/schemas/stsci.edu/jwst_pipeline/*.yaml"], - "jwst.stpipe.resources": ["schemas/*.yaml"], + 'jwst.transforms': ['resources/schemas/stsci.edu/jwst_pipeline/*.yaml'], + 'jwst.stpipe.resources': ['schemas/*.yaml'], } -# Setup C module include directories -include_dirs = [numpy.get_include()] - -# Setup C module macros -define_macros = [('NUMPY', '1')] - setup( - use_scm_version=True, - setup_requires=["setuptools_scm"], scripts=scripts, - packages=find_packages(), package_data=package_data, - ext_modules=[ - Extension( - 'jwst.lib.winclip', - ['jwst/lib/src/winclip.c'], - include_dirs=include_dirs, - define_macros=define_macros - ), - Extension( - 'jwst.cube_build.cube_match_internal', - ['jwst/cube_build/src/cube_match_internal.c','jwst/cube_build/src/cube_utils.c'], - include_dirs=include_dirs, - define_macros=define_macros - ), - Extension( - 'jwst.cube_build.cube_match_sky_pointcloud', - ['jwst/cube_build/src/cube_match_sky_pointcloud.c','jwst/cube_build/src/cube_utils.c', - 'jwst/cube_build/src/cube_dq_utils.c'], - include_dirs=include_dirs, - define_macros=define_macros - ), - Extension( - 'jwst.cube_build.cube_match_sky_driz', - ['jwst/cube_build/src/cube_match_sky_driz.c','jwst/cube_build/src/cube_utils.c', - 'jwst/cube_build/src/cube_dq_utils.c'], - include_dirs=include_dirs, - define_macros=define_macros - ), - Extension( - 'jwst.cube_build.blot_median', - ['jwst/cube_build/src/blot_median.c'], - include_dirs=include_dirs, - define_macros=define_macros - ) - ], + ext_modules=extensions, ) diff --git a/tox.ini b/tox.ini index 8f6ba90e6a0..0115807cb63 100644 --- a/tox.ini +++ b/tox.ini @@ -88,9 +88,9 @@ commands = description = check code style, e.g. with flake8 skip_install = true deps = - flake8 + pyproject-flake8 commands = - flake8 {posargs} + pflake8 {posargs} [testenv:verify-install-requires] description = verify that install_requires in setup.cfg is correct