Skip to main content

A utility to analyze a Python project and its virtual environment to identify unused direct dependencies. Helps you keep your dependency list lean and accurate.

Project description

direct-deps

PyPI - Version PyPI - Python Version


Table of Contents

Introduction

A utility to analyze a Python project and its virtual environment to identify direct dependencies. Helps you keep your dependency list lean and accurate.

Installation

pip install direct-deps

Usage

Inside your project's virtualenv

source venv/bin/activate
pip install direct-deps
#  No need to specify venv since direct-deps can detect the virtualenv if installed in it.
direct-deps .

Installed outside your virtualenv

pipx install direct-deps

# You must pass in the location of your virtualenv
# hatch: hatch env find
# pipenv: pipenv --venv
direct-deps . --venv venv

Recommendation

To split packages and dev-packages you can do the following.

# Sample Project Structure
├── pyproject.toml
├── src
│   └── comma-cli
│       └── ...
└── tests
    └── ...
[flavio@Mac ~/dev/github.com/FlavioAmurrioCS/comma-cli]
$ hatch shell
source "/Users/flavio/Library/Application Support/hatch/env/virtual/comma-cli/NLCv5VCj/comma-cli/bin/activate"

(comma-cli)
[flavio@Mac ~/dev/github.com/FlavioAmurrioCS/comma-cli]
$ pip install direct-deps
...

(comma-cli)
[flavio@Mac ~/dev/github.com/FlavioAmurrioCS/comma-cli]
$ direct-deps src
Direct Dependencies:
 - persistent-cache-decorator
 - requests
 - rich
 - setuptools-scm
 - typedfzf
 - typer

(comma-cli)
[flavio@Mac ~/dev/github.com/FlavioAmurrioCS/comma-cli]
$ direct-deps tests
Direct Dependencies:
 - pytest
 - runtool
 - tomlkit
 - typer

# So my [packages] would be
  persistent-cache-decorator
  requests
  rich
  setuptools-scm
  typedfzf
  typer

# And my [dev-packages] would be, notice that since typer is a main dependency, there is no need to list it in this section.
  pytest
  runtool
  tomlkit

Limitations

This tool relies on being able to look at the import <package> and from <package> import ... as well as use your virtualenv to find the appropiate package name. This means that that anything not imported directly will not appear the the list such as plugins (pytest-cov) and static analysis tools(ruff, pre-commit).

License

direct-deps is distributed under the terms of the MIT license.

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

direct_deps-0.0.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

direct_deps-0.0.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file direct_deps-0.0.1.tar.gz.

File metadata

  • Download URL: direct_deps-0.0.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for direct_deps-0.0.1.tar.gz
Algorithm Hash digest
SHA256 daae13c47adcdcd6a96deefb7153da13fff851adec7c60b272ee537509361021
MD5 4b0a2cbae9c254f76882e7cbf287140c
BLAKE2b-256 c7ef1725dc51a800661b7c712a6049da9aae9ec27ca414a76313c4da8b6b2e7b

See more details on using hashes here.

File details

Details for the file direct_deps-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: direct_deps-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for direct_deps-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ba89014394ead64e7bd2d942f6a95421d3d064e42b3083b532e33bc9e852372f
MD5 1f2998e012b201955c9a37caf1dd8316
BLAKE2b-256 427c5a9aed9ffd9d59c7eb439b6d4c43a80d859abf756679d37dafe9da689288

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