Skip to content

Commit

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

* use `setuptools>=61`

* apply review comments

* fix TOML decoding error

* apply review comment

* update Sphinx extensions

Co-authored-by: William Jamieson <[email protected]>

* character fix

* update author extraction

* Update pyproject.toml

* fix docs metadata

* update from main

* update dependencies

Co-authored-by: William Jamieson <[email protected]>
  • Loading branch information
zacharyburnett and WilliamJamieson authored Jan 5, 2023
1 parent 5c9c58f commit 35d88b2
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 111 deletions.
9 changes: 9 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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 =
docs,
ignore = E203, W503, W504, W605
17 changes: 9 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
import importlib
import os
import sys
from configparser import ConfigParser
from distutils.version import LooseVersion
from pathlib import Path

import sphinx
import stsci_rtd_theme
import tomli


def setup(app):
Expand All @@ -29,17 +30,16 @@ def setup(app):
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.
sys.path.insert(0, os.path.abspath('../'))
sys.path.insert(0, os.path.abspath('roman_datamodels/'))

# -- General configuration ------------------------------------------------
conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')])
setup_cfg = dict(conf.items('metadata'))
with open(Path(__file__).parent.parent / "pyproject.toml", "rb") as configuration_file:
conf = tomli.load(configuration_file)
setup_cfg = conf['project']

# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.3'
Expand Down Expand Up @@ -122,15 +122,16 @@ def check_sphinx_version(expected_version):

# General information about the project
project = setup_cfg['name']
author = setup_cfg['author']
copyright = '{0}, {1}'.format(datetime.datetime.now().year, author)
primary_author = setup_cfg["authors"][0]
author = f'{primary_author["name"]} <{primary_author["email"]}>'
copyright = f'{datetime.datetime.now().year}, {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.
#
# The short X.Y version.
package = importlib.import_module(setup_cfg['name'])
package = importlib.import_module(project)
try:
version = package.__version__.split('-', 1)[0]
# The full version, including alpha/beta/rc tags.
Expand Down
91 changes: 90 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,95 @@
[project]
name = 'roman_datamodels'
description = 'data models supporting calibration of the Nancy Grace Roman Space Telescope'
readme = 'README.md'
requires-python = '>=3.8'
license = { file = 'LICENSE' }
authors = [{ name = 'STScI', email = '[email protected]' }]
classifiers = [
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Astronomy',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 3',
]
dependencies = [
'asdf >=2.13.0',
'asdf-astropy >=0.3.0',
'gwcs >=0.18.1',
'psutil >=5.7.2',
'numpy',
'astropy >=5.0.4',
#'rad >=0.14.0',
# Temporary path for github PR tests
'rad @git+https://github.com/spacetelescope/rad.git@main',
'asdf-standard >=1.0.3',
]
dynamic = ['version']

[project.optional-dependencies]
test = [
'pytest >=6.0.0',
'pytest-doctestplus',
'pytest-openfiles >=0.5.0',
'pytest-doctestplus >=0.10.0',
]
aws = [
'stsci-aws-utils >= 0.1.2',
]
docs = [
'sphinx',
'sphinx-automodapi',
'sphinx-rtd-theme',
'stsci-rtd-theme',
'sphinx-astropy',
'sphinx-asdf',
'tomli; python_version <"3.11"',
]

[project.urls]
'issues' = 'https://github.com/spacetelescope/roman_datamodels/issues'
'repository' = 'https://github.com/spacetelescope/roman_datamodels'

[project.entry-points]
'asdf.extensions' = { roman_datamodels = 'roman_datamodels.integration:get_extensions' }

[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/roman_datamodels/_version.py"

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

[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']

[tool.coverage.run]
omit = [
'roman_datamodels/pyproject.toml',
'roman_datamodels/tests',
# And list these again for running against installed version
'*/roman_datamodels/pyproject.toml',
'*/roman_datamodels/tests',
'*/roman_datamodels/src/roman_datamodels/mktest.py',
]

[tool.coverage.report]
exclude_lines = [
# Have to re-enable the standard pragma
'pragma: no cover',
# Don't complain about packages we have installed
'except ImportError',
# Don't complain if tests don't hit assertions
'raise AssertionError',
'raise NotImplementedError',
# Don't complain about script hooks
'def main\(.*\):',
'if __name__ == \(.*\):',
]
96 changes: 0 additions & 96 deletions setup.cfg

This file was deleted.

6 changes: 0 additions & 6 deletions setup.py

This file was deleted.

1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[tox]
envlist= py38,py310,style,bandit
isolated_build = True

[testenv]
extras= test
Expand Down

0 comments on commit 35d88b2

Please sign in to comment.