Skip to main content

pkgdeps

Explore dependencies of a Python package by parsing its imports.

This might be useful for:

  • seeing how modules within a package depend on each other

  • seeing which built-in libraries are relied upon

  • analysis of 3rd-party dependencies

  • etc.

Examples

Explore dependencies of this project:

$ pkgdeps /path/to/pkgdeps
pkgdeps
  - argparse.ArgumentParser
  - ast
  - collections.defaultdict
  - functools.reduce
  - os
  - os.path
  - sys

Limitations

  • Only tested with Python 3 against Python 3 packages.

  • Doesn’t handle conditional imports; all conditional branches are inspected.

  • Outputs imported module members: from os.path import join creates a dependency on os.path.join, but we probably only want os.path for e.g. tsort output. However, internal dependencies are coarsened to the module level.

Installation

$ pip install pkgdeps

Usage

Various options are available to filter and format the output:

$ pkgdeps -h
usage: pkgdeps [-h] [-n <num>] [-m <num>] [-e <type> | -o <type>]
               [-f <format>]
               </path/to/package>

Explore dependencies of a package by parsing its imports.

positional arguments:
  </path/to/package>    path to package root

optional arguments:
  -h, --help            show this help message and exit
  -n <num>, --package-module-name-segments <num>
                        truncate module names of inspected package to given
                        number of segments (and consolidate imports)
  -m <num>, --dependency-module-name-segments <num>
                        truncate module names of dependencies to given number
                        of segments (and deduplicate)
  -e <type>, --exclude <type>
                        exclude various kinds of dependencies from output
                        (builtin, 3rd-party, internal)
  -o <type>, --only <type>
                        include only dependencies of the given type (builtin,
                        3rd-party, internal)
  -f <format>, --format <format>
                        graph output format (tree, tsort)

Metadata

Release files for pkgdeps 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for pkgdeps 0.0.3
File Interpreter ABI Platform
pkgdeps-0.0.3-py2.py3-none-any.whl Python 3, Python 2 none any Details

Release files / pkgdeps-0.0.3-py2.py3-none-any.whl

Download URL pkgdeps-0.0.3-py2.py3-none-any.whl
Size 7.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e34e733bb5a2c174ab395f3884ec314ad6906c399c1f6950e78b8ac1a4cae822
BLAKE2b-256 checksum
How to use checksums
bfceaae41edbf78d7de24d551bdf94a5bc6cbc925a887d01c3da220aeab6d3eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.3 This release

1 release file

0.0.2

1 release file

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page