Skip to main content

Get the dependency tree of your Python virtual environment via Pip.

Project description

Pip Tree

Get the dependency tree of your Python virtual environment via Pip.

Build Status Coverage Status PyPi Licence

Showcase

There is no simple, native way to get the dependency tree of a Python virtual environment using Pip as the package manager. Pip Tree fixes this problem by retrieving every package from your virtual environment and returning the packages it depends on as well as what depends on that package. These results will print to console.

Install

# Install Pip Tree
pip3 install pip-tree

# Install locally
make install

# Get Makefile help
make help

Usage

Invoke Pip Tree as a script and pass an optional pip path as an environment variable (great for per-project virtual environments). If no optional pip path is passed, then Pip Tree will attempt to use the system pip3 installation.

PIPPIN_PIP="~/my_project/venv/bin/pip" pip-tree

You can also import Pip Tree as a package and build custom logic for your needs. Pip Tree will return an array of json objects, each containing the name, version, packages required by the package, and what packages requires that package.

from pip_tree import PipTree

dependency_tree = PipTree.generate_dependency_tree(
    pip='~/my_project/venv/bin/pip'
)

print(dependency_tree)

Sample Output

Generating Pip Tree Report for "~/my_project/venv/bin/pip"...

[
    {
        "name": "aiohttp",
        "version": "3.6.2",
        "requires": "async-timeout, multidict, attrs, yarl, chardet",
        "required-by": "slackclient"
    },
    {
        "name": "astroid",
        "version": "2.4.2",
        "requires": "six, wrapt, lazy-object-proxy",
        "required-by": ""
    },
    {
        "name": "async-timeout",
        "version": "3.0.1",
        "requires": "",
        "required-by": "aiohttp"
    },
    {
        "name": "attrs",
        "version": "19.3.0",
        "requires": "",
        "required-by": "aiohttp"
    },
    ...
]

Pip Tree report complete! 40 dependencies found for "~/my_project/venv/bin/pip".

Development

# Lint the project
make lint

# Run tests
make test

# Run test coverage
make coverage

Attribution

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

pip-tree-0.3.0.tar.gz (3.9 kB view hashes)

Uploaded Source

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