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
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
.venvorvenvdirectories - 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
# or
uv tool install direct-deps
Usage
direct-deps exposes three subcommands — check, extract-imports, and find-package.
The recommended way to run any of them is without installation via uvx or pipx run.
Every command accepts one or more files or directories (directories are scanned
recursively).
check (primary)
The main command: it lists your project's direct dependencies. Run it directly without installation — the tool will automatically detect your project's virtual environment:
# Using uvx (uv's tool runner)
uvx direct-deps check .
# Using pipx
pipx run direct-deps check .
# Or analyze specific directories
uvx direct-deps check src
uvx direct-deps check tests
To split packages and dev-packages you can do the following.
# Sample Project Structure
├── pyproject.toml
├── src
│ └── comma-cli
│ └── ...
└── tests
└── ...
$ uvx direct-deps check src
persistent-cache-decorator
requests
rich
setuptools-scm
typedfzf
typer
$ uvx direct-deps check tests
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",
]
extract-imports
Lists every unique top-level import found in the given files or directories. This is the
raw input that check resolves against your environment, so it's useful for debugging what
the tool actually detected. Standard-library modules are excluded by default (pass
--include-builtin to include them, and --include-jupyter to scan notebooks).
$ uvx direct-deps extract-imports src
persistent_cache_decorator
requests
rich
typedfzf
typer
find-package
Resolves one or more import/module names to the distribution (package) names that provide
them, using your environment's metadata. Handy when an import name differs from its PyPI
package name (e.g. yaml is provided by PyYAML).
$ uvx direct-deps find-package yaml requests
PyYAML
requests
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file direct_deps-0.0.5.tar.gz.
File metadata
- Download URL: direct_deps-0.0.5.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abe87c285c6d107c07b077050cd4b3a992b0e5a4d8fc82761790c08c9f18fff1
|
|
| MD5 |
d1ef58396f56791e8299ffd78fe201b7
|
|
| BLAKE2b-256 |
4c1bac4cd31dc84d2cd7413656960b0a992646b565f4b0e18972d2b34df455f3
|
Provenance
The following attestation bundles were made for direct_deps-0.0.5.tar.gz:
Publisher:
main.yaml on FlavioAmurrioCS/direct-deps
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
direct_deps-0.0.5.tar.gz -
Subject digest:
abe87c285c6d107c07b077050cd4b3a992b0e5a4d8fc82761790c08c9f18fff1 - Sigstore transparency entry: 1632106683
- Sigstore integration time:
-
Permalink:
FlavioAmurrioCS/direct-deps@5842487a55966b4aedefc2d5c05ad75ad46eaea4 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/FlavioAmurrioCS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yaml@5842487a55966b4aedefc2d5c05ad75ad46eaea4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file direct_deps-0.0.5-py3-none-any.whl.
File metadata
- Download URL: direct_deps-0.0.5-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3bd2b509775877e68c9b0e52a38c0684b1934ea0727178559366da6e49efac7
|
|
| MD5 |
8b32510be597068ad4aeb16a22da17ac
|
|
| BLAKE2b-256 |
46ea3bb155fc64a4158f754b1dc188f8031524a6c886ddcfee633726ec57ad2a
|
Provenance
The following attestation bundles were made for direct_deps-0.0.5-py3-none-any.whl:
Publisher:
main.yaml on FlavioAmurrioCS/direct-deps
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
direct_deps-0.0.5-py3-none-any.whl -
Subject digest:
b3bd2b509775877e68c9b0e52a38c0684b1934ea0727178559366da6e49efac7 - Sigstore transparency entry: 1632106695
- Sigstore integration time:
-
Permalink:
FlavioAmurrioCS/direct-deps@5842487a55966b4aedefc2d5c05ad75ad46eaea4 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/FlavioAmurrioCS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yaml@5842487a55966b4aedefc2d5c05ad75ad46eaea4 -
Trigger Event:
push
-
Statement type: