Skip to main content

Display module dependencies

Project description

Documentation Status https://travis-ci.org/thebjorn/pydeps.svg https://coveralls.io/repos/thebjorn/pydeps/badge.png

Python module dependency visualization. This package installs the pydeps command, and normal usage will be to use it from the command line. To install:

pip install pydeps

To create graphs you need to install Graphviz (make sure the dot command is on your path).

This is the result of running pydeps on itself (pydeps --show pydeps):

https://dl.dropboxusercontent.com/u/94882440/pydeps.svg

pydeps also contains an Erdős-like scoring function (a.k.a. Bacon number, from Six degrees of Kevin Bacon (http://en.wikipedia.org/wiki/Six_Degrees_of_Kevin_Bacon) that lets you filter out modules that are more than a given number of ‘hops’ away from the module you’re interested in. This is useful for finding the interface a module has to the rest of the world.

To find pydeps’ interface to the Python stdlib (less some very common modules).

pydeps pydeps --show --max-bacon 2 --pylib -x os re types _* enum
https://dl.dropboxusercontent.com/u/94882440/pydeps-pylib.svg

--max-bacon 2 gives the modules that are at most 2 hops away, and modules that belong together have similar colors. Compare that to the output without the --max-bacon 2 filter:

https://dl.dropboxusercontent.com/u/94882440/pydeps-pylib-all.svg

pydeps can detect and display cycles with the --show-cycles parameter. This will _only_ display the cycles, and for big libraries it is not a particularly fast operation. Given a folder with the following contents (this uses yaml to define a directory structure, like in the tests):

relimp:
    - __init__.py
    - a.py: |
        from . import b
    - b.py: |
        from . import a

pydeps relimp --show-cycles displays:

.. image:: https://dl.dropboxusercontent.com/u/94882440/pydeps-cycle.svg

An attempt has been made to keep the intermediate formats readable, eg. the output from pydeps --show-deps .. looks like this:

...
"pydeps.mf27": {
    "imported_by": [
        "__main__",
        "pydeps.py2depgraph"
    ],
    "kind": "imp.PY_SOURCE",
    "name": "pydeps.mf27",
    "path": "pydeps\\mf27.py"
},
"pydeps.py2depgraph": {
    "imported_by": [
        "__main__",
        "pydeps.pydeps"
    ],
    "imports": [
        "pydeps.depgraph",
        "pydeps.mf27"
    ],
    "kind": "imp.PY_SOURCE",
    "name": "pydeps.py2depgraph",
    "path": "pydeps\\py2depgraph.py"
}, ...

Usage:

usage: pydeps-script.py [-h] [-v] [-o file] [-T FORMAT] [--show] [--show-deps]
                        [--show-dot] [--debug] [--pylib] [--pylib-all]
                        [-x EXCLUDE [EXCLUDE ...]]
                        fname

positional arguments:
  fname                 filename

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         be more verbose (-vv, -vvv for more verbosity)
  -o file               write output to 'file'
  -T FORMAT             output format (svg|png)
  --show                call external program to display graph
  --show-deps           show output of dependency analysis
  --show-dot            show output of dot conversion
  --debug               turn on all the show and verbose options
  --pylib               include python std lib modules
  --pylib-all           include python all std lib modules (incl. C modules)
  -x EXCLUDE [EXCLUDE ...], --exclude EXCLUDE [EXCLUDE ...]
                        input files to skip

You can of course import pydeps from Python (look in the tests/test_relative_imports.py file for examples.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

pydeps-1.1.0.zip (27.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pydeps-1.1.0.win32.exe (261.1 kB view details)

Uploaded Source

pydeps-1.1.0-py2-none-any.whl (25.7 kB view details)

Uploaded Python 2

File details

Details for the file pydeps-1.1.0.zip.

File metadata

  • Download URL: pydeps-1.1.0.zip
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pydeps-1.1.0.zip
Algorithm Hash digest
SHA256 fe6f37921d125bbf0e23397368570e1c1fceff45fcbdfe9438c2a095bab31efb
MD5 77883f8b7596b86ad0b77fcf0b7ff030
BLAKE2b-256 e9ac8207ee5327783adc792deae88b028084b30f141b65c4ff8af049797616fa

See more details on using hashes here.

File details

Details for the file pydeps-1.1.0.win32.exe.

File metadata

  • Download URL: pydeps-1.1.0.win32.exe
  • Upload date:
  • Size: 261.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pydeps-1.1.0.win32.exe
Algorithm Hash digest
SHA256 b34b4a8f411b278a8a943ad3edd99856b5860342ed4e07fef50330acbd8f2c32
MD5 2d713f217135f35a416a72d396903410
BLAKE2b-256 06eb190769ef1b78169f21880c38840c0e6ae8143de31568218b89b16c338190

See more details on using hashes here.

File details

Details for the file pydeps-1.1.0-py2-none-any.whl.

File metadata

File hashes

Hashes for pydeps-1.1.0-py2-none-any.whl
Algorithm Hash digest
SHA256 3a401389d3008e9845333fd468975c530fa0aaac8bdaf5e43cc066aad7e0cf9b
MD5 b2f720041ea16b99953d56c862c1571a
BLAKE2b-256 2974b0c6578f9f9215d882eb9df07cd68880b623ecc0aece73f2eef307c2bbad

See more details on using hashes here.

Supported by

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