diff --git a/docs/conf.py b/docs/conf.py index 91506a2d..30c267fe 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 @@ -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' @@ -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) @@ -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', @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 = { @@ -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 @@ -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. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..e4724eaa --- /dev/null +++ b/pyproject.toml @@ -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 = "help@stsci.edu" }, +] +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", +] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index bfb87f82..00000000 --- a/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -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 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index ddc82b6f..00000000 --- a/setup.cfg +++ /dev/null @@ -1,36 +0,0 @@ -[metadata] -package_name = pysiaf -description = Handling of Science Instrument Aperture Files (SIAF) for space telescopes -long_description = A python package to access, interpret, maintain, and generate Science Instrument Aperture Files, in particular of JWST. Tools for applying the frame transformations, plotting, comparison, and validation are provided. -author = STScI -author_email = help@stsci.edu -license = BSD -edit_on_github = False -github_project = spacetelescope/pysiaf -description_file = README.md -url = http://www.stsci.edu/ -homepage = http:://www.stsci.edu/ - -[build-sphinx] -source-dir = docs -build-dir = docs -all_files = 1 - -[upload_docs] -upload_dir = docs/_build/html -show_response = 1 - -[tool:pytest] -minversion = 3.0 -norecursedirs = build docs/_build - -[flake8] -# See http://flake8.pycqa.org/en/latest/user/configuration.html - -[entry_points] - -[bdist_wheel] -# This flag says that the code is written to work on both Python 2 and Python -# 3. If at all possible, it is good practice to do this. If you cannot, you -# will need to generate wheels for each Python version that you support. -universal=1 diff --git a/setup.py b/setup.py deleted file mode 100755 index 01a9548f..00000000 --- a/setup.py +++ /dev/null @@ -1,138 +0,0 @@ -#!/usr/bin/env python -import os -import pkgutil -import platform -import sys -from setuptools import setup, find_packages, Extension, Command -from setuptools.command.test import test as TestCommand - -try: - from distutils.config import ConfigParser -except ImportError: - from configparser import ConfigParser - -conf = ConfigParser() -conf.read(['setup.cfg']) - -# Get some config values -metadata = dict(conf.items('metadata')) -PACKAGENAME = metadata.get('package_name', 'packagename') -DESCRIPTION = metadata.get('description', '') -AUTHOR = metadata.get('author', 'STScI') -AUTHOR_EMAIL = metadata.get('author_email', 'help@stsci.edu') -URL = metadata.get('url', 'https://www.stsci.edu/') -LICENSE = metadata.get('license', 'BSD') - - -# allows you to build sphinx docs from the pacakge -# main directory with python setup.py build_sphinx - -try: - from sphinx.cmd.build import build_main - from sphinx.setup_command import BuildDoc - - class BuildSphinx(BuildDoc): - """Build Sphinx documentation after compiling C source files""" - - description = 'Build Sphinx documentation' - - def initialize_options(self): - BuildDoc.initialize_options(self) - - def finalize_options(self): - BuildDoc.finalize_options(self) - - def run(self): - build_cmd = self.reinitialize_command('build_ext') - build_cmd.inplace = 1 - self.run_command('build_ext') - build_main(['-b', 'html', './docs', './docs/_build/html']) - -except ImportError: - class BuildSphinx(Command): - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - # print('!\n! Sphinx is not installed!\n!', file=sys.stderr) - raise RuntimeError('!\n! Sphinx is not installed!\n!') - exit(1) - - -class PyTest(TestCommand): - def finalize_options(self): - TestCommand.finalize_options(self) - self.test_args = ['pysiaf/tests'] - self.test_suite = True - - def run_tests(self): - # import here, cause outside the eggs aren't loaded - import pytest - errno = pytest.main(self.test_args) - sys.exit(errno) - -install_requires = [ - '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', - ] - -# Patch because MacOS Mojave causes matplotlib to fail without pyqt5 - will remove line if this bug is patched -# Also noted as a known installation issue in the project's README -if platform.system().lower() == 'darwin' and platform.mac_ver()[0].split('.')[0:2] == ['10', '14']: - try: - import PyQt5 - except ModuleNotFoundError: - install_requires.append('PyQt5') - -setup( - name=PACKAGENAME, - author=AUTHOR, - author_email=AUTHOR_EMAIL, - description=DESCRIPTION, - license=LICENSE, - url=URL, - 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', - ], - setup_requires=['setuptools_scm'], - use_scm_version={'write_to': os.path.join(PACKAGENAME, 'version.py')}, - install_requires=install_requires, - extras_require={ - 'docs': ['stsci_rtd_theme', - 'sphinx_automodapi', - 'numpy', - 'matplotlib', - 'scipy'] - }, - tests_require=['pytest'], - packages=find_packages(), - package_data={PACKAGENAME: ['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', - ]}, - cmdclass={ - 'test': PyTest, - 'build_sphinx': BuildSphinx - },)