Skip to content

Commit

Permalink
move build configuration into pyproject.toml (#98)
Browse files Browse the repository at this point in the history
* move build configuration into `pyproject.toml`

* move `setup.cfg` to `.flake8`
  • Loading branch information
zacharyburnett authored Feb 14, 2023
1 parent a9e69b0 commit 1c51d86
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 115 deletions.
8 changes: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import importlib

import stsci_rtd_theme
import tomli


def setup(app):
Expand All @@ -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"])
Expand Down
145 changes: 144 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
88 changes: 0 additions & 88 deletions setup.cfg

This file was deleted.

17 changes: 0 additions & 17 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 1c51d86

Please sign in to comment.