Understanding your project’s dependency graph is important for a number of reasons:
With Tach, you can easily visualize the set of dependencies that exist within your Python project. Here’s how:
> pip install tach
The first step is pretty straightforward - install Tach
and make sure you’re on the latest version.
> tach mod
Next, we need to define the modules within your project that we want to visualize dependencies between. The tach mod
command opens up an editor in which you can mark modules and your Python source root. Here are the commands you need:
We’ll use the FastAPI repo as an example. Here’s what this looks like for FastAPI before saving:
In order to correctly visualize your existing dependencies, Tach will crawl the Python AST to figure out which modules import from each other. This can be achieved by running:
> tach sync
Here’s a slice of what Tach found for the above configuration:
The final step is the simplest. Simply run tach show --web
, and click on the generated URL to view your dependency graph! You can also view a local version of the graph through GraphViz using the base command tach show
.
By following the above 4 steps, you can easily visualize your project’s set of Python dependencies, and inform future architecture decisions.
Tach also enables you to enforce boundaries between modules, as well as define strict interfaces for a given module. If there’s a feature you’d like to see in Tach, feel free to drop an issue or join the discussion on Discord!