Skip to content

Commit

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

* `asdf` test plugin can only read a string

* Fix docs build

* make `tomli` dependent on python version

* add change log entry

Co-authored-by: William Jamieson <wjamieson@stsci.edu>
  • Loading branch information
zacharyburnett and WilliamJamieson authored Jan 5, 2023
1 parent 8a4363e commit 0fd1569
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 93 deletions.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# flake8 does not support pyproject.toml (https://github.com/PyCQA/flake8/issues/234)

[flake8]
max-line-length = 130
ignore = E203, W503, W504, W605, E741
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
0.15.0 (unreleased)
==================
-------------------

- Update guidwindow titles and descriptions. [#193]

Expand All @@ -9,6 +9,8 @@

- Fix ``enum`` bug in schemas. [#194]

- move metadata to ``pyproject.toml`` in accordance with PEP621 [#196]

0.14.0 (2022-11-04)
-------------------

Expand Down
30 changes: 13 additions & 17 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

import stsci_rtd_theme

from pathlib import Path
from importlib_metadata import distribution
import tomli

# Ensure documentation examples are determinstically random.
import numpy

Expand All @@ -42,14 +46,11 @@
print("ERROR: the documentation requires the sphinx-astropy package to be installed")
sys.exit(1)

# Get configuration information from setup.cfg
try:
from ConfigParser import ConfigParser
except ImportError:
from configparser import ConfigParser
conf = ConfigParser()
conf.read([os.path.join(os.path.dirname(__file__), "..", "setup.cfg")])
setup_cfg = dict(conf.items("metadata"))
# Get configuration information from pyproject.toml
with open(Path(__file__).parent.parent / "pyproject.toml", "rb") as configuration_file:
conf = tomli.load(configuration_file)
configuration = conf["project"]


# -- General configuration ----------------------------------------------------

Expand Down Expand Up @@ -77,16 +78,11 @@
# -- Project information ------------------------------------------------------

# This does not *have* to match the package name, but typically does
project = setup_cfg["name"]
author = setup_cfg["author"]
copyright = "{0}, {1}".format(datetime.datetime.now().year, setup_cfg["author"])

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
from pkg_resources import get_distribution # noqa
project = configuration["name"]
author = f"{configuration['authors'][0]['name']} <{configuration['authors'][0]['email']}>"
copyright = f"{datetime.datetime.now().year}, {configuration['authors'][0]['name']}"

release = get_distribution(setup_cfg["name"]).version
release = distribution(configuration["name"]).version
# for example take major/minor
version = ".".join(release.split(".")[:2])

Expand Down
70 changes: 69 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,74 @@
[project]
name = 'rad'
description = 'Roman Attribute Dictionary'
readme = { file = 'README.md', content-type = 'text/x-markdown' }
requires-python = '>=3.6'
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.14.2',
]
dynamic = ['version']

[project.optional-dependencies]
test = [
'pytest>=4.6.0',
'pytest-openfiles>=0.5.0',
'pytest-doctestplus>=0.11.1',
]
docs = [
'sphinx',
'sphinx-asdf>=0.1.3',
'sphinx-astropy',
'astropy>=5.0.4',
'graphviz',
'matplotlib',
'docutils',
'stsci-rtd-theme',
'tomli; python_version <"3.11"',
'importlib-metadata',
]

[project.urls]
'Bug Tracker' = 'https://github.com/spacetelescope/rad/issues'
'Source Code' = 'https://github.com/spacetelescope/rad'

[project.entry-points]
'asdf.resource_mappings' = { 'rad' = 'rad.integration:get_resource_mappings' }

[build-system]
requires = ["setuptools>=42", "setuptools_scm[toml]>=3.4", "wheel"]
requires = ["setuptools >=61", "setuptools_scm[toml] >=3.4", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "src/rad/_version.py"

[tool.setuptools.packages.find]
where = ['src']

[tool.package-data]
'rad.resources' = [
'manifests/*.yaml',
'schemas/*.yaml',
'schemas/**/*.yaml',
]

[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',
'src/rad/resources/schemas',
]
asdf_schema_tests_enabled = 'true'
asdf_schema_skip_tests = 'src/rad/resources/schemas/rad_schema-1.0.0.yaml'
asdf_schema_root = 'src/rad/resources/schemas'
68 changes: 0 additions & 68 deletions setup.cfg

This file was deleted.

6 changes: 0 additions & 6 deletions setup.py

This file was deleted.

0 comments on commit 0fd1569

Please sign in to comment.