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
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 21.1MB
glibcpy 3.10–3.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
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.