Tools to manage (uv) environemnts programmatically.
Project description
DepKit
DependencyManager
A flexible Python dependency manager that handles runtime dependencies and script imports.
Quick Start
from depkit import DependencyManager
# Simple usage
manager = DependencyManager(requirements=["requests>=2.31.0"])
manager.install()
import requests
# ... do your work ...
manager.uninstall() # optional cleanup
Recommended Usage (Context Managers)
# Synchronous
with DependencyManager(requirements=["requests"]) as manager:
import requests
# ... do your work ...
# cleanup happens automatically
# Asynchronous
async with DependencyManager(requirements=["requests"]) as manager:
import requests
# ... do your work ...
# cleanup happens automatically
Features
- Simple install/uninstall methods for quick usage
- Context managers for proper resource management
- PEP 723 dependency declaration support
- Support for both pip and uv package managers
- Custom pip index URL support
- Temporary script importing
- Path management for imports
Installation
pip install depkit
Basic Usage
The DependencyManager supports both synchronous and asynchronous context managers:
Async Usage
from depkit import DependencyManager
async with DependencyManager(
requirements=["requests>=2.31.0", "pandas"],
prefer_uv=True
) as manager:
import requests
import pandas
Sync Usage
from depkit import DependencyManager
with DependencyManager(
requirements=["requests>=2.31.0", "pandas"],
prefer_uv=True
) as manager:
import requests
import pandas
Working with Scripts
The DependencyManager can handle scripts with PEP 723 dependency declarations:
# example_script.py
# /// script
# dependencies = [
# "requests>=2.31.0",
# "pandas>=2.0.0"
# ]
# requires-python = ">=3.12"
# ///
import requests
import pandas as pd
Load and use the script:
async with DependencyManager(
scripts=["path/to/example_script.py"],
extra_paths=["."] # Add paths to Python's import path
) as manager:
# Script's dependencies are installed automatically
from example_script import some_function
Configuration Options
DependencyManager(
prefer_uv: bool = False, # Prefer uv over pip if available
requirements: list[str] = None, # List of PEP 508 requirement specifiers
extra_paths: list[str] = None, # Additional Python import paths
scripts: list[str] = None, # Scripts to load and process
pip_index_url: str = None, # Custom PyPI index URL
)
Features in Detail
UV Integration
The manager automatically detects and can use uv for faster package installation:
manager = DependencyManager(prefer_uv=True)
Custom Package Index
Specify a custom PyPI index:
manager = DependencyManager(
requirements=["private-package>=1.0.0"],
pip_index_url="https://private.pypi.org/simple"
)
Path Management
Add custom import paths:
manager = DependencyManager(
extra_paths=[
"./src",
"./lib",
]
)
Error Handling
from depkit import DependencyError
try:
async with DependencyManager(requirements=["nonexistent-package"]):
pass
except DependencyError as e:
print(f"Dependency management failed: {e}")
Best Practices
- Use as a context manager to ensure proper cleanup
- Specify exact version requirements when possible
- Use PEP 723 for script dependencies
- Handle DependencyError exceptions appropriately
- Consider using uv in production for better performance
Limitations
- Requires Python 3.12 or higher
- Some features may not work on all platforms
- UV support requires uv to be installed separately
Project details
Release history Release notifications | RSS feed
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 depkit-0.5.1.tar.gz.
File metadata
- Download URL: depkit-0.5.1.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc3017c4dc466cd335f4842e9c9276f12687d43d9ee0a8e43fcea4dc0019b9ab
|
|
| MD5 |
1ee9bda64cda66124ab979522f56b6b0
|
|
| BLAKE2b-256 |
4cbae676de024bac34b120ef233b7ac18fdd0df15ff0088ea2d3b8e1ea1b482f
|
Provenance
The following attestation bundles were made for depkit-0.5.1.tar.gz:
Publisher:
build.yml on phil65/depkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
depkit-0.5.1.tar.gz -
Subject digest:
fc3017c4dc466cd335f4842e9c9276f12687d43d9ee0a8e43fcea4dc0019b9ab - Sigstore transparency entry: 590240441
- Sigstore integration time:
-
Permalink:
phil65/depkit@a568afa0e884229a8ed61ca9904e99b17ef637fa -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/phil65
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@a568afa0e884229a8ed61ca9904e99b17ef637fa -
Trigger Event:
push
-
Statement type:
File details
Details for the file depkit-0.5.1-py3-none-any.whl.
File metadata
- Download URL: depkit-0.5.1-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02ba5ad42349e223ab61bf4ecff239effa785a2adfa9c44e06623a18168b060b
|
|
| MD5 |
88e45fba51f7daca78d86e5894636177
|
|
| BLAKE2b-256 |
677542638eab0382d6456e6c6a4fbd41e6a63f4c6c4387bdaec1f1e46dc57290
|
Provenance
The following attestation bundles were made for depkit-0.5.1-py3-none-any.whl:
Publisher:
build.yml on phil65/depkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
depkit-0.5.1-py3-none-any.whl -
Subject digest:
02ba5ad42349e223ab61bf4ecff239effa785a2adfa9c44e06623a18168b060b - Sigstore transparency entry: 590240493
- Sigstore integration time:
-
Permalink:
phil65/depkit@a568afa0e884229a8ed61ca9904e99b17ef637fa -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/phil65
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@a568afa0e884229a8ed61ca9904e99b17ef637fa -
Trigger Event:
push
-
Statement type: