Skip to content

Commit

Permalink
Clean up prototyping history
Browse files Browse the repository at this point in the history
  • Loading branch information
BastiTee committed Dec 17, 2024
1 parent bba1b9a commit 9005a1e
Show file tree
Hide file tree
Showing 17 changed files with 1,405 additions and 325 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ jobs:
matrix:
# https://www.python.org/downloads/
python-version: [
"3.8", # EOL: 2024-10
"3.9", # EOL: 2025-10
"3.10", # EOL: 2026-10
"3.11" # EOL: 2027-10
]
"3.9", # EOL: 2025-10
"3.10", # EOL: 2026-10
"3.11", # EOL: 2027-10
"3.12", # EOL: 2028-10
"3.13", # EOL: 2029-10
]
name: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"python.analysis.extraPaths": [
"my_module",
"kindle_to_markdown",
"tests",
".venv/bin/python"
],
Expand Down
103 changes: 11 additions & 92 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,100 +1,14 @@
# Changelog

## 0.3.2
## 0.0.1

- Upgraded all dependencies

## 0.3.1

- Codebase clean-ups

## 0.3.0

- Removed support for Python 3.7
- Upgraded all dependencies
- Added a make target to list outdated dependencies

[#11](https://github.com/BastiTee/python-boilerplate/pull/11)

## 0.2.0

- Added a script installer for fast CLI access
- Improved readability and infos in README

[#10](https://github.com/BastiTee/python-boilerplate/pull/10)

## 0.1.0

- Removed all explicit calls for Python 3 and assuming it everywhere (including project name) [#8](https://github.com/BastiTee/python-boilerplate/pull/8)
- Added a changelog [#9](https://github.com/BastiTee/python-boilerplate/pull/9)

## 0.0.9

- Added support for Python 3.9-3.11
- Updated dependencies

[#6](https://github.com/BastiTee/python-boilerplate/pull/6) [#7](https://github.com/BastiTee/python-boilerplate/pull/7)

## 0.0.8

- Removed a lot of remaining boilerplate
- Reduced dependencies
- Improved Makefile
- Improve rename script

[#5](https://github.com/BastiTee/python-boilerplate/pull/5)

## 0.0.7

- Introduced black code formatting
- Cleaned up README.md

[#4](https://github.com/BastiTee/python-boilerplate/pull/4)

## 0.0.6

- Migrated from pipenv to poetry
- Introduced matrix testing via Github actions
- Updated configuration files

[#3](https://github.com/BastiTee/python-boilerplate/pull/3)

## 0.0.5

- Add mypy support
- Fix test discovery in VSCode
- Add PyLance support

## 0.0.4

- Fix Intellisense for VScode
- Integrate configuration files

## 0.0.3

- Update boilerplate tooling to 2020

## 0.0.2

First release. Contains support for:

- Flask-based dummy application running on <http://localhost:9690>
- Basic project/module organization according to <https://packaging.python.org>
- Makefile-like management script
- pipenv virtual environments
- setup.py-based installer script
- Unit testing with pyTest
- Multicore/-interpreter testing with detox
- Linting (flake8) and code formatting (autopep8) support
- vscode editor configuration including debugging support, unit test discovery and on-save formatting
- Dockerized builds and run with nginx/uwsgi
- Publishing to PyPi.org at <https://pypi.org/project/python3-boilerplate/>
- Initial release

## How to release a new version

- Finish development on branch and merge to main
- Update this changelog, bump version number in `pyproject.toml` and commit
- Run
- Finish development on branch and merge to main
- Update this changelog, bump version number in `pyproject.toml` and commit
- Run

```shell
VERSION=$( poetry version --short ) &&\
Expand All @@ -103,4 +17,9 @@ git tag -a ${VERSION} -m "Version ${VERSION}" &&\
git push --tags
```

- Create a new release under <https://github.com/BastiTee/python-boilerplate/releases>
- Create a new release under <https://github.com/BastiTee/python-boilerplate/releases>
- Push to PyPi

```shell
poetry run twine upload dist/*
```
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ endif

export LC_ALL = C
export LANG = C.UTF-8
PY_FILES := my_module tests
PY_FILES := kindle_to_markdown tests
VERSION := $(shell poetry version --short)

# Bundle tasks
Expand Down Expand Up @@ -84,10 +84,8 @@ outdated:

run-venv:
@echo Execute package directly in virtual environment
$(POETRY_CMD) run python -m my_module
$(POETRY_CMD) run python -m kindle_to_markdown

install-run:
@echo Install and run package via CLI using the activated Python env
python -m pip install --upgrade .
@echo --- Note: The next command might fail before you reload your shell
my_module_cli
82 changes: 40 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
# python-boilerplate ![CI](https://github.com/BastiTee/python-boilerplate/workflows/CI/badge.svg)
# Kindle Annotations to Markdown

> A best-practices template project for Python modules
> A simple program to convert Kindle HTML annotations to a Markdown file
## Setup
## Features

- Create a new repository [using this template](https://github.com/BastiTee/python-boilerplate/generate).
- Make sure that `python` is installed and available on system path. I recommend using [`pyenv`](https://github.com/pyenv/pyenv). Note that Python 2 is _not_ supported. It's end of life was on January 1st, 2020.
- Make sure [`poetry`](https://python-poetry.org/) is installed. This usually just means `python -m pip install poetry`.
- Rename the project using [the provided script](rename_template.sh): `./rename_template.sh`.
- Run `make` to initialize the project configuration and build everything.
- Refer to [the Makefile](Makefile) to learn about the various operations available. Most of them are just facades for `poetry`.
- Conversion of page bookmarks, text highlights, and notes to Markdown
- Included reference positions of annotations
- Automatic detection of annotation file's language

## Features
## Usage

```shell
$ kindle_to_markdown --help
Usage: kindle_to_markdown [OPTIONS]

A simple program to convert Kindle HTML annotations to a Markdown file.

Options:
-i, --input-file PATH Path to the Kindle annotations HTML file.
[required]
-o, --output-file PATH Path to the Markdown file.
-p, --print-only Only print Markdown to the console.
--help Show this message and exit.
```

## Installation

### From PyPi

```shell
pip install kindle-to-markdown
```

### From Source

Prerequisites:

- `python` in a [supported version](pyproject.toml) available on your path.
- Package manager `poetry` installed (e.g., `python -m pip install poetry`)

- Basic project/module organization according to <https://packaging.python.org>
- Makefile bootstrapping script
- [poetry](https://python-poetry.org/) with virtual environments and project builds
- [black](https://github.com/psf/black) code formatting
- Unit testing with [pytest](https://docs.pytest.org/en/latest/)
- Linting ([flake8](http://flake8.pycqa.org)) and code formatting ([autopep8](https://github.com/hhatto/autopep8)) support
- [isort](https://pypi.org/project/isort/) support for automated import sorting
- [mpyp](https://pypi.org/project/mypy/) support for type checking
- Publishing to PyPi.org
- [vscode](https://code.visualstudio.com/) editor configuration including plugin recommendations, debugging support, unit test discovery and on-save formatting
- [Github actions](https://github.com/BastiTee/python-boilerplate/actions) continuous integration with multi-python testing
- Executable script so after package installation you can run from the CLI using `my_module_cli`

## Resources

- <http://packaging.python.org/>
- <https://packaging.python.org/en/latest/distributing.html>
- <https://pypi.org/>
- <https://github.com/pypa/sampleproject>
- <https://www.python.org/dev/peps/>
- <https://www.python.org/dev/peps/pep-0008/>
- <https://www.kennethreitz.org/essays/why-you-should-use-vs-code-if-youre-a-python-developer>
- <https://code.visualstudio.com/docs/python/python-tutorial>

## Future ideas and todos

- Embed flake8 config into `pyproject.toml` once they support it ([see](https://github.com/PyCQA/flake8/issues/234))
- Use cookiecutter instead of [shell script](./rename_template.sh) (it does work fine at the moment though)

## Licensing

This project is licensed under [Apache License 2.0](LICENSE.txt).
```shell
make
poetry run python -m kindle_to_markdown --help
```
16 changes: 16 additions & 0 deletions kindle-to-markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

if [ -z "$1" ]; then
echo "No Kindle annotations HTML provided."
exit 1
fi

ifile="$( cd "$(dirname "$1")"; pwd )/$(basename "$1")"
ofile="$(dirname "$ifile")/$(basename "$ifile" .html ).md"
echo -e "$ifile\n>> $ofile"

cd "$( cd "$( dirname "$0" )"; pwd )"

poetry run python \
-m kindle_to_markdown \
-i "$ifile" -o "$ofile"
2 changes: 2 additions & 0 deletions kindle_to_markdown/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
"""Module init-file."""
Loading

0 comments on commit 9005a1e

Please sign in to comment.