Skip to content

Commit

Permalink
Packaging updates to modernize and fix version number (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsteve committed Jan 26, 2023
1 parent f3ce4d7 commit fff5463
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 176 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,20 @@
A [cookiecutter](https://cookiecutter.readthedocs.io/en/stable/) Python package template for the hermes instrument packages.

Any changes made to this template will be applied to the instrument packages through [cruft](https://cruft.github.io/cruft/).

## Instructions for Maintainers

### Building the template

To build this template into a Python package, first clone this repository. In the directory that contains the hermes_instrument folder, run

cookiecutter hermes_instrument

Answer the instrument prompt. If you named your instrument 'boo', then cookiecutter will create a new directory called `hermes_boo`. Go into this directory and run

git init

This is required by `setuptools_scm` to be able to derive the version number automatically. You can then install the package with

pip install -e .

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
from hermes_core import log

try:
from .version import __version__
from ._version import version as __version__
from ._version import version_tuple
except ImportError:
__version__ = "unknown"
__version__ = "unknown version"
version_tuple = (0, 0, "unknown version")
from hermes_{{ cookiecutter.instr_name }}.io.file_tools import read_file

# from hermes_core.util.config import load_config, print_config
Expand Down
139 changes: 95 additions & 44 deletions hermes_{{ cookiecutter.instr_name }}/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,48 +1,99 @@
[build-system]

requires = ["setuptools",
"setuptools_scm",
requires = ["setuptools>=45",
"setuptools_scm[toml]>=6.2",
"wheel"]

build-backend = 'setuptools.build_meta'

[tool.towncrier]
package = "hermes_{{ cookiecutter.instr_name }}"
filename = "CHANGELOG.rst"
directory = "changelog/"
issue_format = "`#{issue} <https://github.com/HERMES-SOC/hermes_{{ cookiecutter.instr_name }}/pull/{issue}>`__"

[[tool.towncrier.type]]
directory = "breaking"
name = "Backwards Incompatible Changes"
showcontent = true

[[tool.towncrier.type]]
directory = "api"
name = "API Changes"
showcontent = true

[[tool.towncrier.type]]
directory = "removal"
name = "Deprecations and Removals"
showcontent = true

[[tool.towncrier.type]]
directory = "feature"
name = "Features"
showcontent = true

[[tool.towncrier.type]]
directory = "bugfix"
name = "Bug Fixes"
showcontent = true

[[tool.towncrier.type]]
directory = "doc"
name = "Improved Documentation"
showcontent = true

[[tool.towncrier.type]]
directory = "trivial"
name = "Trivial/Internal Changes"
showcontent = true
[project]
name = "hermes_{{ cookiecutter.instr_name }}"
description = "A Python package to process and analyze data from the HERMES {{ cookiecutter.instr_name }} instrument."
readme = "README.rst"
dynamic = ["version"]
authors = [{name = "Steven Christe", email="steven.d.christe@nasa.gov"},
{name = "Damian Barrous Dumme", email="damianbarrous@gmail.com"}]
license = {file = "LICENSE.rst"}
requires-python = ">=3.7"
keywords = ["hermes", "nasa mission", "space weather"]
classifiers = [
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: Apache 2.0",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Physics",
]
dependencies = [
'astropy>=4.1.0',
'numpy>=1.16.0',
'hermes_core @ git+https://github.com/HERMES-SOC/hermes_core/',
]

[project.optional-dependencies]
dev = [
'coverage>=5.0.3',
'pytest',
'pytest-astropy',
'pytest-cov',
'black',
'flake8',
'coverage[toml]'
]

docs = [
'sphinx',
'sphinx-automodapi'
]

test = [
'pytest',
'pytest-astropy',
'pytest-cov',
'coverage[toml]'
]

style = [
'black',
'flake8'
]

[tool.setuptools.package-data]
"hermes_{{ cookiecutter.instr_name }}.data" = ["**"]

[tool.setuptools]
packages = ["hermes_{{ cookiecutter.instr_name }}"]

[tool.setuptools_scm]
write_to = "hermes_{{ cookiecutter.instr_name }}/_version.py"

[tool.pytest.ini_options]
testpaths = [
"hermes_{{ cookiecutter.instr_name }}/tests",
"docs"
]
doctest_plus = "enabled"
text_file_format = "rst"
addopts = "--doctest-rst"

[tool.coverage.run]
omit = [
'hermes_{{ cookiecutter.instr_name }}/__init*',
'hermes_{{ cookiecutter.instr_name }}/conftest.py',
'hermes_{{ cookiecutter.instr_name }}/*setup_package*',
'hermes_{{ cookiecutter.instr_name }}/tests/*',
'hermes_{{ cookiecutter.instr_name }}/*/tests/*',
'hermes_{{ cookiecutter.instr_name }}/extern/*',
'hermes_{{ cookiecutter.instr_name }}/version*',
'*/hermes_{{ cookiecutter.instr_name }}/__init*',
'*/hermes_{{ cookiecutter.instr_name }}/conftest.py',
'*/hermes_{{ cookiecutter.instr_name }}/*setup_package*',
'*/hermes_{{ cookiecutter.instr_name }}/tests/*',
'*/hermes_{{ cookiecutter.instr_name }}/*/tests/*',
'*/hermes_{{ cookiecutter.instr_name }}/extern/*',
'*/hermes_{{ cookiecutter.instr_name }}/version*',
]

86 changes: 1 addition & 85 deletions hermes_{{ cookiecutter.instr_name }}/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,87 +1,3 @@
[metadata]
name = hermes_{{ cookiecutter.instr_name }}
author = Jane Doe
author_email = jane.doe@example.com
license = BSD 3-Clause
license_file = LICENSE.rst
url = https://github.com/HERMES-SOC/hermes_{{ cookiecutter.instr_name }}
description = A Python package to process the HERMES instrument.
long_description = file: README.rst

[options]
zip_safe = False
packages = find:
python_requires = >=3.7
setup_requires = setuptools_scm
install_requires =
astropy>=4.1.0
numpy>=1.16.0
hermes_core @ git+https://github.com/HERMES-SOC/hermes_core/

[options.entry_points]
console_scripts =
astropy-package-template-example = packagename.example_mod:main


[options.extras_require]
dev =
black
flake8

test =
tox
pytest
pytest-astropy
pytest-cov
docs =
sphinx
sphinx-automodapi
sphinx-changelog
towncrier

[options.package_data]
hermes_{{ cookiecutter.instr_name }} = data/*

[tool:pytest]
testpaths = "hermes_{{ cookiecutter.instr_name }}" "docs"
doctest_plus = enabled
text_file_format = rst
addopts = --doctest-rst
remote_data_strict = True

[coverage:run]
omit =
hermes_{{ cookiecutter.instr_name }}/__init*
hermes_{{ cookiecutter.instr_name }}/conftest.py
hermes_{{ cookiecutter.instr_name }}/*setup_package*
hermes_{{ cookiecutter.instr_name }}/tests/*
hermes_{{ cookiecutter.instr_name }}/*/tests/*
hermes_{{ cookiecutter.instr_name }}/extern/*
hermes_{{ cookiecutter.instr_name }}/version*
*/hermes_{{ cookiecutter.instr_name }}/__init*
*/hermes_{{ cookiecutter.instr_name }}/conftest.py
*/hermes_{{ cookiecutter.instr_name }}/*setup_package*
*/hermes_{{ cookiecutter.instr_name }}/tests/*
*/hermes_{{ cookiecutter.instr_name }}/*/tests/*
*/hermes_{{ cookiecutter.instr_name }}/extern/*
*/hermes_{{ cookiecutter.instr_name }}/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_

[flake8]
select = E101,E11,E111,E112,E113,E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E133,E20,E211,E231,E241,E242,E251,E252,E26,E265,E266,E27,E301,E302,E303,E304,E305,E306,E401,E402,E502,E701,E711,E712,E713,E714,E722,E731,E901,E902,F822,F823,W191,W291,W292,W293,W391,W601,W602,W603,W604,W605,W690
exclude = .txt, .rst, .md
exclude = .txt, .rst, .md
45 changes: 0 additions & 45 deletions hermes_{{ cookiecutter.instr_name }}/setup.py

This file was deleted.

0 comments on commit fff5463

Please sign in to comment.