Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/takluyver/importtracer
Track Python imports
https://github.com/takluyver/importtracer
Last synced: 4 days ago
JSON representation
Track Python imports
- Host: GitHub
- URL: https://github.com/takluyver/importtracer
- Owner: takluyver
- Created: 2014-06-24T23:40:08.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-16T18:36:12.000Z (about 10 years ago)
- Last Synced: 2024-11-05T10:58:20.254Z (about 2 months ago)
- Language: Python
- Size: 152 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
Trace Python imports
Command line usage::
python3 importtracer.py [--csv file.csv] [--networkx] [-x pkg [-x ...]] module
This will import ``module``, tracking everything that gets imported. Passing
``--csv`` will dump the results as a CSV file. ``--networkx`` will draw the
graph of imports using `NetworkX `_. ``-x`` options
will exclude packages from the reporting by prefix (the data is still collected,
but not displayed).Python usage:
.. code:: python
import importtracer
with importtracer.track(excludes=['numpy']) as it:
import matplotlib
# The imports made, as (modulename, importedby, time), filtering exclusions
it.filtered_links# Save these as CSV:
it.dump_csv('file.csv')# Make a NetworkX graph
g = it.dump_nx_graph()
# Draw the graph
networkx.draw(g); plt.show()