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.3.tar.gz (11.7 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.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for direct_deps-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0757a8bb09fc2ee8b90a55a23135f3643a19a58b9d74f9774dce9bc154c7edd7
MD5 14d5fe2a74bf40d4ddf492e4f1e13a71
BLAKE2b-256 87661003fc0cda08f58236e9301da42ea07e68ce22c415afe47ba7eb3c1bc2d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for direct_deps-0.0.3.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.3-py3-none-any.whl.

File metadata

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

File hashes

Hashes for direct_deps-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 af74751f822b8951e85496f4ce16c54b4a65f54b9dd89c625bbb00119f7e4f21
MD5 809bac46a273e80dbb0c57b6c9689b3c
BLAKE2b-256 c0dee6c19136e92f9ff117dbafc625be5de0e47be37018f43fd0c632656fd140

See more details on using hashes here.

Provenance

The following attestation bundles were made for direct_deps-0.0.3-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