From 20dca2eefa1e6f29e7e41437ac423459bd13c0cf Mon Sep 17 00:00:00 2001 From: Michael Pilosov Date: Sun, 5 Apr 2026 22:52:45 -0600 Subject: [PATCH] Restructure as src-layout Python package with bundled static assets --- Makefile | 6 +++--- pyproject.toml | 7 +++++++ __init__.py => src/chess_pressure/__init__.py | 0 app.py => src/chess_pressure/app.py | 2 +- engine.py => src/chess_pressure/engine.py | 0 games.py => src/chess_pressure/games.py | 0 {static => src/chess_pressure/static}/app.js | 0 {static => src/chess_pressure/static}/gif.js | 0 {static => src/chess_pressure/static}/gif.worker.js | 0 .../static}/img/chesspieces/wikipedia/bB.png | Bin .../static}/img/chesspieces/wikipedia/bK.png | Bin .../static}/img/chesspieces/wikipedia/bN.png | Bin .../static}/img/chesspieces/wikipedia/bP.png | Bin .../static}/img/chesspieces/wikipedia/bQ.png | Bin .../static}/img/chesspieces/wikipedia/bR.png | Bin .../static}/img/chesspieces/wikipedia/wB.png | Bin .../static}/img/chesspieces/wikipedia/wK.png | Bin .../static}/img/chesspieces/wikipedia/wN.png | Bin .../static}/img/chesspieces/wikipedia/wP.png | Bin .../static}/img/chesspieces/wikipedia/wQ.png | Bin .../static}/img/chesspieces/wikipedia/wR.png | Bin {static => src/chess_pressure/static}/index.html | 0 {static => src/chess_pressure/static}/style.css | 0 23 files changed, 11 insertions(+), 4 deletions(-) rename __init__.py => src/chess_pressure/__init__.py (100%) rename app.py => src/chess_pressure/app.py (96%) rename engine.py => src/chess_pressure/engine.py (100%) rename games.py => src/chess_pressure/games.py (100%) rename {static => src/chess_pressure/static}/app.js (100%) rename {static => src/chess_pressure/static}/gif.js (100%) rename {static => src/chess_pressure/static}/gif.worker.js (100%) rename {static => src/chess_pressure/static}/img/chesspieces/wikipedia/bB.png (100%) rename {static => src/chess_pressure/static}/img/chesspieces/wikipedia/bK.png (100%) rename {static => src/chess_pressure/static}/img/chesspieces/wikipedia/bN.png (100%) rename {static => src/chess_pressure/static}/img/chesspieces/wikipedia/bP.png (100%) rename {static => src/chess_pressure/static}/img/chesspieces/wikipedia/bQ.png (100%) rename {static => src/chess_pressure/static}/img/chesspieces/wikipedia/bR.png (100%) rename {static => src/chess_pressure/static}/img/chesspieces/wikipedia/wB.png (100%) rename {static => src/chess_pressure/static}/img/chesspieces/wikipedia/wK.png (100%) rename {static => src/chess_pressure/static}/img/chesspieces/wikipedia/wN.png (100%) rename {static => src/chess_pressure/static}/img/chesspieces/wikipedia/wP.png (100%) rename {static => src/chess_pressure/static}/img/chesspieces/wikipedia/wQ.png (100%) rename {static => src/chess_pressure/static}/img/chesspieces/wikipedia/wR.png (100%) rename {static => src/chess_pressure/static}/index.html (100%) rename {static => src/chess_pressure/static}/style.css (100%) diff --git a/Makefile b/Makefile index afa8c93..cb08dab 100644 --- a/Makefile +++ b/Makefile @@ -10,12 +10,12 @@ serve: # Lint lint: fmt - uvx ruff check chess_pressure/ + uvx ruff check src/chess_pressure/ # Format fmt: - uvx ruff format chess_pressure/ - uvx ruff check --fix chess_pressure/ + uvx ruff format src/chess_pressure/ + uvx ruff check --fix src/chess_pressure/ help: @echo "chess-pressure" diff --git a/pyproject.toml b/pyproject.toml index 76057ea..ba330ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,3 +12,10 @@ dependencies = [ [project.scripts] chess-pressure = "chess_pressure.app:main" + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.build.targets.wheel] +packages = ["src/chess_pressure"] diff --git a/__init__.py b/src/chess_pressure/__init__.py similarity index 100% rename from __init__.py rename to src/chess_pressure/__init__.py diff --git a/app.py b/src/chess_pressure/app.py similarity index 96% rename from app.py rename to src/chess_pressure/app.py index 482027f..e25ad47 100644 --- a/app.py +++ b/src/chess_pressure/app.py @@ -13,7 +13,7 @@ from pydantic import BaseModel from .engine import make_move, parse_pgn from .games import get_game_list, get_game_pgn -STATIC = Path(__file__).resolve().parent.parent / "static" +STATIC = Path(__file__).resolve().parent / "static" app = FastAPI(title="Chess Pressure", docs_url=None, redoc_url=None) diff --git a/engine.py b/src/chess_pressure/engine.py similarity index 100% rename from engine.py rename to src/chess_pressure/engine.py diff --git a/games.py b/src/chess_pressure/games.py similarity index 100% rename from games.py rename to src/chess_pressure/games.py diff --git a/static/app.js b/src/chess_pressure/static/app.js similarity index 100% rename from static/app.js rename to src/chess_pressure/static/app.js diff --git a/static/gif.js b/src/chess_pressure/static/gif.js similarity index 100% rename from static/gif.js rename to src/chess_pressure/static/gif.js diff --git a/static/gif.worker.js b/src/chess_pressure/static/gif.worker.js similarity index 100% rename from static/gif.worker.js rename to src/chess_pressure/static/gif.worker.js diff --git a/static/img/chesspieces/wikipedia/bB.png b/src/chess_pressure/static/img/chesspieces/wikipedia/bB.png similarity index 100% rename from static/img/chesspieces/wikipedia/bB.png rename to src/chess_pressure/static/img/chesspieces/wikipedia/bB.png diff --git a/static/img/chesspieces/wikipedia/bK.png b/src/chess_pressure/static/img/chesspieces/wikipedia/bK.png similarity index 100% rename from static/img/chesspieces/wikipedia/bK.png rename to src/chess_pressure/static/img/chesspieces/wikipedia/bK.png diff --git a/static/img/chesspieces/wikipedia/bN.png b/src/chess_pressure/static/img/chesspieces/wikipedia/bN.png similarity index 100% rename from static/img/chesspieces/wikipedia/bN.png rename to src/chess_pressure/static/img/chesspieces/wikipedia/bN.png diff --git a/static/img/chesspieces/wikipedia/bP.png b/src/chess_pressure/static/img/chesspieces/wikipedia/bP.png similarity index 100% rename from static/img/chesspieces/wikipedia/bP.png rename to src/chess_pressure/static/img/chesspieces/wikipedia/bP.png diff --git a/static/img/chesspieces/wikipedia/bQ.png b/src/chess_pressure/static/img/chesspieces/wikipedia/bQ.png similarity index 100% rename from static/img/chesspieces/wikipedia/bQ.png rename to src/chess_pressure/static/img/chesspieces/wikipedia/bQ.png diff --git a/static/img/chesspieces/wikipedia/bR.png b/src/chess_pressure/static/img/chesspieces/wikipedia/bR.png similarity index 100% rename from static/img/chesspieces/wikipedia/bR.png rename to src/chess_pressure/static/img/chesspieces/wikipedia/bR.png diff --git a/static/img/chesspieces/wikipedia/wB.png b/src/chess_pressure/static/img/chesspieces/wikipedia/wB.png similarity index 100% rename from static/img/chesspieces/wikipedia/wB.png rename to src/chess_pressure/static/img/chesspieces/wikipedia/wB.png diff --git a/static/img/chesspieces/wikipedia/wK.png b/src/chess_pressure/static/img/chesspieces/wikipedia/wK.png similarity index 100% rename from static/img/chesspieces/wikipedia/wK.png rename to src/chess_pressure/static/img/chesspieces/wikipedia/wK.png diff --git a/static/img/chesspieces/wikipedia/wN.png b/src/chess_pressure/static/img/chesspieces/wikipedia/wN.png similarity index 100% rename from static/img/chesspieces/wikipedia/wN.png rename to src/chess_pressure/static/img/chesspieces/wikipedia/wN.png diff --git a/static/img/chesspieces/wikipedia/wP.png b/src/chess_pressure/static/img/chesspieces/wikipedia/wP.png similarity index 100% rename from static/img/chesspieces/wikipedia/wP.png rename to src/chess_pressure/static/img/chesspieces/wikipedia/wP.png diff --git a/static/img/chesspieces/wikipedia/wQ.png b/src/chess_pressure/static/img/chesspieces/wikipedia/wQ.png similarity index 100% rename from static/img/chesspieces/wikipedia/wQ.png rename to src/chess_pressure/static/img/chesspieces/wikipedia/wQ.png diff --git a/static/img/chesspieces/wikipedia/wR.png b/src/chess_pressure/static/img/chesspieces/wikipedia/wR.png similarity index 100% rename from static/img/chesspieces/wikipedia/wR.png rename to src/chess_pressure/static/img/chesspieces/wikipedia/wR.png diff --git a/static/index.html b/src/chess_pressure/static/index.html similarity index 100% rename from static/index.html rename to src/chess_pressure/static/index.html diff --git a/static/style.css b/src/chess_pressure/static/style.css similarity index 100% rename from static/style.css rename to src/chess_pressure/static/style.css