hatch-polylith-bricks
Hatch build hook plugin for Polylith
Decision gist · record as of 2026-08-14
Yes, if you are using Hatch as your build backend and Polylith as your monorepo architecture. The hook solves the specific problem of packaging multiple libraries from one workspace without namespace conflicts. Install friction is low, maintenance is active, and there are no known vulnerabilities. Not relevant if you are not using Polylith or a different build system.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Hatch as your build backend and a Polylith workspace structure with bricks in bases/ and components/ directories.
- Low friction: pure Python wheel with only two lightweight runtime dependencies (hatchling and tomlkit).
- Active maintenance with a recent release 42 days ago and no security vulnerabilities.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
last release 2026-07-03 (42 days) · last repo commit 2026-08-07 · 553 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 299,580 downloads/mo, #7,857 on PyPI
Alternatives
Verify before relying
Add to pyproject.toml:
[build-system]
requires = ["hatchling", "hatch-polylith-bricks"]
build-backend = "hatchling.build"
[tool.hatch.build.hooks.polylith-bricks]
# Section enables the hook
[tool.polylith.bricks]
"../../bases/my_namespace/my_base" = "my_namespace/my_base"
Then run: hatch build- Whether AST-based import rewriting handles all Python import patterns (relative imports, star imports, etc.)
- Performance impact when rewriting large codebases with many bricks
- Compatibility with Polylith workspaces using non-standard directory layouts
What it is and what it does
This package is a Hatch build hook that bridges Polylith architecture—a modular monorepo pattern—with Python packaging. It reads brick definitions from your pyproject.toml (paths to bases and components in your Polylith workspace) and ensures they are correctly included in built wheels and source distributions. The hook also solves a real packaging problem: when multiple libraries built from the same monorepo share the same top-level namespace, they collide when installed in the same environment. This hook can rewrite imports during packaging to add a custom namespace wrapper, preventing those collisions.
The rewriting uses Python's ast module to parse and modify source code, injecting a custom top namespace into all imports. Without a custom namespace configured, the hook simply includes bricks as-is. It's designed for teams using Polylith who need to publish multiple independent libraries from a single workspace without namespace conflicts.
Use it for
- Publishing multiple Python libraries from a Polylith monorepo without namespace collisions when installed together.
- Automatically including Polylith bricks in wheel and sdist distributions during Hatch builds.
- Adding a custom namespace prefix to library code during packaging to isolate it from other monorepo libraries.
- Simplifying build configuration for Polylith workspaces by automating brick discovery and inclusion.
- Rewriting internal imports in source code to reflect a different namespace structure in the published package.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you are using Hatch as your build backend and Polylith as your monorepo architecture.
The hook solves the specific problem of packaging multiple libraries from one workspace without namespace conflicts. Install friction is low, maintenance is active, and there are no known vulnerabilities. Not relevant if you are not using Polylith or a different build system.
Install
hatch-polylith-bricks on PyPI
Before you install
Low friction: pure Python wheel with only two lightweight runtime dependencies (hatchling and tomlkit). Active maintenance with a recent release 42 days ago and no security vulnerabilities.
Requires Hatch as your build backend and a Polylith workspace structure with bricks in bases/ and components/ directories.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
Add to pyproject.toml:
[build-system]
requires = ["hatchling", "hatch-polylith-bricks"]
build-backend = "hatchling.build"
[tool.hatch.build.hooks.polylith-bricks]
# Section enables the hook
[tool.polylith.bricks]
"../../bases/my_namespace/my_base" = "my_namespace/my_base"
Then run: hatch build
Verify before relying
- Whether AST-based import rewriting handles all Python import patterns (relative imports, star imports, etc.)
- Performance impact when rewriting large codebases with many bricks
- Compatibility with Polylith workspaces using non-standard directory layouts
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release <4.0,>=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packageshatchlingtomlkit |
| Maintenance | Actively maintained 42 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 299,580 / month, #7,857 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Framework :: HatchLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: hatch_polylith_bricks-1.5.7-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “hatch build hook polylith”
- hatch-polylith-bricksA Hatch build hook that integrates Polylith architecture bricks into…
- polylith-cliA command-line tool that scaffolds and manages Polylith architecture…
- hatch-jupyter-builderA Hatch build hook plugin that automates the build process for…
Give your agent the search over MCP, or paste the wish link into any chat.
More Build Tools packages
Provides reusable utilities for Python packaging interoperability, including version handling, specifiers, markers, requirements, tags, and metadata parsing according to standards like PEP 440 and PEP 425.
Wraps any iterable to display a real-time progress bar in the terminal or Jupyter notebook, showing iteration count, elapsed time, and estimated time remaining.
pip is the standard installer for Python packages, enabling you to download and install packages from the Python Package Index and other indexes into your Python environment.
Hatchling is a standards-compliant Python build backend that handles packaging, metadata, and distribution of Python projects when configured in a project's pyproject.toml file.
Generates Python gRPC service stubs and message classes from Protocol Buffer definitions, enabling developers to build gRPC clients and servers.
pre-commit is a framework for installing and running git hooks written in any language before commits are made, automating code quality and validation checks across multi-language projects.
Install it if your team needs consistent, automated validation at commit time.
See also hatch-cython · polylith-cli · hatch_build_scripts · hatchling-autoextras-hook · hatch-requirements-txt · hatch-regex-commit · hatch-fancy-pypi-readme · hatch-nodejs-version · hatch-vcs