Registry / devops / hatch-polylith-bricks

hatch-polylith-bricks

JSON →
library1.5.6pypypiunverified

Hatch Polylith Bricks is a Hatch build hook plugin that integrates Polylith architecture principles into Hatch-managed Python projects. It enables the use of Polylith's `poly` CLI commands for monorepo development, helping manage workspaces, components, and bases. The current version is 1.5.5, with frequent updates addressing new features and fixes.

pip install hatch-polylith-bricks
INSTALL
IMPORT
SIG · HATCH-POLYLITH-BRI
H
hatch-polylith-bricks
devopspythonv1.5.6
Install
2.0s avg
Import
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.5.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 21.1MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.0s · import 0.000s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PolylithBuildHook
from hatch_polylith_bricks import PolylithBuildHook
from hatch_polylith_bricks import PolylithBuildHook

Configure `hatch-polylith-bricks` in your `pyproject.toml` as a Hatch build hook, set up your Polylith `workspace.toml`, and then use the `poly` command-line interface to interact with your Polylith project. The example guides through the setup and demonstrates running a basic `poly info` command.

# 1. Ensure you have Hatch installed: `pip install hatch` # 2. Initialize a Hatch project (if you don't have one): # `hatch new my-polylith-project` # `cd my-polylith-project` print("--- Step 1: Configure pyproject.toml ---") print("Add the following to your project's pyproject.toml:") print("```toml") print("[tool.hatch.build.hooks.polylith]") print("# Optional: specify top-level namespace if different from 'project.name'") print("# namespace = \"my_polylith_namespace\"") print("```") print("\n--- Step 2: Create a workspace.toml (optional but recommended) ---") print("Create a file named workspace.toml in your project root with content like:") print("```toml") print("[tool.polylith]") print("namespace = \"my_polylith_namespace\" # Replace with your actual namespace") print("bases = [\"src/bases\"]") print("components = [\"src/components\"]") print("projects = [\"projects/*\"]") print("```") print("\n--- Step 3: Run a Polylith CLI command ---") print("Make sure you are in the project's root directory where pyproject.toml and workspace.toml reside.") import subprocess try: print("Attempting to run 'poly info'...") # In a real Hatch project, you'd typically run: hatch run poly info # This example assumes 'poly' is accessible from the current environment/PATH result = subprocess.run(['poly', 'info'], capture_output=True, text=True, check=True) print("STDOUT:\n", result.stdout) if result.stderr: print("STDERR:\n", result.stderr) print("\nSuccessfully ran 'poly info'.") except FileNotFoundError: print("Error: 'poly' command not found.\nEnsure 'hatch-polylith-bricks' is installed and 'poly' is in your PATH,\nor run via 'hatch run poly info' if within a Hatch-managed project environment.") except subprocess.CalledProcessError as e: print(f"Error running 'poly info': {e}") print("STDOUT:\n", e.stdout) print("STDERR:\n", e.stderr)
poly --version
Debug
Known issues
gotchaOlder versions (before 1.5.0, stable-94) might fail at runtime for Python 3.8 environments due to a missing `typing-extensions` dependency for Typer, which was silently dropped by Typer. This could lead to `ModuleNotFoundError`.
fix
Upgrade to `hatch-polylith-bricks>=1.5.0` or explicitly install `typing-extensions` (`pip install typing-extensions`).
affects: <1.5.0
gotchaThe `poly check` and `poly libs` commands in older versions (before 1.5.2, stable-99) might incorrectly report missing imports or dependencies when third-party libraries have similar names to Polylith top namespaces. This could lead to misleading warnings or errors.
fix
Upgrade to `hatch-polylith-bricks>=1.5.2` for accurate dependency and import reporting.
affects: <1.5.2
gotchaRunning `poly create component` or `poly create base` in versions 1.5.1 and newer (stable-98) will now exit with a non-zero fail code if a brick with the same name already exists. This changes previous behavior where it might have proceeded or warned without failing, potentially breaking automation scripts.
fix
Update automation scripts to check for the exit code (`0` for success, non-`0` for failure), or ensure unique brick names are provided when creating new bricks.
affects: >=1.5.1
Upgrade
Version history
1.5.6latest on PyPI · released Apr 18, 2026
Audit
Dependencies
polylithrequiredProvides core Polylith functionality and `poly` CLI commands, used by the build hook.
hatchrequiredRequired to use `hatch-polylith-bricks` as a build hook within a Hatch project; project must be managed by Hatch.
typing-extensionsoptionalEnsures compatibility with the underlying Typer CLI framework across various Python versions, especially Python 3.8.
Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
1
Resources
hatch-polylith-bricks — pip install hatch-polylith-bricks · libregistry