Registry / data / importlab

importlab

JSON →
library0.8.1pypiunverified

Importlab is a Python library that automatically infers dependencies and calculates a dependency graph for Python files. It can perform dependency ordering of a set of files, including cycle detection. Its primary use case is to work with static analysis tools that process one file at a time, ensuring dependencies are analyzed first. The project is currently at version 0.8.1 and its GitHub repository was archived on May 6, 2025, making it read-only.

pip install importlab
INSTALL
IMPORT
SIG · IMPORTLAB
I
importlab
dataenv0.8.1
Install
2.5s avg
Import
Disk
32MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.8.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 32.1MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.5s · import 0.000s · 33MB
32MB installed
● package 32MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

build_graph
from importlab.graph import build_graph
This is the primary function for programmatic graph construction.

This quickstart demonstrates how to use `importlab.graph.build_graph` to create a dependency graph from a list of Python file paths. It creates two dummy modules, analyzes their imports, and prints the nodes and edges of the resulting graph. The graph object returned is a networkx.DiGraph.

import os from importlab.graph import build_graph # Create dummy Python files for demonstration with open('module_a.py', 'w') as f: f.write('import module_b\ndef func_a(): pass') with open('module_b.py', 'w') as f: f.write('def func_b(): pass') # Build the dependency graph # Assuming current directory is in PYTHONPATH for this example graph = build_graph(paths=['module_a.py', 'module_b.py']) print('Nodes (files):', graph.nodes()) print('Edges (dependencies):', graph.edges()) # Clean up dummy files os.remove('module_a.py') os.remove('module_b.py')
Debug
Known issues
breakingThe `importlab` GitHub repository was archived on May 6, 2025, and is now read-only. This indicates that the library is no longer actively maintained, and no further updates, bug fixes, or new features are expected.
fix
Users should be aware that the library is unmaintained. Consider forking the repository if active development is required, or seek alternative solutions for dependency graph analysis.
affects: 0.8.1 and future development
gotcha`importlab` might execute module initialization code when attempting to find dependencies, which could lead to unexpected side effects or security vulnerabilities if analyzing untrusted or malformed code.
fix
Exercise caution when using `importlab` on untrusted Python code. Review the code to be analyzed for potential side effects or ensure a sandboxed environment for analysis.
affects: All versions
breakingSupport for Python 2 was officially dropped in version 0.6.1. Using `importlab` with Python 2 will result in errors.
fix
Ensure your project uses Python 3.6 or newer (as per `requires_python` metadata) when using `importlab` versions 0.6.1 or later.
affects: < 0.6.1 (supported), >= 0.6.1 (unsupported)
gotchaWhile `importlab` infers dependencies, the resulting graph object is a `networkx.DiGraph`. Users needing to traverse, query, or manipulate this graph extensively will likely require familiarity with the `networkx` library's API.
fix
Familiarize yourself with the `networkx` library's documentation to effectively work with the graphs generated by `importlab`.
affects: All versions
Upgrade
Version history
0.8.1latest on PyPI · released Oct 6, 2023
Audit
Dependencies
networkxrequiredUsed internally to represent the dependency graph, which may be exposed to users.
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources

No resource links recorded.

importlab — pip install importlab · libregistry