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, andjson. - Stable traversal: Works on
Pathobjects, 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 fortext/jsonreports (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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a15c5379e8716bacb09fa80d4cce19dab02ea9a09183c8ca8c9cf7ecbe3901d
|
|
| MD5 |
edd8b70124053a1ed5194394190aaa89
|
|
| BLAKE2b-256 |
94e5c9aa50006736922d0348d2f14d8cd8e4f570b856bfd1165018268104491c
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91b3f0d463a5c52dd0d923f1b77f4b3940e21e6066719432962eeb64918b6860
|
|
| MD5 |
298a048403f5eba0fe9cded8ba2c68b8
|
|
| BLAKE2b-256 |
e9d7679ddd34c2410674769df0b3d1aa727458467d8f6c02b82bb8118c0bd8e9
|