Skip to content

Commit

Permalink
package stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
kbwestfall committed Mar 28, 2024
1 parent 4f5da61 commit cd3dbee
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 68 deletions.
15 changes: 7 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import os

from pkg_resources import get_distribution
from configparser import ConfigParser
from importlib import metadata
import pathlib

# Get configuration information from setup.cfg
from configparser import ConfigParser
conf = ConfigParser()

conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')])
conf.read([pathlib.Path(__file__).resolve().parents[1] / 'setup.cfg'])
setup_cfg = dict(conf.items('metadata'))


Expand Down Expand Up @@ -71,22 +70,22 @@

# General information about the project.
project = 'synospec'
copyright = '2021, Kyle B. Westfall'
copyright = '2024, Kyle B. Westfall'
author = 'Kyle B. Westfall'

# 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 full version, including alpha/beta/rc tags.
version = get_distribution(setup_cfg['name']).version
version = metadata.version(setup_cfg['name'])

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down
2 changes: 1 addition & 1 deletion docs/help/fobos_etc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
FOBOS Exposure-Time Calculator (v0.2)
optional arguments:
options:
-h, --help show this help message and exit
--spec_file SPEC_FILE
A fits or ascii file with the object spectrum to use
Expand Down
2 changes: 1 addition & 1 deletion docs/help/fobos_etc_grid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Grid sampling of FOBOS ETC
optional arguments:
options:
-h, --help show this help message and exit
-w WAVELENGTHS WAVELENGTHS WAVELENGTHS, --wavelengths WAVELENGTHS WAVELENGTHS WAVELENGTHS
Wavelength grid: start wave, approx end wave,
Expand Down
2 changes: 1 addition & 1 deletion docs/help/imaging_etc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Imaging Exposure-Time Calculator
optional arguments:
options:
-h, --help show this help message and exit
-m MAG, --mag MAG Total apparent magnitude of the source (default: 24.0)
--mag_band MAG_BAND Broad-band used for the provided magnitude. Must be u,
Expand Down
2 changes: 1 addition & 1 deletion docs/help/wfos_etc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
WFOS Exposure-Time Calculator (v0.1)
optional arguments:
options:
-h, --help show this help message and exit
--spec_file SPEC_FILE
A fits or ascii file with the object spectrum to use
Expand Down
17 changes: 7 additions & 10 deletions docs/scripts/write_script_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
Dynamically build the rst documentation with the script help text.
"""

import os
import time
import importlib
from pkg_resources import resource_filename
from importlib import resources

from synospec.scripts import script_classes

Expand All @@ -14,9 +12,9 @@

def write_help(script_cls, opath, width=80):
exe = script_cls.name()
ofile = os.path.join(opath, '{0}.rst'.format(exe))
ofile = opath / f'{exe}.rst'
lines = ['.. code-block:: console', '']
lines += [' $ {0} -h'.format(exe)]
lines += [f' $ {exe} -h']
parser = script_cls.get_parser(width=80)
parser.prog = exe
lines += [' ' + l for l in parser.format_help().split('\n')]
Expand All @@ -27,14 +25,13 @@ def write_help(script_cls, opath, width=80):
if __name__ == '__main__':
t = time.perf_counter()

root = os.path.dirname(resource_filename('synospec', ''))
path = os.path.join(root, 'docs', 'help')
if not os.path.isdir(path):
os.makedirs(path)
root = resources.files('producer').parent
path = root / 'docs' / 'help'
if not path.is_dir():
path.mkdir(parents=True)

# Get the list of script names and script classes
scr_clss = script_classes()

for name, script_cls in scr_clss.items():
write_help(script_cls, path)

Expand Down
17 changes: 9 additions & 8 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# This is needed for tox.ini!!
name: synospec
channels:
- conda-forge
- defaults
dependencies:
- python>=3.7
- IPython>=7.26
- python>=3.10
- IPython>=8.0
- pip
- numpy>=1.21
- scipy>=1.7
- matplotlib>=3.4
- astropy>=4.3
- numpy>=1.24
- scipy>=1.10
- matplotlib>=3.6
- astropy>=6.0
- extension-helpers>=0.1
- pydl>=0.7
- shapely>=1.7.0
- shapely>=2.0
- pytest>=6.2
- setuptools>=46.4

27 changes: 12 additions & 15 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ classifiers =
zip_safe = False
use_2to3 = False
packages = find:
python_requires = >=3.7
python_requires = >=3.10
setup_requires = setuptools_scm
include_package_data = True
install_requires =
IPython>=7.26
numpy>=1.21
scipy>=1.7
matplotlib>=3.4
astropy>=4.3
IPython>=8.0
numpy>=1.24
scipy>=1.10
matplotlib>=3.6
astropy>=6.0
extension-helpers>=0.1
pydl>=0.7
shapely>=2.0
Expand All @@ -47,24 +47,21 @@ test =
tox
pytest-cov
coverage
codecov
docs =
sphinx
sphinx<7,>=1.6
docutils<0.19
sphinx-automodapi
sphinx_rtd_theme
sphinx_rtd_theme==1.2.2
dev =
pytest>=6.2
pytest-astropy
tox
pytest-cov
coverage
codecov
sphinx
sphinx<7,>=1.6
docutils<0.19
sphinx-automodapi
sphinx_rtd_theme

[options.package_data]
* = *.md, data/*, data/*/*
sphinx_rtd_theme==1.2.2

[options.entry_points]
console_scripts =
Expand Down
37 changes: 14 additions & 23 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# Largely copied from github.com/pypeit/PypeIt
[tox]
envlist =
py{38,39}-test{,-shapely}{,-cov}
py{38,39}-test-numpy{119,120,121}
py{38,39}-test-astropy{lts,42,43}
py{38,39}-test-{numpy,astropy}dev
py{310,311,312}-test{,-shapely}{,-cov}
py{310,311,312}-test-numpy{124,125,126}
py{310,311,312}-test-{numpy,astropy}dev
codestyle
requires =
setuptools >= 30.3.0
pip >= 19.3.1
isolated_build = true
indexserver =
NIGHTLY = https://pypi.anaconda.org/scipy-wheels-nightly/simple

[testenv]
# Suppress display of matplotlib plots generated during docs build
setenv = MPLBACKEND=agg
setenv =
MPLBACKEND=agg
numpydev: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/scipy-wheels-nightly/simple

# Pass through the following environment variables which may be needed for the CI
passenv = HOME WINDIR LC_ALL LC_CTYPE CC CI
passenv = HOME,WINDIR,LC_ALL,LC_CTYPE,CC,CI

# Run the tests in a temporary directory to make sure that we don't import
# this package from the source tree
Expand All @@ -38,26 +37,19 @@ description =
devdeps: with the latest developer version of key dependencies
oldestdeps: with the oldest supported version of key dependencies
cov: and test coverage
numpy119: with numpy 1.19.*
numpy120: with numpy 1.20.*
numpy121: with numpy 1.21.*
astropy42: with astropy 4.2.*
astropy43: with astropy 4.3.*
astropylts: with the latest astropy LTS
numpy124: with numpy 1.24.*
numpy125: with numpy 1.25.*
numpy126: with numpy 1.26.*

# The following provides some specific pinnings for key packages
deps =

cov: coverage
numpy119: numpy==1.19.*
numpy120: numpy==1.20.*
numpy121: numpy==1.21.*
numpy124: numpy==1.24.*
numpy125: numpy==1.25.*
numpy126: numpy==1.26.*

astropy42: astropy==4.2.*
astropy43: astropy==4.3.*
astropylts: astropy==4.0.*

numpydev: :NIGHTLY:numpy
numpydev: numpy>=0.0.dev0
astropydev: git+https://github.com/astropy/astropy.git#egg=astropy

# The following indicates which extras_require from setup.cfg will be installed
Expand All @@ -81,7 +73,6 @@ commands = pycodestyle synospec --count --select=E9
[testenv:conda]
description = run tests in environment created via conda
requires = tox-conda
conda_deps = numpy,astropy,scipy
conda_env = {toxinidir}/environment.yml
commands = pytest --pyargs synospec {posargs}

Expand Down

0 comments on commit cd3dbee

Please sign in to comment.