🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

direct-deps

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

direct-deps

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.

0.0.1
Source
PyPI
Maintainers
1

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

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.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts