Initial commit.

This commit is contained in:
felix
2023-10-31 14:37:16 +01:00
commit 5e2cbb8cb8
23 changed files with 2192 additions and 0 deletions

14
.cookiecutter.json Normal file
View File

@@ -0,0 +1,14 @@
{
"_checkout": null,
"_output_dir": "/home/felix/repositories/flucto-gmbh",
"_repo_dir": "/home/felix/.cookiecutters/cookiecutter-pragmatic-python",
"_template": "gh:pacjac/cookiecutter-pragmatic-python",
"author": "Felix Weiler",
"copyright_year": "2023",
"email": "felix@flucto.tech",
"friendly_name": "Heisskleber",
"github_user": "flucto-gmbh",
"package_name": "heisskleber",
"project_name": "heisskleber",
"version": "0.1.0"
}

15
.editorconfig Normal file
View File

@@ -0,0 +1,15 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{py,toml}]
indent_style = space
indent_size = 4
[*.yml,yaml,json]
indent_style = space
indent_size = 2

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
* text=auto eol=lf

178
.gitignore vendored Normal file
View File

@@ -0,0 +1,178 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Coverage
/.coverage
/.coverage.*
# Nox
/.nox/
# pyEnv
/.python-version
/.pytype/
# Python Build
/dist/
/src/*.egg-info/
# Docs Build
/docs/_build/

20
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
hooks:
- id: check-case-conflict
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.230"
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: "22.8.0"
hooks:
- id: black

12
.readthedocs.yml Normal file
View File

@@ -0,0 +1,12 @@
version: 2
build:
os: ubuntu-20.04
tools:
python: "3.10"
sphinx:
configuration: docs/conf.py
formats: all
python:
install:
- requirements: docs/requirements.txt
- path: .

21
Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
# syntax=docker/dockerfile:1
FROM python:3.9-slim-buster
ENV POETRY_VERSION=1.4 \
POETRY_VIRTUALENVS_CREATE=false
# Install poetry
RUN pip install "poetry==$POETRY_VERSION"
# Copy only requirements to cache them in docker layer
WORKDIR /code
COPY poetry.lock pyproject.toml /code/
# Project initialization:
RUN poetry install --no-interaction --no-ansi --no-root --no-dev
# Copy Python code to the Docker image
COPY heisskleber /code/heisskleber/
CMD [ "python", "heisskleber/foo.py"]

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright © 2023 Felix Weiler
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.

56
Makefile Normal file
View File

@@ -0,0 +1,56 @@
.PHONY: install
install: ## Install the poetry environment and install the pre-commit hooks
@echo "Creating virtual environment using pyenv and poetry"
@poetry install
@poetry run pre-commit install
@poetry shell
.PHONY: check
check: ## Run code quality tools.
@echo "Checking Poetry lock file consistency with 'pyproject.toml': Running poetry lock --check"
@poetry check --lock
@echo "Linting code: Running pre-commit"
@poetry run pre-commit run -a
@echo "Static type checking: Running mypy"
@poetry run mypy .
@echo "Checking for obsolete dependencies: Running deptry"
@poetry run deptry .
.PHONY: test
test: ## Test the code with pytest
@echo "Testing code: Running pytest"
@poetry run pytest --cov --cov-config=pyproject.toml --cov-report=xml
.PHONY: build
build: clean-build ## Build wheel file using poetry
@echo "Creating wheel file"
@poetry build
.PHONY: clean-build
clean-build: ## clean build artifacts
@rm -rf dist
.PHONY: publish
publish: ## publish a release to pypi.
@echo "Publishing: Dry run."
@poetry config pypi-token.pypi $(PYPI_TOKEN)
@poetry publish --dry-run
@echo "Publishing."
@poetry publish
.PHONY: build-and-publish
build-and-publish: build publish ## Build and publish.
.PHONY: docs-test
docs-test: ## Test if documentation can be built without warnings or errors
@poetry run sphinx docs/ docs/_build -W
.PHONY: docs
docs: ## Build and serve the documentation
@poetry run mkdocs serve
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help

68
README.md Normal file
View File

@@ -0,0 +1,68 @@
# Heisskleber
[![PyPI](https://img.shields.io/pypi/v/heisskleber.svg)][pypi status]
[![Status](https://img.shields.io/pypi/status/heisskleber.svg)][pypi status]
[![Python Version](https://img.shields.io/pypi/pyversions/heisskleber)][pypi status]
[![License](https://img.shields.io/pypi/l/heisskleber)][license]
[![Read the documentation at https://heisskleber.readthedocs.io/](https://img.shields.io/readthedocs/heisskleber/latest.svg?label=Read%20the%20Docs)][read the docs]
[![Tests](https://github.com/flucto-gmbh/heisskleber/workflows/Tests/badge.svg)][tests]
[![Codecov](https://codecov.io/gh/flucto-gmbh/heisskleber/branch/main/graph/badge.svg)][codecov]
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)][pre-commit]
[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)][black]
[pypi status]: https://pypi.org/project/heisskleber/
[read the docs]: https://heisskleber.readthedocs.io/
[tests]: https://github.com/flucto-gmbh/heisskleber/actions?workflow=Tests
[codecov]: https://app.codecov.io/gh/flucto-gmbh/heisskleber
[pre-commit]: https://github.com/pre-commit/pre-commit
[black]: https://github.com/psf/black
## Features
- TODO
## Requirements
- TODO
## Installation
You can install _Heisskleber_ via [pip] from [PyPI]:
```console
$ pip install heisskleber
```
## Usage
Please see the [Command-line Reference] for details.
## Contributing
Contributions are very welcome.
To learn more, see the [Contributor Guide].
## License
Distributed under the terms of the [MIT license][license],
_Heisskleber_ is free and open source software.
## Issues
If you encounter any problems,
please [file an issue] along with a detailed description.
## Credits
[pypi]: https://pypi.org/
[hypermodern python cookiecutter]: https://github.com/cjolowicz/cookiecutter-hypermodern-python
[file an issue]: https://github.com/flucto-gmbh/heisskleber/issues
[pip]: https://pip.pypa.io/
<!-- github-only -->
[license]: https://github.com/flucto-gmbh/heisskleber/blob/main/LICENSE
[contributor guide]: https://github.com/flucto-gmbh/heisskleber/blob/main/CONTRIBUTING.md
[command-line reference]: https://heisskleber.readthedocs.io/en/latest/usage.html

9
codecov.yml Normal file
View File

@@ -0,0 +1,9 @@
comment: false
coverage:
status:
project:
default:
target: "100"
patch:
default:
target: "100"

16
docs/conf.py Normal file
View File

@@ -0,0 +1,16 @@
"""Sphinx configuration."""
project = "glue"
author = "Felix Weiler"
copyright = f"2023, {author}"
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx_autodoc_typehints",
]
autodoc_mock_imports = ["RPi.GPIO", "picamera2", "smbus"]
# html_static_path = ["_static"]
html_theme = "sphinx_rtd_theme"

8
docs/index.rst Normal file
View File

@@ -0,0 +1,8 @@
PROJECT
=======================
.. toctree::
:hidden:
:maxdepth: 1
license
reference

4
docs/license.rst Normal file
View File

@@ -0,0 +1,4 @@
License
=======
.. include:: ../LICENSE

9
docs/reference.rst Normal file
View File

@@ -0,0 +1,9 @@
Reference
=============
package 1
-------------
.. automodule:: glue
:members:

2
heisskleber/__init__.py Normal file
View File

@@ -0,0 +1,2 @@
"""Heisskleber."""
__version__ = "0.1.0"

0
heisskleber/py.typed Normal file
View File

136
noxfile.py Normal file
View File

@@ -0,0 +1,136 @@
"""Nox sessions."""
import os
import shutil
import sys
from pathlib import Path
from textwrap import dedent
import nox
try:
from nox_poetry import Session, session
except ImportError:
message = f"""\
Nox failed to import the 'nox-poetry' package.
Please install it using the following command:
{sys.executable} -m pip install nox-poetry"""
raise SystemExit(dedent(message)) from None
package = "heisskleber"
locations = package, "tests", "docs/conf.py"
python_versions = ["3.9"] # ["3.10", "3.9", "3.11"]
nox.needs_version = ">= 2021.6.6"
nox.options.sessions = (
"mypy",
"tests",
"lint",
"typeguard",
"xdoctest",
"docs-build",
)
@session(python=python_versions[0])
def lint(session: Session) -> None:
"""Lint using ruff."""
args = session.posargs or locations
session.install("ruff")
session.run("ruff", *args)
@session(python=python_versions)
def mypy(session: Session) -> None:
"""Type-check using mypy."""
args = session.posargs or locations
session.install(".")
session.install("mypy", "pytest")
session.run("mypy", *args)
if not session.posargs:
session.run("mypy", f"--python-executable={sys.executable}", "noxfile.py")
@session(python=python_versions)
def tests(session: Session) -> None:
"""Run the test suite."""
session.install(".")
session.install("coverage[toml]", "pytest", "pygments")
try:
session.run("coverage", "run", "--parallel", "-m", "pytest", *session.posargs)
finally:
if session.interactive:
session.notify("coverage", posargs=[])
@session(python=python_versions[0])
def coverage(session: Session) -> None:
"""Produce the coverage report."""
args = session.posargs or ["report"]
session.install("coverage[toml]")
if not session.posargs and any(Path().glob(".coverage.*")):
session.run("coverage", "combine")
session.run("coverage", *args)
@session(python=python_versions[0])
def typeguard(session: Session) -> None:
"""Runtime type checking using Typeguard."""
session.install(".")
session.install("pytest", "typeguard", "pygments")
session.run("pytest", f"--typeguard-packages={package}", *session.posargs)
@session(python=python_versions)
def xdoctest(session: Session) -> None:
"""Run examples with xdoctest."""
if session.posargs:
args = [package, *session.posargs]
else:
args = [f"--modname={package}", "--command=all"]
if "FORCE_COLOR" in os.environ:
args.append("--colored=1")
session.install(".")
session.install("xdoctest[colors]")
session.run("python", "-m", "xdoctest", *args)
@session(name="docs-build", python=python_versions[0])
def docs_build(session: Session) -> None:
"""Build the documentation."""
args = session.posargs or ["docs", "docs/_build"]
if not session.posargs and "FORCE_COLOR" in os.environ:
args.insert(0, "--color")
session.install(".")
session.install(
"sphinx", "sphinx-autodoc-typehints", "sphinx-rtd-theme", "myst-parser"
)
build_dir = Path("docs", "_build")
if build_dir.exists():
shutil.rmtree(build_dir)
session.run("sphinx-build", *args)
@session(python=python_versions[0])
def docs(session: Session) -> None:
"""Build and serve the documentation with live reloading on file changes."""
args = session.posargs or ["--open-browser", "docs", "docs/_build"]
session.install(".")
session.install(
"sphinx", "sphinx-autodoc-typehints", "sphinx-rtd-theme", "myst-parser"
)
build_dir = Path("docs", "_build")
if build_dir.exists():
shutil.rmtree(build_dir)
session.run("sphinx-autobuild", *args)

1499
poetry.lock generated Normal file

File diff suppressed because it is too large Load Diff

93
pyproject.toml Normal file
View File

@@ -0,0 +1,93 @@
[tool.poetry]
name = "heisskleber"
version = "0.1.0"
description = "Heisskleber"
authors = ["Felix Weiler <felix@flucto.tech>"]
license = "MIT"
readme = "README.md"
homepage = "https://github.com/flucto-gmbh/heisskleber"
repository = "https://github.com/flucto-gmbh/heisskleber"
documentation = "https://heisskleber.readthedocs.io"
[tool.poetry.urls]
Changelog = "https://github.com/flucto-gmbh/heisskleber/releases"
[tool.poetry.dependencies]
python = "^3.9"
[tool.poetry.group.dev.dependencies]
black = ">=21.10b0"
coverage = { extras = ["toml"], version = ">=6.2" }
furo = ">=2021.11.12"
mypy = ">=0.930"
pre-commit = ">=2.16.0"
pre-commit-hooks = ">=4.1.0"
pytest = ">=6.2.5"
pytest-cov = "^4.1.0"
pytest-mock = "^3.11.1"
ruff = "^0.0.292"
pyupgrade = ">=2.29.1"
safety = ">=1.10.3"
sphinx = ">=4.3.2"
sphinx-autobuild = ">=2021.3.14"
sphinx-autodoc-typehints = "^1.24.0"
sphinx-rtd-theme = "^1.3.0"
typeguard = ">=2.13.3"
xdoctest = { extras = ["colors"], version = ">=0.15.10" }
myst-parser = { version = ">=0.16.1" }
[tool.poetry.scripts]
heisskleber = "heisskleber.__main__:main"
[tool.coverage.paths]
source = ["heisskleber", "*/site-packages"]
tests = ["tests", "*/tests"]
[tool.coverage.run]
branch = true
source = ["heisskleber", "tests"]
[tool.coverage.report]
show_missing = true
# fail_under = 100
[tool.mypy]
strict = true
warn_unreachable = true
pretty = true
show_column_numbers = true
show_error_context = true
[tool.ruff]
target-version = "py39"
line-length = 120
fix = true
select = [
"YTT", # flake8-2020
"S", # flake8-bandit
"B", # flake8-bugbear
"A", # flake8-builtins
"C4", # flake8-comprehensions
"T10", # flake8-debugger
"SIM", # flake8-simplify
"I", # isort
"C90", # mccabe
"E",
"W", # pycodestyle
"F", # pyflakes
"PGH", # pygrep-hooks
"UP", # pyupgrade
"RUF", # ruff
"TRY", # tryceratops
]
ignore = [
"E501", # LineTooLong
"E731", # DoNotAssignLambda
"A001", #
]
[tool.ruff.per-file-ignores]
"tests/*" = ["S101", "D"]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

0
tests/__init__.py Normal file
View File

3
tests/conftest.py Normal file
View File

@@ -0,0 +1,3 @@
# This is the pytest configuration file.
# It is loaded automatically by pytest and any fixtures placed here are available
# for all tests

7
tests/test_version.py Normal file
View File

@@ -0,0 +1,7 @@
"""Test the version of the package."""
import heisskleber
def test_glue_version() -> None:
"""Test that the glue version is correct."""
assert heisskleber.__version__ == "0.1.0"