diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..87ca071f --- /dev/null +++ b/.flake8 @@ -0,0 +1,8 @@ +# 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 = .git,__pycache__,docs,build,dist,.tox,.eggs +ignore = E203, W503, W504, W605 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a59fd02b..5380e5ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: with: python-version: ${{ matrix.python-version }} cache: 'pip' - cache-dependency-path: setup.cfg + cache-dependency-path: 'pyproject.toml' - run: pip install "tox>=4.0" - run: tox -e ${{ matrix.toxenv }} test: @@ -64,7 +64,7 @@ jobs: with: python-version: ${{ matrix.python-version }} cache: 'pip' - cache-dependency-path: setup.cfg + cache-dependency-path: 'pyproject.toml' - run: echo "CRDS_PATH=$HOME/crds_cache" >> $GITHUB_ENV - run: echo "CRDS_SERVER_URL=https://jwst-crds.stsci.edu" >> $GITHUB_ENV - run: pip install crds diff --git a/docs/source/conf.py b/docs/source/conf.py index ceb5cd6b..0018e851 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -6,6 +6,7 @@ import importlib import stsci_rtd_theme +import tomli def setup(app): @@ -21,14 +22,11 @@ def setup(app): # in the path: sys.path.insert(0, str(REPO_ROOT/"src"/"stdatamodels")) -# Read the package's setup.cfg 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: + setup_metadata = tomli.load(configuration_file)['project'] project = setup_metadata["name"] -author = setup_metadata["author"] +author = setup_metadata["authors"][0]["name"] copyright = f"{datetime.now().year}, {author}" package = importlib.import_module(setup_metadata["name"]) diff --git a/pyproject.toml b/pyproject.toml index 560ba074..0e08a614 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,149 @@ +[project] +name = "stdatamodels" +description = "Core support for DataModel classes used in calibration pipelines" +requires-python = ">=3.6" +authors = [ + { name = "STScI" }, +] +classifiers = [ + "Intended Audience :: Science/Research", + "Topic :: Scientific/Engineering :: Astronomy", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python :: 3", +] +dependencies = [ + "jsonschema>=3.0.2", + "asdf>=2.14.1", + "asdf-astropy>=0.3.0", + "psutil>=5.7.2", + "numpy>=1.16", + "astropy>=5.0.4", + "stcal>=1.3.2,<1.4", +] +dynamic = [ + "version", +] + +[project.readme] +file = "README.md" +content-type = "text/markdown" + +[project.license] +file = "LICENSE" +content-type = "text/plain" + +[project.urls] +Homepage = "https://github.com/spacetelescope/stdatamodels" +"Bug Tracker" = "https://github.com/spacetelescope/stdatamodels/issues" +"Source Code" = "https://github.com/spacetelescope/stdatamodels" + +[project.entry-points."asdf.extensions"] +jwst_pipeline = "stdatamodels.jwst.transforms.integration:get_extensions" + +[project.entry-points."asdf.resource_mappings"] +jwst_datamodel = "stdatamodels.jwst.datamodels.integration:get_resource_mappings" +jwst_pipeline = "stdatamodels.jwst.transforms.integration:get_resource_mappings" + +[project.optional-dependencies] +test = [ + "asdf>=2.8.0", + "psutil", + "pytest>=4.6.0", + "pytest-doctestplus", + "pytest-openfiles>=0.5.0", + "crds>=11.16.14", +] +docs = [ + "sphinx", + "sphinx-automodapi", + "numpydoc", + "sphinx-rtd-theme", + "stsci-rtd-theme", + "sphinx-asdf>=0.1.1", +] +aws = [ + "stsci-aws-utils>=0.1.2", +] + [build-system] -requires = ["setuptools>=42", "setuptools_scm[toml]>=3.4", "wheel"] +requires = [ + "setuptools>=61.2", + "setuptools_scm[toml]>=3.4", + "wheel", +] build-backend = "setuptools.build_meta" +[tool.setuptools] +zip-safe = true +include-package-data = false + +[tool.setuptools.packages.find] +where = [ + "src", +] +namespaces = false + +[tool.setuptools.package-dir] +"" = "src" + +[tool.setuptools.package-data] +"*" = [ + "*.yaml", +] +"stdatamodels.jwst.transforms" = [ + "resources/schemas/stsci.edu/jwst_pipeline/*.yaml", +] + +[tool.flake8] +exclude = [ + ".git", + "__pycache__", + "docs", + "build", + "dist", + ".tox", + ".eggs", +] +ignore = [ + "E203", + "W503", + "W504", + "W605", +] +max-line-length = 130 +select = [ + "F", + "W", + "E101", + "E111", + "E112", + "E113", + "E401", + "E402", + "E501", + "E711", + "E722", +] + +[tool.pytest.ini_options] +minversion = "4.6" +doctest_plus = true +doctest_rst = true +text_file_format = "rst" +addopts = "--open-files" +testpaths = [ + "tests", + "src/stdatamodels/jwst", +] +asdf_schema_tests_enabled = true +asdf_schema_validate_default = false +asdf_schema_root = "src/stdatamodels/jwst/datamodels/schemas\nsrc/stdatamodels/jwst/transforms/resources/schemas" +norecursedirs = [ + "build", + ".tox", + ".eggs", + "venv", +] + [tool.setuptools_scm] write_to = "src/stdatamodels/_version.py" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 9f08b64e..00000000 --- a/setup.cfg +++ /dev/null @@ -1,88 +0,0 @@ -[metadata] -name = stdatamodels -description = Core support for DataModel classes used in calibration pipelines -long_description = Core support for DataModel classes used in calibration pipelines -long_description_content_type = text/markdown -author = STScI -license = BSD-3-Clause -url = https://github.com/spacetelescope/stdatamodels -project_urls = - Bug Tracker = https://github.com/spacetelescope/stdatamodels/issues - Source Code = https://github.com/spacetelescope/stdatamodels -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.6 -setup_requires = - setuptools_scm -install_requires = - jsonschema>=3.0.2 - asdf>=2.14.1 - asdf-astropy>=0.3.0 - psutil>=5.7.2 - numpy>=1.16 - astropy>=5.0.4 - stcal>=1.3.2,<1.4 -package_dir = - =src -packages = find: - -[options.packages.find] -where = src - -[options.extras_require] -test = - asdf>=2.8.0 - psutil - pytest>=4.6.0 - pytest-doctestplus - pytest-openfiles>=0.5.0 - crds>=11.16.14 -docs = - sphinx - sphinx-automodapi - numpydoc - sphinx-rtd-theme - stsci-rtd-theme - sphinx-asdf>=0.1.1 -aws = - stsci-aws-utils>=0.1.2 - -[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 = .git,__pycache__,docs,build,dist,.tox,.eggs -ignore = E203, W503, W504, W605 - -[tool:pytest] -minversion = 4.6 -doctest_plus = true -doctest_rst = true -text_file_format = rst -addopts = --open-files -testpaths = - tests - src/stdatamodels/jwst -asdf_schema_tests_enabled = true -asdf_schema_validate_default = false -asdf_schema_root = - src/stdatamodels/jwst/datamodels/schemas - src/stdatamodels/jwst/transforms/resources/schemas -norecursedirs = - build - .tox - .eggs - venv - -[options.entry_points] -asdf.extensions = - jwst_pipeline = stdatamodels.jwst.transforms.integration:get_extensions -asdf.resource_mappings = - jwst_datamodel = stdatamodels.jwst.datamodels.integration:get_resource_mappings - jwst_pipeline = stdatamodels.jwst.transforms.integration:get_resource_mappings diff --git a/setup.py b/setup.py deleted file mode 100644 index 35b81509..00000000 --- a/setup.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python3 -from setuptools import setup - -package_data = { - "": [ - "*.yaml", - ], - # Include the transforms schemas - "stdatamodels.jwst.transforms": [ - "resources/schemas/stsci.edu/jwst_pipeline/*.yaml", - ], -} - -setup( - use_scm_version={"write_to": "src/stdatamodels/_version.py"}, - package_data=package_data, -) diff --git a/tox.ini b/tox.ini index 20c7d8a1..c2f7246c 100644 --- a/tox.ini +++ b/tox.ini @@ -57,7 +57,7 @@ commands_pre = commands = pytest \ xdist: -n auto \ - cov: --cov=. --cov-config=setup.cfg --cov-report=term-missing --cov-report=xml \ + cov: --cov=. --cov-config=pyproject.toml --cov-report=term-missing --cov-report=xml \ jwst: --pyargs jwst --ignore-glob=*/scripts/* \ # TODO: fix bug with `.finalize()` in `jwst.associations` jwst: --ignore-glob=*/associations/tests/test_dms.py \