--- id: grimp version: "3.15" license: BSD 2-Clause License license_treatment: permissive maintenance: active --- # grimp — Builds a queryable graph of the imports within one or more Python packages. License: permissive · Maintenance: active · Downloads: 14.3M/mo ## What it is and what it does Grimp is a Python import graph builder that constructs a queryable representation of how modules within one or more packages import each other. It parses the installed package code and builds a directed graph where nodes are modules and edges represent import relationships. You use it to answer questions like 'what does this module import', 'what imports this module', and 'what is the shortest import chain between two modules'. The package supports analyzing single packages, multiple packages together, and namespace packages. By default it excludes external dependencies, but you can include them to see the full import picture including third-party libraries. It returns import details including line numbers and the actual import statements, making it useful for code audits, refactoring, and understanding package architecture. Use it for: - Audit a package's internal structure to identify circular dependencies or tightly coupled modules. - Find the shortest import path between two modules to understand coupling depth. - Trace which modules depend on a specific internal API before refactoring it. - Analyze namespace packages to understand how portions are distributed and imported. - Generate import statistics for code quality reports or architecture documentation. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Grimp builds a queryable graph of Python package imports, letting you analyze module dependencies, find import chains, and trace which modules import what. Yes. Grimp is actively maintained, has no known vulnerabilities, uses a permissive license, and solves a specific problem—understanding Python package import structure—that has no obvious built-in alternative. The medium install friction is standard for compiled packages and poses no real barrier. Install it if you need to analyze or audit module dependencies in Python code. ## Install pip install grimp uv add grimp poetry add grimp ## Installing grimp Before you install: Medium install friction due to compiled wheels for multiple platforms and Python versions (3.10–3.14). Last release 42 days ago; repository is active with 129 stars and recent commits. License in practice: BSD 2-Clause License is permissive; you may use, modify, and distribute grimp with minimal restrictions, provided you retain the license notice. Quickstart: pip install grimp import grimp graph = grimp.build_graph('somepackage') children = graph.find_children('somepackage.foo') upstream = graph.find_upstream_modules('somepackage.foo') Requires Python 3.10 or later; the target package must be installed before building its graph. Verify before relying: - Performance characteristics on large codebases (number of modules or import depth limits). - Whether the graph API supports filtering or excluding specific import types (e.g., conditional imports). - Behavior when analyzing packages with circular imports or dynamic imports. ## Package facts - License: BSD 2-Clause License (permissive) - Python support: supports_current - Install friction: medium - Maintenance: active - Downloads: 14.3M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags python import graph analysis, module dependency visualization, find import chains, analyze package structure, trace module imports, dependency graph builder, python code structure analysis, code-analysis, dependency-graph, refactoring-tool [View on SkillFed](https://skillfed.io/packages/grimp) · [View on PyPI](https://pypi.org/project/grimp/)