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.
Metadata
Release files for direct-deps 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| direct_deps-0.0.5.tar.gz | 18.2 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| direct_deps-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.7 kB
Release files / direct_deps-0.0.5.tar.gz
| Download URL | direct_deps-0.0.5.tar.gz |
|---|---|
| Size | 18.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
abe87c285c6d107c07b077050cd4b3a992b0e5a4d8fc82761790c08c9f18fff1
|
|
BLAKE2b-256 checksum How to use checksums |
4c1bac4cd31dc84d2cd7413656960b0a992646b565f4b0e18972d2b34df455f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 26, 2026.
Transparency logRelease files / direct_deps-0.0.5-py3-none-any.whl
| Download URL | direct_deps-0.0.5-py3-none-any.whl |
|---|---|
| Size | 13.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b3bd2b509775877e68c9b0e52a38c0684b1934ea0727178559366da6e49efac7
|
|
BLAKE2b-256 checksum How to use checksums |
46ea3bb155fc64a4158f754b1dc188f8031524a6c886ddcfee633726ec57ad2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 26, 2026.
Transparency logSecurity for direct-deps 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for direct_deps-0.0.5.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.