Skip to content

Commit

Permalink
move build configuration into pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett committed Oct 26, 2022
1 parent 05f83ad commit 3c302e1
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 138 deletions.
11 changes: 11 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# flake8 does not support pyproject.toml (https://github.com/PyCQA/flake8/issues/234)

[flake8]
select = F, W, E, C
# We should set max line length lower eventually
max-line-length = 130
exclude =
docs,
.tox,
.eggs,
build
23 changes: 11 additions & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from pathlib import Path
import os
import importlib
import sys
from configparser import ConfigParser
from datetime import datetime
import importlib
from pathlib import Path

import sphinx
import stsci_rtd_theme
import tomli


def setup(app):
Expand All @@ -20,19 +18,20 @@ def setup(app):

# Modules that automodapi will document need to be available
# in the path:
sys.path.insert(0, str(REPO_ROOT/"romanisim"))
sys.path.insert(0, str(REPO_ROOT / "romanisim"))

# Read the package's setup.cfg so that we can use relevant
# Read the package's metadata 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:
conf = tomli.load(configuration_file)
setup_metadata = conf["project"]

project = setup_metadata["name"]
author = setup_metadata["author"]
primary_author = setup_metadata["authors"][0]
author = f'{primary_author["name"]} <{primary_author["email"]}>'
copyright = f"{datetime.now().year}, {author}"

package = importlib.import_module(setup_metadata['name'])
package = importlib.import_module(project)
try:
version = package.__version__.split('-', 1)[0]
release = package.__version__
Expand Down
114 changes: 110 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,111 @@
# pyproject.toml
[project]
name = 'romanisim'
description = 'Nancy Grace Roman Space Telescope WFI Simulator'
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',
'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 = [
'astropy>=5.0.4',
'asdf>=2.9.2',
'crds>=10.3.1',
'gwcs>=0.16.1',
'jsonschema>=3.0.2',
'galsim>=2.3',
'romancal>=0.7',
]
dynamic = ['version']

[project.optional-dependencies]
docs = [
'sphinx',
'sphinx-automodapi',
'sphinx-rtd-theme',
'stsci-rtd-theme',
'sphinx-astropy',
'sphinx-asdf >=0.1.1',
'tomli; python_version <"3.11"'
]
test = [
'ci-watson >=0.3.0',
'colorama >=0.4.1',
'getch >=1.0.0',
'pytest >=4.6.0',
'pytest-openfiles >=0.5.0',
'pytest-doctestplus >=0.10.0',
'pytest-cov >=2.9.0',
'codecov >=1.6.0',
'flake8 >=3.6.0',
]

[project.urls]
'Tracker' = 'https://github.com/spacetelescope/romanisim/issues'
'Documentation' = 'https://romanisim.readthedocs.io/en/stable/'
'Source Code' = 'https://github.com/spacetelescope/romanisim'

[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>=38.2.5",
"wheel",
"setuptools_scm"]
requires = [
'setuptools >=61',
'setuptools_scm[toml] >=3.4',
'wheel',
]
build-backend = 'setuptools.build_meta'

[tool.setuptools_scm]

[tool.setuptools]
zip-safe = false

[tool.setuptools.packages.find]
exclude = ['examples']

[tool.pytest.ini_options]
minversion = 4.6
norecursedirs = [
'docs/_build',
'docs/exts',
'scripts',
'.tox',
]
doctest_plus = 'enabled'
doctest_rst = 'enabled'

[tool.coverage]
run = { omit = [
'romanisim/conftest.py',
'romanisim/setup.py',
'romanisim/tests/test*',
'docs/*',
# And list these again for running against installed version
'*/romanisim/conftest.py',
'*/romanisim/tests/test*',
'*/romanisim/regtest/test*',
'*/romanisim/*/tests/*',
'*/docs/*',
] }
report = { exclude_lines = [
'pragma: no cover',
'if self.debug:',
'except ImportError',
'raise AssertionError',
'raise NotImplementedError',
'if __name__ == "__main__":',
] }
105 changes: 0 additions & 105 deletions setup.cfg

This file was deleted.

21 changes: 5 additions & 16 deletions setup.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
#!/usr/bin/env python
import os
import pkgutil
import subprocess
import sys
from setuptools import setup, find_packages, Extension, Command
from setuptools.command.test import test as TestCommand
from glob import glob
from os.path import basename
from pathlib import Path

scripts = [s for s in glob('scripts/*') if basename(s) != '__pycache__']
from setuptools import setup

setup(
setup_requires=["setuptools_scm"],
packages=find_packages(exclude=["examples"]),
scripts=scripts,
use_scm_version=True,
include_package_data=True,)
scripts = [str(s) for s in Path('scripts/').iterdir() if s.is_file() and s.name != '__pycache__']

setup(scripts=scripts)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ passenv =

commands=
!cov: pytest {posargs}
cov: pytest --cov-report=xml --cov=romanisim --cov-config=setup.cfg {posargs}
cov: pytest --cov-report=xml --cov=romanisim --cov-config=pyproject.toml {posargs}

[testenv:style]
deps=
Expand Down

0 comments on commit 3c302e1

Please sign in to comment.