{"id":10438,"library":"importlab","title":"Python Dependency Graph Calculator","description":"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.","status":"abandoned","version":"0.8.1","language":"en","source_language":"en","source_url":"https://github.com/google/importlab","tags":["dependency-graph","static-analysis","python-imports","code-analysis"],"install":[{"cmd":"pip install importlab","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Used internally to represent the dependency graph, which may be exposed to users.","package":"networkx","optional":false}],"imports":[{"note":"This is the primary function for programmatic graph construction.","symbol":"build_graph","correct":"from importlab.graph import build_graph"}],"quickstart":{"code":"import os\nfrom importlab.graph import build_graph\n\n# Create dummy Python files for demonstration\nwith open('module_a.py', 'w') as f:\n    f.write('import module_b\\ndef func_a(): pass')\nwith open('module_b.py', 'w') as f:\n    f.write('def func_b(): pass')\n\n# Build the dependency graph\n# Assuming current directory is in PYTHONPATH for this example\ngraph = build_graph(paths=['module_a.py', 'module_b.py'])\n\nprint('Nodes (files):', graph.nodes())\nprint('Edges (dependencies):', graph.edges())\n\n# Clean up dummy files\nos.remove('module_a.py')\nos.remove('module_b.py')","lang":"python","description":"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."},"warnings":[{"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.","message":"The `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.","severity":"breaking","affected_versions":"0.8.1 and future development"},{"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.","message":"`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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your project uses Python 3.6 or newer (as per `requires_python` metadata) when using `importlab` versions 0.6.1 or later.","message":"Support for Python 2 was officially dropped in version 0.6.1. Using `importlab` with Python 2 will result in errors.","severity":"breaking","affected_versions":"< 0.6.1 (supported), >= 0.6.1 (unsupported)"},{"fix":"Familiarize yourself with the `networkx` library's documentation to effectively work with the graphs generated by `importlab`.","message":"While `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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[],"ecosystem":"pypi"}