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 details)

Uploaded Source

File details

Details for the file pip-tree-0.3.0.tar.gz.

File metadata

  • Download URL: pip-tree-0.3.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.7.1

File hashes

Hashes for pip-tree-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0506c152779a778ccf624b8365589b12a766baa714b463971a308dcc0df4ee2e
MD5 11018b46932947f96889ef820c91c456
BLAKE2b-256 c2dd7e59e8108c9b7c1d8e2f3fcde3bdacbeef5c7bf42feede0d88ae26dddc47

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