Skip to main content

Show the inter-dependencies between modules of Python packages.

Project description

Dependenpy

ci documentation pypi version

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

Requirements

Dependenpy requires Python 3.6 or above.

To install Python 3.6, I recommend using pyenv.
# install pyenv
git clone https://github.com/pyenv/pyenv ~/.pyenv

# setup pyenv (you should also put these three lines in .bashrc or similar)
export PATH="${HOME}/.pyenv/bin:${PATH}"
export PYENV_ROOT="${HOME}/.pyenv"
eval "$(pyenv init -)"

# install Python 3.6
pyenv install 3.6.8

# make it available globally
pyenv global system 3.6.8

Installation

With pip:

python3.6 -m pip install dependenpy

With pipx:

python3.6 -m pip install --user pipx

pipx install --python python3.6 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: gen-readme-data.py [-d DEPTH] [-f {csv,json,text}] [-g] [-G] [-h]
                          [-i INDENT] [-l] [-m] [-o OUTPUT] [-t] [-v]
                          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.

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│ │ │ │

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dependenpy-3.3.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

dependenpy-3.3.0-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file dependenpy-3.3.0.tar.gz.

File metadata

  • Download URL: dependenpy-3.3.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.0b2 CPython/3.8.5 Linux/5.8.5-arch1-1

File hashes

Hashes for dependenpy-3.3.0.tar.gz
Algorithm Hash digest
SHA256 a62022cfa1dddc9f514027ca55b4d28dde5c6ef071b34226391a8cbe9c87f98b
MD5 2ad5938f49f2be710a1def7d3d57bffe
BLAKE2b-256 8a8bb60402cf3aac5d27b436819b992aedc7426bcd2cc070a6a29f36d57faec0

See more details on using hashes here.

File details

Details for the file dependenpy-3.3.0-py3-none-any.whl.

File metadata

  • Download URL: dependenpy-3.3.0-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.0b2 CPython/3.8.5 Linux/5.8.5-arch1-1

File hashes

Hashes for dependenpy-3.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2b65b36c4e64f4b8aa8f951a3fa0df9bbfcb7330b4b3fdff55a3036c450caf4
MD5 9d1a816fe04105e415e197f52a61405b
BLAKE2b-256 90c459746e87c8923d75f2d06b4b568415d644292a6480eff0382423330adf6b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page