From 8bcc85c6af254d5fa1f43c891a5203dbaf2f5cf9 Mon Sep 17 00:00:00 2001 From: SuperElectron Date: Wed, 26 Aug 2026 17:40:09 -0700 Subject: [PATCH] =?UTF-8?q?chore:=20release=201.0.0=20=E2=80=94=20ship=20t?= =?UTF-8?q?he=20catalog=20inside=20the=20wheel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - version 1.0.0 - wheel now packages patterns/ (docs + examples + tests) so the MCP server works from an installed distribution, not only a checkout - find_patterns_root falls back to the installed patterns package - verified clean-room: fresh venv + wheel -> server answers initialize, catalog loads 32 units Co-Authored-By: Claude Fable 5 --- pyproject.toml | 4 ++-- src/design_patterns/__init__.py | 2 +- src/design_patterns/catalog.py | 12 ++++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 104c09a..8303eb7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "python-design-patterns" -version = "0.1.0" +version = "1.0.0" description = "Design patterns in Python: naive, pythonic, and real-world examples, with an MCP server for agents." readme = "README.md" license = { file = "LICENSE" } @@ -44,7 +44,7 @@ requires = ["hatchling"] build-backend = "hatchling.build" [tool.hatch.build.targets.wheel] -packages = ["src/design_patterns", "src/design_patterns_mcp"] +packages = ["src/design_patterns", "src/design_patterns_mcp", "patterns"] [tool.ruff] line-length = 100 diff --git a/src/design_patterns/__init__.py b/src/design_patterns/__init__.py index e313c59..38cee3d 100644 --- a/src/design_patterns/__init__.py +++ b/src/design_patterns/__init__.py @@ -1,3 +1,3 @@ """Design patterns in Python: catalog loader and shared utilities.""" -__version__ = "0.1.0" +__version__ = "1.0.0" diff --git a/src/design_patterns/catalog.py b/src/design_patterns/catalog.py index 273038a..f34952c 100644 --- a/src/design_patterns/catalog.py +++ b/src/design_patterns/catalog.py @@ -8,6 +8,7 @@ from __future__ import annotations +import importlib.util import json from dataclasses import asdict, dataclass, field from pathlib import Path @@ -150,13 +151,20 @@ def to_json(self) -> str: def find_patterns_root(start: Path | None = None) -> Path: - """Locate the ``patterns/`` directory from a file inside the repo.""" + """Locate the ``patterns/`` directory. + + Works both from a repo checkout (walk upward from this file) and from an + installed wheel (the ``patterns`` package ships inside the distribution). + """ here = (start or Path(__file__)).resolve() for parent in [here, *here.parents]: candidate = parent / "patterns" if candidate.is_dir(): return candidate - raise CatalogError(f"no patterns/ directory above {here}") + spec = importlib.util.find_spec("patterns") + if spec is not None and spec.origin is not None: + return Path(spec.origin).parent + raise CatalogError(f"no patterns/ directory above {here} and no installed patterns package") def load_catalog(root: Path | None = None) -> Catalog: