Skip to content

Commit

Permalink
retemplate dance
Browse files Browse the repository at this point in the history
  • Loading branch information
wtbarnes committed Nov 1, 2023
1 parent 6d70fbe commit 6941079
Show file tree
Hide file tree
Showing 11 changed files with 268 additions and 51 deletions.
41 changes: 41 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
repos:
# The warnings/errors we check for here are:
# E101 - mix of tabs and spaces
# W191 - use of tabs
# W291 - trailing whitespace
# W292 - no newline at end of file
# W293 - trailing whitespace
# W391 - blank line at end of file
# E111 - 4 spaces per indentation level
# E112 - 4 spaces per indentation level
# E113 - 4 spaces per indentation level
# E303 - too many blank lines (3)
# E304 - blank lines found after function decorator
# E305 - expected 2 blank lines after class or function definition
# E306 - expected 1 blank line before a nested definition
# E502 - the backslash is redundant between brackets
# E722 - do not use bare except
# E901 - SyntaxError or IndentationError
# E902 - IOError
# F822: undefined name in __all__
# F823: local variable name referenced before assignment
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
hooks:
- id: flake8
args: ['--count', '--select', 'E101,W191,W291,W292,W293,W391,E111,E112,E113,E303,E304,E306,E502,E722,E901,E902,F822,F823']

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: check-ast
- id: check-case-conflict
- id: trailing-whitespace
exclude: ".*(.fits|.fts|.fit|.txt)$"
- id: check-yaml
- id: debug-statements
- id: check-added-large-files
- id: end-of-file-fixer
exclude: ".*(.fits|.fts|.fit|.txt|tca.*)$"
- id: mixed-line-ending
exclude: ".*(.fits|.fts|.fit|.txt|tca.*)$"
27 changes: 12 additions & 15 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2
build:
os: ubuntu-20.04
tools:
python: "3.9"

# Build documentation in the docs/ directory with Sphinx
sphinx:
builder: html
configuration: docs/conf.py
fail_on_warning: false

# Optionally build your docs in additional formats such as PDF and ePub
formats: []

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: requirements/requirements-dev.txt
- method: setuptools
path: .
install:
- method: pip
extra_requirements:
- all
- docs
path: .
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include README.md
include LICENSE
include pydrad/configure/templates/*
include pyproject.toml
include pydrad/configure/templates/*
include pydrad/configure/data/*
4 changes: 4 additions & 0 deletions pydrad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import logging
from astropy.logger import AstropyLogger

from .version import version as __version__


def _init_log():
"""
Expand All @@ -25,3 +27,5 @@ def _init_log():

log = logging.getLogger()
log = _init_log()

__all__ = ['__version__', 'log']
97 changes: 97 additions & 0 deletions pydrad/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
[metadata]
name = pydrad
author = Will Barnes
author_email = [email protected]
license = MIT
license_file = LICENSE
url = https://github.com/rice-solar-physics/pydrad
description = Tools for configuring and parsing HYDRAD simulations.
long_description = file: README.md
long_description_content_type = text/markdown
keywords = hydrodynamics, coronal loop, corona, solar physics, solar, science, sun
classifiers =
Development Status :: 4 - Beta
Intended Audience :: Science/Research
License :: OSI Approved :: MIT License
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Topic :: Scientific/Engineering :: Astronomy

[options]
zip_safe = False
packages = find:
python_requires = >=3.7
setup_requires = setuptools_scm
install_requires =
scipy
matplotlib
astropy
Jinja2
asdf
h5py
plasmapy[theory]

[options.extras_require]
test =
flake8
GitPython
pillow
pytest
pytest-cov
codecov
docs =
sphinx
sphinx-automodapi
sphinx-changelog
sphinx-gallery
sphinx-rtd-theme

[options.package_data]
pydrad.configure = templates/*, data/*

[tool:pytest]
testpaths = "pydrad" "docs"
doctest_plus = enabled
text_file_format = rst
addopts = --doctest-rst
remote_data_strict = False
filterwarnings =
error

[coverage:run]
omit =
pydrad/_sunpy_init*
pydrad/conftest.py
pydrad/*setup_package*
pydrad/tests/*
pydrad/*/tests/*
pydrad/extern/*
pydrad/version*
*/pydrad/_sunpy_init*
*/pydrad/conftest.py
*/pydrad/*setup_package*
*/pydrad/tests/*
*/pydrad/*/tests/*
*/pydrad/extern/*
*/pydrad/version*

[coverage:report]
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
# Don't complain about packages we have installed
except ImportError
# Don't complain if tests don't hit assertions
raise AssertionError
raise NotImplementedError
# Don't complain about script hooks
def main\(.*\):
# Ignore branches that don't pertain to this version of Python
pragma: py{ignore_python_version}
# Don't complain about IPython completion helper
def _ipython_key_completions_

17 changes: 17 additions & 0 deletions pydrad/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# NOTE: First try _dev.scm_version if it exists and setuptools_scm is installed
# This file is not included in wheels/tarballs, so otherwise it will
# fall back on the generated _version module.
try:
try:
from ._dev.scm_version import version
except ImportError:
from ._version import version
except Exception:
import warnings

warnings.warn(
f'could not determine {__name__.split(".")[0]} package version; this indicates a broken installation'
)
del warnings

version = '0.0.0'
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]

requires = ["setuptools",
"setuptools_scm",
"wheel"]

build-backend = 'setuptools.build_meta'
11 changes: 0 additions & 11 deletions requirements/requirements-dev.txt

This file was deleted.

7 changes: 0 additions & 7 deletions requirements/requirements.txt

This file was deleted.

44 changes: 27 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
from distutils.core import setup
#!/usr/bin/env python
import os
from itertools import chain

from setuptools import setup
from setuptools.config import read_configuration

################################################################################
# Programmatically generate some extras combos.
################################################################################
extras = read_configuration("setup.cfg")['options']['extras_require']

# Dev is everything
extras['dev'] = list(chain(*extras.values()))

# All is everything but tests and docs
exclude_keys = ("tests", "docs", "dev")
ex_extras = dict(filter(lambda i: i[0] not in exclude_keys, extras.items()))
# Concatenate all the values together for 'all'
extras['all'] = list(chain.from_iterable(ex_extras.values()))

################################################################################
# Version configuration and setup call
################################################################################
setup(
name='pydrad',
license='MIT',
version='0.1',
author='Will Barnes',
url='https://github.com/rice-solar-physics/pydrad',
package_data={'pydrad': ['configure/templates/*',
'configure/data/defaults.asdf']},
packages=[
'pydrad',
'pydrad.configure',
'pydrad.configure.data',
'pydrad.parse',
'pydrad.visualize',
],
author_email='[email protected]',
description='Tools for configuring and parsing HYDRAD simulations'
extras_require=extras,
use_scm_version={
'write_to': os.path.join('pydrad', '_version.py'),
},
)
60 changes: 60 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[tox]
envlist =
py{38,39,310}
build_docs
codestyle
isolated_build = true
requires =
setuptools >= 30.3.0
pip >= 19.3.1
tox-pypi-filter >= 0.10

[testenv]

# The following option combined with the use of the tox-pypi-filter above allows
# project-wide pinning of dependencies, e.g. if new versions of pytest do not
# work correctly with pytest-astropy plugins. Most of the time the pinnings file
# should be empty.

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

# Run the tests in a temporary directory to make sure that we don't import
# the package from the source tree
changedir = .tmp/{envname}

# tox environments are constructued with so-called 'factors' (or terms)
# separated by hyphens, e.g. test-devdeps-cov. Lines below starting with factor:
# will only take effect if that factor is included in the environment name. To
# see a list of example environments that can be run, along with a description,
# run:
#
# tox -l -v
#
description =
run tests

deps =
# The following indicates which extras_require from setup.cfg will be installed
extras =
test
commands =
pytest --pyargs pydrad {toxinidir}/docs --cov pydrad --cov-report=xml --cov-config={toxinidir}/setup.cfg {posargs}


[testenv:build_docs]
changedir = docs
description = invoke sphinx-build to build the HTML docs
extras = docs
commands =
sphinx-build -b html . _build/html {posargs}


[testenv:codestyle]
skip_install = true
description = Run all style and file checks with pre-commit
deps =
pre-commit
commands =
pre-commit install-hooks
pre-commit run --all-files

0 comments on commit 6941079

Please sign in to comment.