From 26905ce90b897955435344920c67a3c65131a503 Mon Sep 17 00:00:00 2001 From: Ben Soyka Date: Sat, 26 Jul 2025 12:45:55 -0600 Subject: [PATCH 1/4] chore(gitignore): bump to current Python template --- .gitignore | 86 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 67 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 8f6a6e1..4348f8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,6 @@ -# Copied from bsoyka/template on GitHub -# Some lines may not be necessary for this project - -#### PYTHON #### - # Byte-compiled / optimized / DLL files __pycache__/ -*.py[cod] +*.py[codz] *$py.class # C extensions @@ -51,7 +46,7 @@ htmlcov/ nosetests.xml coverage.xml *.cover -*.py,cover +*.py.cover .hypothesis/ .pytest_cache/ cover/ @@ -99,7 +94,37 @@ ipython_config.py # install all needed dependencies. #Pipfile.lock -# PEP 582; used by e.g. github.com/David-OConnor/pyflow +# UV +# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +#uv.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 +#poetry.toml + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python. +# https://pdm-project.org/en/latest/usage/project/#working-with-version-control +#pdm.lock +#pdm.toml +.pdm-python +.pdm-build/ + +# pixi +# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control. +#pixi.lock +# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one +# in the .venv directory. It is recommended not to include this directory in version control. +.pixi + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm __pypackages__/ # Celery stuff @@ -111,6 +136,7 @@ celerybeat.pid # Environments .env +.envrc .venv env/ venv/ @@ -142,14 +168,36 @@ dmypy.json # Cython debug symbols cython_debug/ -#### VISUAL STUDIO CODE #### - -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -# Local History for Visual Studio Code -.history/ +# 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/ + +# Abstra +# Abstra is an AI-powered process automation framework. +# Ignore directories containing user credentials, local state, and settings. +# Learn more at https://abstra.io/docs +.abstra/ + +# Visual Studio Code +# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore +# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore +# and can be added to the global gitignore or merged into this file. However, if you prefer, +# you could uncomment the following to ignore the entire vscode folder +# .vscode/ + +# Ruff stuff: +.ruff_cache/ + +# PyPI configuration file +.pypirc + +# Marimo +marimo/_static/ +marimo/_lsp/ +__marimo__/ + +# Streamlit +.streamlit/secrets.toml From f87d79b40f2af3f2166955c45a5468578379e990 Mon Sep 17 00:00:00 2001 From: Ben Soyka Date: Sat, 26 Jul 2025 12:50:21 -0600 Subject: [PATCH 2/4] refactor: make version number dynamic This makes `pyproject.toml` the single source of truth for the current version number. The module uses the standard `importlib` to pull the version number, and Sphinx now pulls from that variable when building docs. --- advent_of_code_ocr/__init__.py | 4 +++- docs/conf.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/advent_of_code_ocr/__init__.py b/advent_of_code_ocr/__init__.py index 451fffa..4d46b0d 100644 --- a/advent_of_code_ocr/__init__.py +++ b/advent_of_code_ocr/__init__.py @@ -1,6 +1,8 @@ """A library to parse Advent of Code ASCII art.""" +from importlib.metadata import version as get_version + from .height_6 import convert_6 as convert_6 from .height_6 import convert_array_6 as convert_array_6 -__version__ = '1.1.0' +__version__ = get_version(__package__) diff --git a/docs/conf.py b/docs/conf.py index 0883155..9d5d4e2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -7,10 +7,12 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information +from advent_of_code_ocr import __version__ + project = 'Advent of Code OCR' copyright = '2020-present Benjamin Soyka' # noqa: A001 author = 'Ben Soyka' -release = '1.1.0' +release = __version__ # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration From 93fa1ff5c88b2b6bfecfa1fd1622cf1846687ae0 Mon Sep 17 00:00:00 2001 From: Ben Soyka Date: Sat, 26 Jul 2025 13:52:14 -0500 Subject: [PATCH 3/4] fix: specify package name when pulling version Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- advent_of_code_ocr/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advent_of_code_ocr/__init__.py b/advent_of_code_ocr/__init__.py index 4d46b0d..d85030c 100644 --- a/advent_of_code_ocr/__init__.py +++ b/advent_of_code_ocr/__init__.py @@ -5,4 +5,4 @@ from .height_6 import convert_6 as convert_6 from .height_6 import convert_array_6 as convert_array_6 -__version__ = get_version(__package__) +__version__ = get_version('advent_of_code_ocr') From 2ee0df012388728b9bc7d6222eb108cf46354478 Mon Sep 17 00:00:00 2001 From: Ben Soyka Date: Sat, 26 Jul 2025 13:00:55 -0600 Subject: [PATCH 4/4] test(init): cover dynamic version number This also includes adding the `toml` lib as a dev dependency (in uv, Tox, and Mypy configs). --- .pre-commit-config.yaml | 1 + pyproject.toml | 2 ++ tests/init_test.py | 15 +++++++++++++++ tox.ini | 1 + uv.lock | 22 ++++++++++++++++++++++ 5 files changed, 41 insertions(+) create mode 100644 tests/init_test.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6a17833..a80ca27 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,6 +27,7 @@ repos: additional_dependencies: - click - pytest + - types-toml ci: autofix_commit_msg: "style: auto fixes from pre-commit hooks" autofix_prs: true diff --git a/pyproject.toml b/pyproject.toml index a30fecf..f016f7f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,8 @@ dev = [ "pre-commit>=4.2.0", "pytest>=8.4.1", "ruff>=0.12.5", + "toml>=0.10.2", + "types-toml>=0.10.8.20240310", ] docs = [ "sphinx>=8.1.3", diff --git a/tests/init_test.py b/tests/init_test.py new file mode 100644 index 0000000..ce3c1f5 --- /dev/null +++ b/tests/init_test.py @@ -0,0 +1,15 @@ +"""Test the package __init__ module.""" + +from pathlib import Path + +import toml + +from advent_of_code_ocr import __version__ + + +def test_version() -> None: + """Test that the package version matches the pyproject.toml.""" + pyproject_path = Path(__file__).parent.parent / 'pyproject.toml' + pyproject = toml.load(pyproject_path) + + assert __version__ == pyproject['project']['version'] diff --git a/tox.ini b/tox.ini index 8e58222..4b2fc8c 100644 --- a/tox.ini +++ b/tox.ini @@ -14,5 +14,6 @@ wheel_build_env = .pkg deps = numpy>=2.0.2 pytest>=8.4.1 + toml>=0.10.2 commands = pytest {tty:--color=yes} {posargs} diff --git a/uv.lock b/uv.lock index 67cce0d..f52b236 100644 --- a/uv.lock +++ b/uv.lock @@ -24,6 +24,8 @@ dev = [ { name = "pre-commit" }, { name = "pytest" }, { name = "ruff" }, + { name = "toml" }, + { name = "types-toml" }, ] docs = [ { name = "sphinx", version = "8.1.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, @@ -42,6 +44,8 @@ dev = [ { name = "pre-commit", specifier = ">=4.2.0" }, { name = "pytest", specifier = ">=8.4.1" }, { name = "ruff", specifier = ">=0.12.5" }, + { name = "toml", specifier = ">=0.10.2" }, + { name = "types-toml", specifier = ">=0.10.8.20240310" }, ] docs = [{ name = "sphinx", specifier = ">=8.1.3" }] @@ -1158,6 +1162,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/52/a7/d2782e4e3f77c8450f727ba74a8f12756d5ba823d81b941f1b04da9d033a/sphinxcontrib_serializinghtml-2.0.0-py3-none-any.whl", hash = "sha256:6e2cb0eef194e10c27ec0023bfeb25badbbb5868244cf5bc5bdc04e4464bf331", size = 92072, upload-time = "2024-07-29T01:10:08.203Z" }, ] +[[package]] +name = "toml" +version = "0.10.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/be/ba/1f744cdc819428fc6b5084ec34d9b30660f6f9daaf70eead706e3203ec3c/toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f", size = 22253, upload-time = "2020-11-01T01:40:22.204Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/44/6f/7120676b6d73228c96e17f1f794d8ab046fc910d781c8d151120c3f1569e/toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", size = 16588, upload-time = "2020-11-01T01:40:20.672Z" }, +] + [[package]] name = "tomli" version = "2.2.1" @@ -1206,6 +1219,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/bd/75/8539d011f6be8e29f339c42e633aae3cb73bffa95dd0f9adec09b9c58e85/tomlkit-0.13.3-py3-none-any.whl", hash = "sha256:c89c649d79ee40629a9fda55f8ace8c6a1b42deb912b2a8fd8d942ddadb606b0", size = 38901, upload-time = "2025-06-05T07:13:43.546Z" }, ] +[[package]] +name = "types-toml" +version = "0.10.8.20240310" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/86/47/3e4c75042792bff8e90d7991aa5c51812cc668828cc6cce711e97f63a607/types-toml-0.10.8.20240310.tar.gz", hash = "sha256:3d41501302972436a6b8b239c850b26689657e25281b48ff0ec06345b8830331", size = 4392, upload-time = "2024-03-10T02:18:37.518Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/da/a2/d32ab58c0b216912638b140ab2170ee4b8644067c293b170e19fba340ccc/types_toml-0.10.8.20240310-py3-none-any.whl", hash = "sha256:627b47775d25fa29977d9c70dc0cbab3f314f32c8d8d0c012f2ef5de7aaec05d", size = 4777, upload-time = "2024-03-10T02:18:36.568Z" }, +] + [[package]] name = "typing-extensions" version = "4.14.1"