Automatically generate absolute Python imports and relative file paths from a project directory.
absolutely is a lightweight Python script that walks through your project directory and generates:
- π Absolute import paths for all Python modules (excluding
__init__.pyand__pycache__) - π Relative paths to all non-Python files (e.g., configs, data, assets)
Perfect for large projects where import statements or file references are hard to track manually.
You have a project folder like this:
project/
βββ utils/
β βββ tools.py
βββ data/
β βββ sample.json
βββ main.py
βββ init.py
Running absolutely will generate a file like this:
=== ABSOLUTE IMPORTS (Python Modules) === from utils.tools import * from main import *
=== RELATIVE FILE PATHS (Non-Python Files) === data/sample.json
Edit the script and point base_path to the root of your project:
base_path = Path(r"C:\Users\USER\Documents\pythonscripts")- Run the Script Just run the script with Python: python absolutely.py
- Output It creates an absolute_imports.txt file in your project root with two sections: β Absolute Python imports π Relative file links (non-.py)
π¦ Output Example
from shadowbrief.utils.tools import * from shadowbrief.main import *
data/sample.json assets/config.yaml
π§ Why? Simplify refactoring in large Python codebases Generate boilerplate imports for tools, scripts, or test runners Track non-Python assets for packaging or processing
π οΈ Dependencies Only built-in modules are used: pathlib
π License MIT β do what you want, just don't blame me if it explodes. π₯