Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move build configuration into pyproject.toml #13

Merged
merged 3 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
108 changes: 104 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,105 @@
# 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 = 'help@stsci.edu' }]
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 = [
'asdf >=2.9.2',
'astropy >=5.0.4',
'crds >=10.3.1',
'defusedxml',
'galsim >=2.3',
'gwcs >=0.16.1',
'jsonschema >=3.0.2',
'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'

[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__":',
] }
106 changes: 0 additions & 106 deletions setup.cfg

This file was deleted.

15 changes: 4 additions & 11 deletions setup.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
#!/usr/bin/env python
from pathlib import Path

from setuptools import setup, find_packages
from glob import glob
from os.path import basename
from setuptools import setup

scripts = [s for s in glob('scripts/*') if basename(s) != '__pycache__']
scripts = [str(s) for s in Path('scripts/').iterdir() if s.is_file() and s.name != '__pycache__']

setup(
setup_requires=["setuptools_scm"],
packages=find_packages(exclude=["examples"]),
scripts=scripts,
use_scm_version=True,
include_package_data=True,)
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