https://github.com/justintime50/pip-tree
Get the dependency tree of your Python virtual environment via Pip.
https://github.com/justintime50/pip-tree
dependency dependency-tree environment package pip project python tree venv virtual virtual-environments
Last synced: about 1 month ago
JSON representation
Get the dependency tree of your Python virtual environment via Pip.
- Host: GitHub
- URL: https://github.com/justintime50/pip-tree
- Owner: Justintime50
- License: mit
- Created: 2020-11-11T06:08:20.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-15T17:24:04.000Z (7 months ago)
- Last Synced: 2024-10-25T06:48:36.602Z (7 months ago)
- Topics: dependency, dependency-tree, environment, package, pip, project, python, tree, venv, virtual, virtual-environments
- Language: Python
- Homepage:
- Size: 86.9 KB
- Stars: 20
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Pip Tree
Get the dependency tree of your Python virtual environment via Pip.
[](https://github.com/Justintime50/pip-tree/actions)
[](https://coveralls.io/github/Justintime50/pip-tree?branch=main)
[](https://pypi.org/project/pip-tree/)
[](LICENSE)
There is no simple, native way to get the dependency tree of a Python virtual environment using the Pip package manager for Python. Pip Tree fixes this problem by retrieving every package from your virtual environment and returning a list of JSON objects that include the package name, version installed, date updated, and which packages are required by each package (the tree).
## Install
```bash
# Install Pip Tree globally
pip3 install pip-tree# Install Pip Tree into the virtual environment of the project you want to run it on
venv/bin/pip install pip-tree# Install locally
just install
```## Usage
```text
Virtual Env Usage:
pip-treeGlobal Usage:
pip-tree --path "path/to/my_project/venv/lib/python3.9/site-packages"Options:
-h, --help show this help message and exit
-p PATH, --path PATH The path to the site-packages directory of a Python virtual environment. If a path is not provided, the virtual environment Pip Tree is run from will be used.
```### Sample Output
```text
Generating Pip Tree Report...[
{
"name": "docopt",
"version": "0.6.2",
"updated": "2021-05-12",
"requires": [],
"required_by": [
"coveralls"
]
},
{
"name": "flake8",
"version": "3.9.2",
"updated": "2021-05-12",
"requires": [
"mccabe<0.7.0,>=0.6.0",
"pyflakes<2.4.0,>=2.3.0",
"pycodestyle<2.8.0,>=2.7.0"
],
"required_by": []
},
{
"name": "Flask",
"version": "2.0.0",
"updated": "2021-05-12",
"requires": [
"click>=7.1.2",
"itsdangerous>=2.0",
"Jinja2>=3.0"
"Werkzeug>=2.0",
],
"required_by": []
}
]Pip Tree report complete! 40 dependencies found for "path/to/my_project/venv/lib/python3.12/site-packages".
```### Package
In addition to the CLI tool, you can use functions to retrieve the list of packages and their details from a Python virtual environment in your own code:
```python
import pip_treepath = 'path/to/my_project/venv/lib/python3.12/site-packages'
package_list = pip_tree.get_pip_package_list(path)
for package in package_list:
package_details = pip_tree.get_package_details(package)
print(package_details['name'])
```## Development
```bash
# Get a comprehensive list of development tools
just --list
```