How kivicode/pipzap works
Project Type and Purpose
• This is a Python command-line tool (CLI) for dependency pruning and format conversion.
• It ingests a dependency file (requirements.txt, pyproject.toml for Poetry or uv), resolves the full graph via the uv library, prunes transitive dependencies, and emits a minimal list in the chosen format.
High-Level Components
• CLI Layer (pipzap/cli.py, __main__.py)
• Argument parsing (file path, python version, output format, verbosity)
• Entrypoint dispatch to internal pipeline
• Parsing Layer (pipzap/parsing)
• parser.py: Detects input format and extracts raw dependencies
• converter.py: Normalizes legacy Poetry keys to standard project metadata
• workspace.py: Builds a temporary isolated pyproject.toml for uv resolution
• Core Layer (pipzap/core)
• dependencies.py: Interfaces with uv to build the full dependency graph
• pruner.py: Walks the graph to remove transitively satisfied dependencies
• source_format.py: Captures source file metadata (python version, extras, indexes)
• Formatting Layer (pipzap/formatting)
• base.py: Defines the formatter interface
• _uv_to_poetry.py, poetry.py, requirements.py, uv.py: Implement output in uv, Poetry, or pip-style formats
• Utilities & Exceptions (pipzap/utils, pipzap/exceptions.py)
• I/O helpers, debug logging, string utilities, custom error classes
• External Service
• The uv library (astral-sh/uv) for dependency resolution
Data Flow & Interactions
• User runs pipzap <input-file> [options].
→ CLI Layer reads args
→ reads the input file via IO util
→ Parsing Layer detects format and extracts direct dependencies
→ Workspace writes a temp pyproject.toml
→ Core Layer calls uv resolver → gets full dependency graph
→ Pruner removes redundancies → returns pruned list + metadata
→ Formatting Layer renders the output format
→ writes to stdout or output file via IO util
Architectural Patterns & Design Principles
• Single Responsibility: Each subpackage (cli, parsing, core, formatting) has a well-defined role.
• Pipeline: Clear linear flow from input → parse → resolve → prune → format → output.
• Dependency Injection: Formatter implementations plug into the CLI via the base interface.
• Isolation: Uses a temporary workspace to avoid side effects in the user’s environment.
Technologies & Frameworks
• Python 3.8+
• click or argparse (in cli.py) for argument parsing
• uv library for dependency resolution
• Poetry/pyproject metadata parsing
• pytest for tests, pre-commit/ruff for linting, GitHub Actions for CI
Checklist
• [ ] Each package/module is a labeled node.
• [ ] External dependencies (uv library, file system I/O) are distinctly marked.
• [ ] Options (format choice, python version) are annotated near the CLI node.