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 pre-commit.ci status


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.

The tool automatically detects common virtual environment setups including:

  • Current activated virtual environment ($VIRTUAL_ENV)
  • Local .venv or venv directories
  • Hatch environments
  • Pipenv environments

Installation

Installation is optional! You can run direct-deps without installing it using uvx or pipx run.

# Optional: Install globally
pipx install direct-deps

Usage

Run without installation (Recommended)

The easiest way to use direct-deps is to run it directly without installation. The tool will automatically detect your project's virtual environment:

# Using uvx (uv's tool runner)
uvx direct-deps .

# Using pipx
pipx run direct-deps .

# Or analyze specific directories
uvx direct-deps src
uvx direct-deps tests

Recommendation

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

# Sample Project Structure
├── pyproject.toml
├── src
│   └── comma-cli
│       └── ...
└── tests
    └── ...
$ uvx direct-deps src
Direct Dependencies:
 - persistent-cache-decorator
 - requests
 - rich
 - setuptools-scm
 - typedfzf
 - typer

$ uvx direct-deps tests
Direct Dependencies:
 - pytest
 - runtool
 - tomlkit
 - typer

# So my [project.dependencies] would be:
[project]
dependencies = [
  "persistent-cache-decorator",
  "requests",
  "rich",
  "setuptools-scm",
  "typedfzf",
  "typer",
]

# And my [project.optional-dependencies.dev] would be (notice that since typer is a main dependency, there is no need to list it here):
[project.optional-dependencies]
dev = [
  "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 appropriate package name. This means that anything not imported directly will not appear in 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.4.tar.gz (13.5 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.4-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: direct_deps-0.0.4.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for direct_deps-0.0.4.tar.gz
Algorithm Hash digest
SHA256 70f19724adc41ed015e50e16c20a20d64b239192f535227d0ef3a0e855bc6e27
MD5 9f9cce5d02f3dd22b6d765c89a157226
BLAKE2b-256 f68d74ba24d045eac027afc3ea2369aa34d36bf7aed297883f20fa791f980d57

See more details on using hashes here.

Provenance

The following attestation bundles were made for direct_deps-0.0.4.tar.gz:

Publisher: main.yaml on FlavioAmurrioCS/direct-deps

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: direct_deps-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for direct_deps-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 07b2075a18bd2f987d4ee911d6877670c65f8468e5606d95480936c0b4c51198
MD5 db936b4fe7fc0a7ff0ece31a14d5f801
BLAKE2b-256 e0f01cba9fede3e000f921935e570a76f46594b67fc2353bbc2f4c3eb5adec1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for direct_deps-0.0.4-py3-none-any.whl:

Publisher: main.yaml on FlavioAmurrioCS/direct-deps

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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