Skip to main content

A package to track your imports

Project description

importsearch

importsearch is a CLI tool that inspects Python files and reports the import dependency graph for a given entry point.
Specify a target file and instantly view the downstream files and modules that it touches.

Looking for the Japanese guide? See README-ja.md.

Features

  • Rich CLI report: Presents dependencies and visited files in a styled table.
  • Multiple output formats: Choose between print (decorated), text, and json.
  • Stable traversal: Works on Path objects, avoiding cycles and duplicates during analysis.

Installation

pip install importsearch

CLI Usage

importsearch path/to/main.py --root . --output-format print

Common options

  • --root / -r: Root directory for the analysis (defaults to the current directory)
  • --output-format / -o: print | text | json
  • --output-file / -of: Base name for text / json reports (extension is added automatically)
  • --verbose / -v: Display progress logs during the walk

Example: Save a text report

importsearch src/main.py --root . --output-format text --output-file report

The command prints the summary to stdout and writes it to report.txt.

Optional: Programmatic Usage

While the CLI is the primary interface, you can instantiate the searcher directly:

import argparse
from pathlib import Path
from importsearch import importsearch

args = argparse.Namespace(
    file_path=Path("src/main.py"),
    root_path=Path("."),
    output_format="json",
    output_path=Path("dependencies"),
    verbose=False,
)

searcher = importsearch(args)
searcher.search()
searcher.summary()

Development

Run the test suite with pytest:

pytest

Contributions are welcome! If you have ideas for improvements, please open an issue or submit a pull request.

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

importsearch-0.2.0.tar.gz (50.9 kB view details)

Uploaded Source

Built Distribution

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

importsearch-0.2.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file importsearch-0.2.0.tar.gz.

File metadata

  • Download URL: importsearch-0.2.0.tar.gz
  • Upload date:
  • Size: 50.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for importsearch-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1a15c5379e8716bacb09fa80d4cce19dab02ea9a09183c8ca8c9cf7ecbe3901d
MD5 edd8b70124053a1ed5194394190aaa89
BLAKE2b-256 94e5c9aa50006736922d0348d2f14d8cd8e4f570b856bfd1165018268104491c

See more details on using hashes here.

File details

Details for the file importsearch-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: importsearch-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for importsearch-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 91b3f0d463a5c52dd0d923f1b77f4b3940e21e6066719432962eeb64918b6860
MD5 298a048403f5eba0fe9cded8ba2c68b8
BLAKE2b-256 e9d7679ddd34c2410674769df0b3d1aa727458467d8f6c02b82bb8118c0bd8e9

See more details on using hashes here.

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