# Hatch vs Poetry: CIに適したPythonプロジェクトツールはどちら?

> Python CIにおけるHatch vs Poetry: 標準ベースの設定、環境、locking、build。どのプロジェクトマネージャがパッケージングとpipelineに合うか。

Source: https://latchkey.dev/ja/learn/tool-comparisons/hatch-vs-poetry  
Updated: 2026-06-25

HatchはPEP標準とmatrix環境に依拠し、Poetryは統合されたlockfile優先のワークフローを提供します。

HatchはPyPAのプロジェクトマネージャで、標準準拠のpyproject.toml設定、スクリプト可能な環境、高速なbuild backendに重点を置いています。Poetryは依存関係の解決、lockfile、パッケージングを1つの意見の強いツールにまとめています。

## Comparison

|  | Hatch | Poetry |
| --- | --- | --- |
| 設定 | pyproject.toml (PEP 621) | pyproject.toml (歴史的にPoetry固有) |
| Lockfile | plugin経由 / 新しめのサポート | poetry.lock (組み込み) |
| 環境 | matrix環境管理 | 単一のプロジェクトvenv |
| Build backend | hatchling (高速、人気) | poetry-core |
| 最適な用途 | ライブラリ、マルチ環境テスト | デフォルトで固定された依存関係を求めるapp |

## CIにおいて

Hatchは、Pythonのバージョンや依存関係セットのmatrixにまたがってテストするときに真価を発揮します - その環境モデルはCIのmatrixにきれいにマッピングされ、hatchlingは広く使われている標準に優しいbuild backendです。Poetryは、コミットされたlockfileから決定論的なインストールを最小限のセットアップで行いたいときに真価を発揮します。多くのライブラリ作者はbuildにHatchを、多くのappチームはlockingにPoetryを好みます。

## pipeline向けの選択

ライブラリを公開してバージョン/依存関係のmatrixを回す: Hatch。コミットされたlockfileと1コマンドのインストールが最も重要なappを構築する: Poetry。どちらの場合も、lockや固定した入力をキーにして該当するvenvまたはwheelのcacheをcacheしましょう。

## Decide with your own numbers, not a feature table

Feature comparisons age badly and rarely decide anything, because both tools in a mature category can do the job. What differs is how each behaves on your repository, and that takes one afternoon to measure.

```Terminal
# time a cold install with each candidate, cache cleared
hyperfine --prepare "rm -rf node_modules" --warmup 1 \
  "<tool-a> install" "<tool-b> install"

# and the thing CI actually pays for: a cold run with no local cache
docker run --rm -v "$(pwd):/w" -w /w node:22 sh -c "<tool> install"
```

> Measure the cold path. Warm local benchmarks favour whichever tool you already have cached, which is exactly the condition a CI runner never has.

## What actually changes when you switch

- Lockfile format. A switch is a one-way door for anyone still on the old tool until everyone migrates, so plan it as a single coordinated change.
- Resolution strictness. Tools differ on whether an undeclared transitive import works, and the stricter one will surface latent bugs as new failures.
- CI cache configuration. The cache path and key differ per tool; carrying over the old ones silently disables caching.
- Everyone on the team and every runner must move together. Pin the version so they cannot drift.

## 結論

マルチ環境テストとPEP標準の設定を持つライブラリ: Hatch。lockfile優先でバッテリー同梱の依存関係管理を求めるapp: Poetry。パッケージングをするのかバージョンを固定するのかでツールを選びましょう。

## FAQ

### Hatch vs Poetry: Which Python Project Tool for CI?

Hatch is a PyPA project manager focused on standards-compliant pyproject.toml config, scriptable environments, and a fast build backend. Poetry bundles dependency resolution, a lockfile, and packaging in one opinionated tool.

### In CI?

Hatch shines when you test across a matrix of Python versions and dependency sets - its environment model maps cleanly onto CI matrices, and hatchling is a widely-used, standards-friendly build backend. Poetry shines when you want deterministic installs from a committed lockfile with minimal setup.

### Choosing for pipelines?

Publishing a library and running a version/dependency matrix: Hatch. Building an app where a committed lockfile and one-command install matter most: Poetry. Cache the relevant venv or wheel cache keyed on your lock or pinned inputs in both.

### Which should I choose?

Library with multi-environment testing and PEP-standard config: Hatch. App wanting lockfile-first, batteries-included dependency management: Poetry. Match the tool to whether you are packaging or pinning.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
