dependenpy

Show the inter-dependencies between modules of Python packages.


Keywords
dependency, analysis, matrix, dsm, dependencies, python
License
ISC
Install
pip install dependenpy==3.3.2

Documentation

Dependenpy

ci documentation pypi version gitpod gitter

Show the inter-dependencies between modules of Python packages.

dependenpy allows you to build a dependency matrix for a set of Python packages. To do this, it reads and searches the source code for import statements.

demo

Installation

With pip:

pip install dependenpy

With pipx:

python3.7 -m pip install --user pipx
pipx install dependenpy

Usage (as a library)

from dependenpy import DSM

# create DSM
dsm = DSM('django')

# transform as matrix
matrix = dsm.as_matrix(depth=2)

# initialize with many packages
dsm = DSM('django', 'meerkat', 'appsettings', 'dependenpy', 'archan')
with open('output', 'w') as output:
    dsm.print(format='json', indent=2, output=output)

# access packages and modules
meerkat = dsm['meerkat']  # or dsm.get('meerkat')
finder = dsm['dependenpy.finder']  # or even dsm['dependenpy']['finder']

# instances of DSM and Package all have print, as_matrix, etc. methods
meerkat.print_matrix(depth=2)

This package was originally design to work in a Django project. The Django package django-meerkat uses it to display the matrices with Highcharts.

Usage (command-line)

usage: dependenpy [-d DEPTH] [-f {csv,json,text}] [-g] [-G] [-h]
                  [-i INDENT] [-l] [-m] [-o OUTPUT] [-t] [-v] 
                  [-z STRING] PACKAGES [PACKAGES ...]

Command line tool for dependenpy Python package.

positional arguments:
  PACKAGES              The package list. Can be a comma-separated list. Each
                        package must be either a valid path or a package in
                        PYTHONPATH.

optional arguments:
  -d DEPTH, --depth DEPTH
                        Specify matrix or graph depth. Default: best guess.
  -f {csv,json,text}, --format {csv,json,text}
                        Output format. Default: text.
  -g, --show-graph      Show the graph (no text format). Default: false.
  -G, --greedy          Explore subdirectories even if they do not contain an
                        __init__.py file. Can make execution slower. Default:
                        false.
  -h, --help            Show this help message and exit.
  -i INDENT, --indent INDENT
                        Specify output indentation. CSV will never be
                        indented. Text will always have new-lines. JSON can be
                        minified with a negative value. Default: best guess.
  -l, --show-dependencies-list
                        Show the dependencies list. Default: false.
  -m, --show-matrix     Show the matrix. Default: true unless -g, -l or -t.
  -o OUTPUT, --output OUTPUT
                        Output to given file. Default: stdout.
  -t, --show-treemap    Show the treemap (work in progress). Default: false.
  -v, --version         Show the current version of the program and exit.
  -z ZERO, --zero ZERO  Character to use for cells with value=0 (text matrix 
                        display only). Default: "0".

Example:

$ # running dependenpy on itself
$ dependenpy dependenpy -z=

                Module β”‚ Id β”‚0β”‚1β”‚2β”‚3β”‚4β”‚5β”‚6β”‚7β”‚8β”‚
 ──────────────────────┼────┼─┼─┼─┼─┼─┼─┼─┼─┼──
   dependenpy.__init__ β”‚  0 β”‚ β”‚ β”‚ β”‚4β”‚ β”‚ β”‚ β”‚ β”‚2β”‚
   dependenpy.__main__ β”‚  1 β”‚ β”‚ β”‚1β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
        dependenpy.cli β”‚  2 β”‚1β”‚ β”‚ β”‚1β”‚ β”‚4β”‚ β”‚ β”‚ β”‚
        dependenpy.dsm β”‚  3 β”‚ β”‚ β”‚ β”‚ β”‚2β”‚1β”‚3β”‚ β”‚ β”‚
     dependenpy.finder β”‚  4 β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
    dependenpy.helpers β”‚  5 β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
       dependenpy.node β”‚  6 β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚3β”‚
    dependenpy.plugins β”‚  7 β”‚ β”‚ β”‚ β”‚1β”‚ β”‚1β”‚ β”‚ β”‚ β”‚
 dependenpy.structures β”‚  8 β”‚ β”‚ β”‚ β”‚ β”‚ β”‚1β”‚ β”‚ β”‚ β”‚