Skip to main content

DepKit

PyPI License Package status Monthly downloads Distribution format Wheel availability Python version Implementation Releases Github Contributors Github Discussions Github Forks Github Issues Github Issues Github Watchers Github Stars Github Repository size Github last commit Github release date Github language count Github commits this month Package status PyUp

Install Python packages at runtime, programmatically.

DepKit's DependencyManager makes sure a set of requirements is available in the current virtual environment before your code imports them. Requirements can be listed explicitly, read from PEP 723 inline script metadata, or collected from the .py files in extra import paths. Packages are installed with pip or uv pip.

Documentation: https://phil65.github.io/depkit/

Installation

pip install depkit
# or
uv add depkit

Quick start

from depkit import DependencyManager

with DependencyManager(requirements=["requests>=2.31.0"]) as manager:
    import requests

    print(manager.get_installed_requirements())

Requirements that are already installed are skipped; missing ones are installed on entry. The async variant works the same way:

async with DependencyManager(requirements=["requests"], prefer_uv=True) as manager:
    import requests

Without a context manager, call install() and (optionally) uninstall() yourself:

manager = DependencyManager(requirements=["requests"])
manager.install()
import requests

manager.uninstall()  # removes temporary files

Features

  • Sync and async context managers, or plain install() / uninstall()
  • PEP 723 inline script metadata: dependencies and requires-python checks
  • Scripts listed in scripts become importable modules (by file stem)
  • extra_paths are added to sys.path and scanned for PEP 723 dependencies
  • Uses uv pip when uv is available (on PATH or in a uv environment), otherwise python -m pip
  • Custom package index via pip_index_url
  • Refuses to install outside a virtual environment unless force_install=True

Working with scripts

Given a script with PEP 723 metadata:

# example_script.py
# /// script
# dependencies = [
#   "requests>=2.31.0",
# ]
# requires-python = ">=3.13"
# ///

import requests


def fetch(url: str) -> int:
    return requests.get(url).status_code

DepKit installs its dependencies and makes it importable:

with DependencyManager(scripts=["path/to/example_script.py"]) as manager:
    from example_script import fetch

You can also install a single requirement or a script's dependencies directly:

manager = DependencyManager()
manager.install_dependency("rich>=13")
manager.install_script("path/to/example_script.py")

Configuration

DependencyManager(
    requirements=None,  # list of PEP 508 requirement strings
    prefer_uv=False,  # prefer `uv pip` (warns if uv is not found)
    extra_paths=None,  # directories added to sys.path and scanned for PEP 723 deps
    scripts=None,  # PEP 723 scripts to load as importable modules
    pip_index_url=None,  # custom package index URL
    force_install=False,  # allow installing outside a virtual environment
)

Error handling

All errors derive from DependencyError (ScriptError for invalid script metadata):

from depkit import DependencyError, DependencyManager

try:
    with DependencyManager(requirements=["nonexistent-package-xyz"]):
        pass
except DependencyError as e:
    print(f"Dependency management failed: {e}")

Limitations

  • Requires Python 3.13 or newer.
  • Already-installed packages are detected by name only; version specifiers of installed packages are not re-checked.
  • Changes to sys.path made via extra_paths are not undone on cleanup.
  • uv support requires uv to be installed separately.

Metadata

Release files for depkit 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for depkit 1.0.4
File Size Uploaded Provenance Actions
depkit-1.0.4.tar.gz 14.7 kB With provenance Details for depkit-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for depkit 1.0.4
File Interpreter ABI Platform Actions
depkit-1.0.4-py3-none-any.whl Python 3 none any Details for depkit-1.0.4-py3-none-any.whl

Total release size: 28.4 kB

Release files / depkit-1.0.4.tar.gz

Download URL depkit-1.0.4.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ffc9cb66e87fdfacca0c6d02bf44c434ff58525035da1a75d28e115db892c872
BLAKE2b-256 checksum
How to use checksums
06c967a4be67317053322650c72aa17a6517c19bda93cd05aae48087e203b1bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 22, 2026.

Transparency log

Release files / depkit-1.0.4-py3-none-any.whl

Download URL depkit-1.0.4-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4045ddc404e86fa649add679c9d503808575e184c5f9965bc130751e607b4884
BLAKE2b-256 checksum
How to use checksums
b98dd595d210c56b45abe9d96e0041b2a7e8998c60873a132d7aba1c7d801aae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 22, 2026.

Transparency log

Security for depkit 1.0.4

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for depkit-1.0.4.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 Nov 22, 2026.

Transparency log

A 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page