Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up roman-lander-plugin package #1

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

"on": [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # full history for setuptools_scm

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Python install
run: |
python -m pip install --upgrade pip
python -m pip install .[dev]
python -m pip install tox

- name: Run tests
run: tox -e py,lint,typing
38 changes: 38 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-yaml
- id: check-toml
- id: check-json
- id: trailing-whitespace

- repo: https://github.com/Lucas-C/pre-commit-hooks-markup
rev: v1.0.1
hooks:
- id: rst-linter
files: (README\.rst)|(CHANGELOG\.rst)

- repo: https://github.com/PyCQA/isort
rev: 5.7.0
hooks:
- id: isort
additional_dependencies:
- toml

- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black

- repo: https://github.com/asottile/blacken-docs
rev: v1.9.1
hooks:
- id: blacken-docs
additional_dependencies: [black==20.8b0]
args: [-l, "79", -t, py38]

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Change log
==========

Unreleased
----------

First release of roman-lander-plugin.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 California Institute of Technology

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.PHONY: help
help:
@echo "Make command reference"
@echo " make init ........ (initialize for development)"

.PHONY: init
init:
pip install -e ".[dev]"
pip install tox tox-pyenv pre-commit
pre-commit install
rm -rf .tox
17 changes: 17 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
###################
roman-lander-plugin
###################

This plugin configures Lander, the PDF landing page static site generator, for Roman Observatory documents.

Development workflow
====================

Using a virtual environment is best practice.
To install the plugin within the virtual environment, along with development dependencies, run::

make init

To run the full suite of test and linting commands (assuming Python 3.8 is available)::

tox
56 changes: 56 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"setuptools_scm[toml]>=3.4"
]
build-backend = 'setuptools.build_meta'

[tool.setuptools_scm]

[tool.black]
line-length = 79
target-version = ['py38']
exclude = '''
/(
\.eggs
| \.git
| \.mypy_cache
| \.tox
| \.venv
| _build
| build
| dist
| node_modules
)/
'''
# Use single-quoted strings so TOML treats the string like a Python r-string
# Multi-line strings are implicitly treated by black as regular expressions

[tool.isort]
include_trailing_comma = true
multi_line_output = 3
known_first_party = "romanlander"
skip = ["docs/conf.py"]

[tool.coverage.run]
parallel = true
branch = true
source = ["romanlander"]

[tool.coverage.paths]
source = ["src", ".tox/*/site-packages"]

[tool.coverage.report]
show_missing = true
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:"
]
77 changes: 77 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[metadata]
name = roman-lander-plugin
description = Roman Observatory plugin for the Lander PDF landing page tool.
author = J.Sick Codes Inc.
author_email = [email protected]
long_description = file: README.rst, CHANGELOG.rst, LICENSE
long_description_content_type = text/x-rst
url = https://github.com/jsickcodes/roman-lander-plugin
project_urls =
Change log = https://github.com/jsickcodes/roman-lander-plugin/blob/master/CHANGELOG.rst
Source code = https://github.com/jsickcodes/roman-lander-plugin
Issue tracker = https://github.com/jsickcodes/roman-lander-plugin/issues
classifiers =
Development Status :: 4 - Beta
License :: OSI Approved :: MIT License
Programming Language :: Python
Programming Language :: Python :: 3
Topic :: Documentation
Intended Audience :: Science/Research
Natural Language :: English
Operating System :: POSIX
Typing :: Typed
keywords =
roman
lander

[options]
zip_safe = False
include_package_data = True
package_dir =
= src
packages = find:
python_requires = >=3.7
setup_requires =
setuptools_scm
install_requires =
importlib_metadata; python_version < "3.8"
lander >= 2.0.0a6

[options.packages.find]
where = src

[options.package_data]
romanlander =
themes/roman/templates/*.jinja
themes/roman/site/*.js
themes/roman/site/*.css
themes/roman/site/*.png
themes/roman/site/*.jpg
themes/roman/site/*.svg
themes/roman/site/*.txt
themes/roman/site/*.jinja

[options.extras_require]
dev =
pytest
coverage[toml]
beautifulsoup4

[flake8]
max-line-length = 79
# E203: whitespace before :, flake8 disagrees with PEP 8
# W503: line break after binary operator, flake8 disagrees with PEP 8
ignore = E203, W503

[tool:pytest]
norecursedirs = node_modules

[mypy]
disallow_untyped_defs = True
disallow_incomplete_defs = True
ignore_missing_imports = True
show_error_codes = True
strict_equality = True
warn_redundant_casts = True
warn_unreachable = True
warn_unused_ignores = True
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from setuptools import setup

setup(use_scm_version=True)
22 changes: 22 additions & 0 deletions src/romanlander/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""The Roman Observatory plugin for Lander, the PDF landing page static site
generator.
"""

__all__ = ["__version__"]

import sys

if sys.version_info < (3, 8):
from importlib_metadata import PackageNotFoundError, version
else:
from importlib.metadata import PackageNotFoundError, version


__version__: str
"""The package version string (PEP 440 / SemVer compatible)."""

try:
__version__ = version(__name__)
except PackageNotFoundError:
# package is not installed
__version__ = "0.0.0"
7 changes: 7 additions & 0 deletions tests/init_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Test the romanlander __init__ module."""

from romanlander import __version__


def test_version() -> None:
assert isinstance(__version__, str)
34 changes: 34 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[tox]
envlist = py38,coverage-report,lint,typing
isolated_build = True

[testenv]
description = Run pytest against {envname}.
extras =
dev
commands=
coverage run -m pytest {posargs}

[testenv:coverage-report]
description = Compile coverage from each test run.
skip_install = true
deps = coverage[toml]>=5.0.2
depends =
py38
commands =
coverage combine
coverage report

[testenv:lint]
description = Lint codebase by running pre-commit (Black, isort, Flake8).
skip_install = true
deps =
pre-commit
commands = pre-commit run --all-files

[testenv:typing]
description = Run mypy.
deps =
mypy
commands =
mypy src/romanlander tests setup.py