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: