Skip to main content

Analyze, validate, and visualize Python import dependencies — like dependency-cruiser for Python.

Project description

import-cruiser

PyPI version Python versions Workflow License: MIT

Analyze, validate, and visualize Python import dependencies.

import-cruiser helps you quickly answer:

  • Where are tight couplings?
  • Are there circular imports?
  • Are architecture rules respected?

Why teams use it

  • Fast graph export to html, svg, and dot
  • Rule-based validation for CI (validate --strict)
  • Readable interactive HTML output for architecture reviews
  • Works out of the box on regular Python codebases

See it in action: project self-graph

Dependency graph of src/import_cruiser, generated by the tool itself:

import-cruiser self graph

Run make self-graph to refresh these artifacts—the script passes --show-loc so clusters include LOC badges in the DOT/HTML/SVG exports (with --cluster-mode module --cluster-depth 1, the self-graph renders a single top-level import_cruiser cluster and skips the src path layer). The target also passes --include-external-deps, so non-dev third-party packages render as a grouped green block labeled “External dependencies” (without LOC badges). External roots are read from both tool.poetry.dependencies and project.dependencies.

Install

pip install import-cruiser

60-second quick start

From your repo root:

# 1) Generate an interactive dependency graph
import-cruiser export . --format html --output deps.html

# 2) Generate an embeddable SVG
import-cruiser export . --format svg --output deps.svg

# 3) Detect cycles and get a JSON report
import-cruiser analyze . --output report.json

For larger repos, filter noise:

import-cruiser export . \
  --format html \
  --include-path '^src/' \
  --exclude-common-noise-paths \
  --output deps-src.html

Commands

import-cruiser analyze  <path>   # analyze imports, output json/dot/svg/html
import-cruiser export   <path>   # export graph dot/svg/html
import-cruiser validate <path>   # enforce dependency rules

Most useful options

  • --format {json,dot,svg,html}
  • --include, --exclude
  • --include-path, --exclude-path
  • --exclude-common-noise-paths
  • --cluster-depth, --cluster-mode
  • --include-db-connectors, --include-http-hosts
  • --show-loc to show LOC per node/cluster and total LOC badge in HTML
  • --include-external-deps to surface non-dev third-party packages as grouped green nodes (auto-enabled in the self-graph)
  • --external-deps-include, --external-deps-exclude to filter which external dependency roots are surfaced

Validate architecture in CI

Minimal import-cruiser.json example:

{
  "rules": [
    {
      "name": "no-data-to-ui",
      "severity": "error",
      "from": { "path": "\\.data" },
      "to": { "path": "\\.ui" },
      "allow": false
    }
  ]
}

Run in CI:

import-cruiser validate . --config import-cruiser.json --strict --output-format github

Development

poetry install
poetry run pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

import_cruiser-0.2.36.tar.gz (36.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

import_cruiser-0.2.36-py3-none-any.whl (38.0 kB view details)

Uploaded Python 3

File details

Details for the file import_cruiser-0.2.36.tar.gz.

File metadata

  • Download URL: import_cruiser-0.2.36.tar.gz
  • Upload date:
  • Size: 36.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for import_cruiser-0.2.36.tar.gz
Algorithm Hash digest
SHA256 eacaaa62996ea2294b6a65ac6da57d569d29e07c5eaf72d97dc89bde0409a870
MD5 7acf7a70239a95e29d9dc708a207d335
BLAKE2b-256 ac02b9bd6e69a077913878adbf36c00eb3f4e8c80f962bfc56e7ddfb4d9c3279

See more details on using hashes here.

Provenance

The following attestation bundles were made for import_cruiser-0.2.36.tar.gz:

Publisher: workflow.yml on kevin91nl/import-cruiser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file import_cruiser-0.2.36-py3-none-any.whl.

File metadata

File hashes

Hashes for import_cruiser-0.2.36-py3-none-any.whl
Algorithm Hash digest
SHA256 05fcd9dd58de023a065060c29ab82c4b4b1bf0cf1d3d66fec965d60c7d45b9bf
MD5 654a986fe6cb3a216cf0c4f3e8d511a0
BLAKE2b-256 e36063ef088bc9477b39de23a4420d68fbde4c1ebe07143751c86a810a71b0de

See more details on using hashes here.

Provenance

The following attestation bundles were made for import_cruiser-0.2.36-py3-none-any.whl:

Publisher: workflow.yml on kevin91nl/import-cruiser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page