seddonym / grimp

Builds a graph of a Python project's internal dependencies.
https://grimp.readthedocs.io
BSD 2-Clause "Simplified" License
51 stars 10 forks source link

Build graph exclude stdlib #143

Open sbrugman opened 4 months ago

sbrugman commented 4 months ago

For the analysis of how heavily a package relies on external dependencies, we can use the include_external_packages argument in the build_graph. This analysis can be used to determine which modules are affected when a dependency is removed/replaced or made optional.

Standard library imports are not relevant for this analysis, as we cannot remove them anyway.

I would like to be able to exclude them, preferably when building the graph. Alternatively, they can be filtered out later. For this use case, I would suggest exposing the build graph arguments through impulse so that users can perform this analysis quickly from the command line.

seddonym commented 4 months ago

So to summarize, we could have an API something like this:

graph = grimp.build_graph('mypackage', include_external_packages=True, exclude_stdlib=True)

And for completeness, possibly this would raise an exception:

graph = grimp.build_graph('mypackage', include_external_packages=False, exclude_stdlib=True)

I think I could get behind this proposal providing it doesn't introduce too much complexity, since as you say we could, alternatively, move this up a level and filter things out by libraries that use Grimp. Feel free to submit something if you'd find it helpful.