Skip to content

Commit

Permalink
Merge pull request #279 from zacharyburnett/pep621
Browse files Browse the repository at this point in the history
move build configuration to `pyproject.toml`
  • Loading branch information
mfixstsci authored Aug 21, 2023
2 parents d6a9b6f + ce9248c commit d3ac5eb
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 214 deletions.
59 changes: 27 additions & 32 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,22 @@

import datetime
import importlib
import sys
import os
import sphinx
import stsci_rtd_theme
import sys
if sys.version_info < (3, 11):
import tomli as tomllib
else:
import tomllib


def setup(app):
app.add_stylesheet("stsci.css")
# app.add_stylesheet("default.css")



from distutils.version import LooseVersion
try:
from ConfigParser import ConfigParser
except ImportError:
from configparser import ConfigParser
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
Expand All @@ -40,8 +39,9 @@ def setup(app):
sys.path.insert(0, os.path.abspath('exts/'))

# -- 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 = tomllib.load(configuration_file)
setup_cfg = conf['project']

# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = '1.3'
Expand All @@ -58,13 +58,14 @@ def check_sphinx_version(expected_version):
"documentation. Found {1}.".format(
expected_version, sphinx_version))


# Configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'python': ('http://docs.python.org/3/', None),
'numpy': ('http://docs.scipy.org/doc/numpy/', None),
'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None),
'matplotlib': ('http://matplotlib.org/', None),
}
}

if sys.version_info[0] == 2:
intersphinx_mapping['python'] = ('http://docs.python.org/2/', None)
Expand All @@ -76,12 +77,14 @@ def check_sphinx_version(expected_version):
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx_automodapi.automodapi',
'sphinx_automodapi.automodsumm',
'numpydoc',
'sphinx.ext.autodoc',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',]
extensions = [
'sphinx_automodapi.automodapi',
'sphinx_automodapi.automodsumm',
'numpydoc',
'sphinx.ext.autodoc',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
]

# extensions = [
# 'numfig',
Expand Down Expand Up @@ -132,11 +135,10 @@ def check_sphinx_version(expected_version):
# Suppress the warnings requires Sphinx v1.4.2
suppress_warnings = ['app.add_directive', ]


# General information about the project
project = setup_cfg['package_name']
author = setup_cfg['author']
copyright = '{0}, {1}'.format(datetime.datetime.now().year, author)
author = f'{setup_cfg["authors"][0]["name"]} <{setup_cfg["authors"][0]["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
Expand Down Expand Up @@ -170,7 +172,6 @@ def check_sphinx_version(expected_version):
# documents.
default_role = 'obj'


# Don't show summaries of the members in each class along with the
# class' docstring
# numpydoc_show_class_members = False
Expand All @@ -196,7 +197,6 @@ def check_sphinx_version(expected_version):
'-Gfontname=Helvetica Neue, Helvetica, Arial, sans-serif'
]


# If true, '()' will be appended to :func: etc. cross-reference text.
# add_function_parentheses = True

Expand All @@ -220,7 +220,6 @@ def check_sphinx_version(expected_version):
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False


# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
Expand Down Expand Up @@ -290,7 +289,6 @@ def check_sphinx_version(expected_version):
# Output file base name for HTML help builder.
htmlhelp_basename = 'pysiafdoc'


# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
Expand All @@ -306,8 +304,8 @@ def check_sphinx_version(expected_version):
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'pysiaf.tex', u'Pysiaf Documentation',
u'pysiaf', 'manual'),
('index', 'pysiaf.tex', u'Pysiaf Documentation',
u'pysiaf', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand All @@ -329,29 +327,26 @@ def check_sphinx_version(expected_version):
# If false, no module index is generated.
latex_domain_indices = True


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'pysiaf', u'Pysiaf Documentation',
[u'pysiaf'], 1)
('index', 'pysiaf', u'Pysiaf Documentation', [u'pysiaf'], 1),
]

# If true, show URL addresses after external links.
man_show_urls = True


# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'pysiaf', u'Pysiaf Documentation',
u'pysiaf', 'pysiaf', 'Packagname',
'Miscellaneous'),
('index', 'pysiaf', u'Pysiaf Documentation',
u'pysiaf', 'pysiaf', 'Packagname',
'Miscellaneous'),
]

# Documents to append as an appendix to all manuals.
Expand Down
84 changes: 84 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
[project]
name = "pysiaf"
description = "Handling of Science Instrument Aperture Files (SIAF) for space telescopes"
requires-python = ">=3.8"
authors = [
{ name = "STScI", email = "[email protected]" },
]
classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Topic :: Scientific/Engineering :: Astronomy",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"astropy>=4.3.1",
"lxml>=4.6.4",
"matplotlib>=3.4.3",
"numpy>=1.21.4",
"numpydoc>=1.1.0",
"openpyxl>=3.0.9",
"requests>=2.26.0",
"scipy>=1.7.2",
]
dynamic = [
"version",
]

[project.readme]
file = "README.md"
content-type = "text/markdown"

[project.license]
file = "LICENSE.md"
content-type = "text/plain"

[project.urls]
documentation = "https://pysiaf.readthedocs.io/en/latest/"
repository = "https://github.com/spacetelescope/pysiaf"

[project.optional-dependencies]
docs = [
"stsci_rtd_theme",
"sphinx_automodapi",
"numpy",
"matplotlib",
"scipy",
"tomli; python_version<\"3.11\"",
]

[build-system]
requires = [
"setuptools>=61.2",
"setuptools_scm[toml]>=3.4",
"wheel",
"oldest-supported-numpy",
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "pysiaf/version.py"

[tool.setuptools.packages.find]

[tool.setuptools.package-data]
pysiaf = [
"prd_data/HST/*",
"prd_data/JWST/*/*/*/*.xlsx",
"prd_data/JWST/*/*/*/*.xml",
"pre_delivery_data/*/*.*",
"source_data/*/*/*.txt",
"source_data/*/*.txt",
"source_data/*.txt",
"tests/test_data/*/*/*/*.fits",
"tests/test_data/*/*/*/*.txt",
]

[tool.pytest.ini_options]
minversion = 3.0
norecursedirs = [
"build",
"docs/_build",
]
8 changes: 0 additions & 8 deletions requirements.txt

This file was deleted.

36 changes: 0 additions & 36 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit d3ac5eb

Please sign in to comment.