depkit


Namedepkit JSON
Version 0.5.0 PyPI version JSON
download
home_pageNone
SummaryTools to manage (uv) environemnts programmatically.
upload_time2025-10-06 20:34:41
maintainerNone
docs_urlNone
authorPhilipp Temminghoff
requires_python>=3.12
licenseMIT License Copyright (c) 2024, Philipp Temminghoff Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # DepKit

[![PyPI License](https://img.shields.io/pypi/l/depkit.svg)](https://pypi.org/project/depkit/)
[![Package status](https://img.shields.io/pypi/status/depkit.svg)](https://pypi.org/project/depkit/)
[![Monthly downloads](https://img.shields.io/pypi/dm/depkit.svg)](https://pypi.org/project/depkit/)
[![Distribution format](https://img.shields.io/pypi/format/depkit.svg)](https://pypi.org/project/depkit/)
[![Wheel availability](https://img.shields.io/pypi/wheel/depkit.svg)](https://pypi.org/project/depkit/)
[![Python version](https://img.shields.io/pypi/pyversions/depkit.svg)](https://pypi.org/project/depkit/)
[![Implementation](https://img.shields.io/pypi/implementation/depkit.svg)](https://pypi.org/project/depkit/)
[![Releases](https://img.shields.io/github/downloads/phil65/depkit/total.svg)](https://github.com/phil65/depkit/releases)
[![Github Contributors](https://img.shields.io/github/contributors/phil65/depkit)](https://github.com/phil65/depkit/graphs/contributors)
[![Github Discussions](https://img.shields.io/github/discussions/phil65/depkit)](https://github.com/phil65/depkit/discussions)
[![Github Forks](https://img.shields.io/github/forks/phil65/depkit)](https://github.com/phil65/depkit/forks)
[![Github Issues](https://img.shields.io/github/issues/phil65/depkit)](https://github.com/phil65/depkit/issues)
[![Github Issues](https://img.shields.io/github/issues-pr/phil65/depkit)](https://github.com/phil65/depkit/pulls)
[![Github Watchers](https://img.shields.io/github/watchers/phil65/depkit)](https://github.com/phil65/depkit/watchers)
[![Github Stars](https://img.shields.io/github/stars/phil65/depkit)](https://github.com/phil65/depkit/stars)
[![Github Repository size](https://img.shields.io/github/repo-size/phil65/depkit)](https://github.com/phil65/depkit)
[![Github last commit](https://img.shields.io/github/last-commit/phil65/depkit)](https://github.com/phil65/depkit/commits)
[![Github release date](https://img.shields.io/github/release-date/phil65/depkit)](https://github.com/phil65/depkit/releases)
[![Github language count](https://img.shields.io/github/languages/count/phil65/depkit)](https://github.com/phil65/depkit)
[![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/depkit)](https://github.com/phil65/depkit)
[![Package status](https://codecov.io/gh/phil65/depkit/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/depkit/)
[![PyUp](https://pyup.io/repos/github/phil65/depkit/shield.svg)](https://pyup.io/repos/github/phil65/depkit/)

# DependencyManager

A flexible Python dependency manager that handles runtime dependencies and script imports.

## Quick Start

```python
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)

```python
# 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

```bash
pip install depkit
```

## Basic Usage

The DependencyManager supports both synchronous and asynchronous context managers:

### Async Usage
```python
from depkit import DependencyManager

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

### Sync Usage
```python
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:

```python
# 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:

```python
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

```python
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:

```python
manager = DependencyManager(prefer_uv=True)
```

### Custom Package Index

Specify a custom PyPI index:

```python
manager = DependencyManager(
    requirements=["private-package>=1.0.0"],
    pip_index_url="https://private.pypi.org/simple"
)
```

### Path Management

Add custom import paths:

```python
manager = DependencyManager(
    extra_paths=[
        "./src",
        "./lib",
    ]
)
```

### Error Handling

```python
from depkit import DependencyError

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

## Best Practices

1. Use as a context manager to ensure proper cleanup
2. Specify exact version requirements when possible
3. Use PEP 723 for script dependencies
4. Handle DependencyError exceptions appropriately
5. 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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "depkit",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": null,
    "author": "Philipp Temminghoff",
    "author_email": "Philipp Temminghoff <philipptemminghoff@googlemail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ed/e0/ae570a53b47b4e2dafb62e8c7dc4f78852b3324cff827609abfbdafaa0b2/depkit-0.5.0.tar.gz",
    "platform": null,
    "description": "# DepKit\n\n[![PyPI License](https://img.shields.io/pypi/l/depkit.svg)](https://pypi.org/project/depkit/)\n[![Package status](https://img.shields.io/pypi/status/depkit.svg)](https://pypi.org/project/depkit/)\n[![Monthly downloads](https://img.shields.io/pypi/dm/depkit.svg)](https://pypi.org/project/depkit/)\n[![Distribution format](https://img.shields.io/pypi/format/depkit.svg)](https://pypi.org/project/depkit/)\n[![Wheel availability](https://img.shields.io/pypi/wheel/depkit.svg)](https://pypi.org/project/depkit/)\n[![Python version](https://img.shields.io/pypi/pyversions/depkit.svg)](https://pypi.org/project/depkit/)\n[![Implementation](https://img.shields.io/pypi/implementation/depkit.svg)](https://pypi.org/project/depkit/)\n[![Releases](https://img.shields.io/github/downloads/phil65/depkit/total.svg)](https://github.com/phil65/depkit/releases)\n[![Github Contributors](https://img.shields.io/github/contributors/phil65/depkit)](https://github.com/phil65/depkit/graphs/contributors)\n[![Github Discussions](https://img.shields.io/github/discussions/phil65/depkit)](https://github.com/phil65/depkit/discussions)\n[![Github Forks](https://img.shields.io/github/forks/phil65/depkit)](https://github.com/phil65/depkit/forks)\n[![Github Issues](https://img.shields.io/github/issues/phil65/depkit)](https://github.com/phil65/depkit/issues)\n[![Github Issues](https://img.shields.io/github/issues-pr/phil65/depkit)](https://github.com/phil65/depkit/pulls)\n[![Github Watchers](https://img.shields.io/github/watchers/phil65/depkit)](https://github.com/phil65/depkit/watchers)\n[![Github Stars](https://img.shields.io/github/stars/phil65/depkit)](https://github.com/phil65/depkit/stars)\n[![Github Repository size](https://img.shields.io/github/repo-size/phil65/depkit)](https://github.com/phil65/depkit)\n[![Github last commit](https://img.shields.io/github/last-commit/phil65/depkit)](https://github.com/phil65/depkit/commits)\n[![Github release date](https://img.shields.io/github/release-date/phil65/depkit)](https://github.com/phil65/depkit/releases)\n[![Github language count](https://img.shields.io/github/languages/count/phil65/depkit)](https://github.com/phil65/depkit)\n[![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/depkit)](https://github.com/phil65/depkit)\n[![Package status](https://codecov.io/gh/phil65/depkit/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/depkit/)\n[![PyUp](https://pyup.io/repos/github/phil65/depkit/shield.svg)](https://pyup.io/repos/github/phil65/depkit/)\n\n# DependencyManager\n\nA flexible Python dependency manager that handles runtime dependencies and script imports.\n\n## Quick Start\n\n```python\nfrom depkit import DependencyManager\n\n# Simple usage\nmanager = DependencyManager(requirements=[\"requests>=2.31.0\"])\nmanager.install()\nimport requests\n# ... do your work ...\nmanager.uninstall()  # optional cleanup\n```\n\n## Recommended Usage (Context Managers)\n\n```python\n# Synchronous\nwith DependencyManager(requirements=[\"requests\"]) as manager:\n    import requests\n    # ... do your work ...\n    # cleanup happens automatically\n\n# Asynchronous\nasync with DependencyManager(requirements=[\"requests\"]) as manager:\n    import requests\n    # ... do your work ...\n    # cleanup happens automatically\n```\n\n## Features\n\n- Simple install/uninstall methods for quick usage\n- Context managers for proper resource management\n- PEP 723 dependency declaration support\n- Support for both pip and uv package managers\n- Custom pip index URL support\n- Temporary script importing\n- Path management for imports\n\n## Installation\n\n```bash\npip install depkit\n```\n\n## Basic Usage\n\nThe DependencyManager supports both synchronous and asynchronous context managers:\n\n### Async Usage\n```python\nfrom depkit import DependencyManager\n\nasync with DependencyManager(\n    requirements=[\"requests>=2.31.0\", \"pandas\"],\n    prefer_uv=True\n) as manager:\n    import requests\n    import pandas\n```\n\n### Sync Usage\n```python\nfrom depkit import DependencyManager\n\nwith DependencyManager(\n    requirements=[\"requests>=2.31.0\", \"pandas\"],\n    prefer_uv=True\n) as manager:\n    import requests\n    import pandas\n```\n\n## Working with Scripts\n\nThe DependencyManager can handle scripts with PEP 723 dependency declarations:\n\n```python\n# example_script.py\n# /// script\n# dependencies = [\n#   \"requests>=2.31.0\",\n#   \"pandas>=2.0.0\"\n# ]\n# requires-python = \">=3.12\"\n# ///\n\nimport requests\nimport pandas as pd\n```\n\nLoad and use the script:\n\n```python\nasync with DependencyManager(\n    scripts=[\"path/to/example_script.py\"],\n    extra_paths=[\".\"]  # Add paths to Python's import path\n) as manager:\n    # Script's dependencies are installed automatically\n    from example_script import some_function\n```\n\n## Configuration Options\n\n```python\nDependencyManager(\n    prefer_uv: bool = False,          # Prefer uv over pip if available\n    requirements: list[str] = None,   # List of PEP 508 requirement specifiers\n    extra_paths: list[str] = None,    # Additional Python import paths\n    scripts: list[str] = None,        # Scripts to load and process\n    pip_index_url: str = None,        # Custom PyPI index URL\n)\n```\n\n## Features in Detail\n\n### UV Integration\n\nThe manager automatically detects and can use uv for faster package installation:\n\n```python\nmanager = DependencyManager(prefer_uv=True)\n```\n\n### Custom Package Index\n\nSpecify a custom PyPI index:\n\n```python\nmanager = DependencyManager(\n    requirements=[\"private-package>=1.0.0\"],\n    pip_index_url=\"https://private.pypi.org/simple\"\n)\n```\n\n### Path Management\n\nAdd custom import paths:\n\n```python\nmanager = DependencyManager(\n    extra_paths=[\n        \"./src\",\n        \"./lib\",\n    ]\n)\n```\n\n### Error Handling\n\n```python\nfrom depkit import DependencyError\n\ntry:\n    async with DependencyManager(requirements=[\"nonexistent-package\"]):\n        pass\nexcept DependencyError as e:\n    print(f\"Dependency management failed: {e}\")\n```\n\n## Best Practices\n\n1. Use as a context manager to ensure proper cleanup\n2. Specify exact version requirements when possible\n3. Use PEP 723 for script dependencies\n4. Handle DependencyError exceptions appropriately\n5. Consider using uv in production for better performance\n\n## Limitations\n\n- Requires Python 3.12 or higher\n- Some features may not work on all platforms\n- UV support requires uv to be installed separately\n",
    "bugtrack_url": null,
    "license": "MIT License\n         \n         Copyright (c) 2024, Philipp Temminghoff\n         \n         Permission is hereby granted, free of charge, to any person obtaining a copy\n         of this software and associated documentation files (the \"Software\"), to deal\n         in the Software without restriction, including without limitation the rights\n         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n         copies of the Software, and to permit persons to whom the Software is\n         furnished to do so, subject to the following conditions:\n         \n         The above copyright notice and this permission notice shall be included in all\n         copies or substantial portions of the Software.\n         \n         THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n         SOFTWARE.\n         ",
    "summary": "Tools to manage (uv) environemnts programmatically.",
    "version": "0.5.0",
    "project_urls": {
        "Code coverage": "https://app.codecov.io/gh/phil65/depkit",
        "Discussions": "https://github.com/phil65/depkit/discussions",
        "Documentation": "https://phil65.github.io/depkit/",
        "Issues": "https://github.com/phil65/depkit/issues",
        "Source": "https://github.com/phil65/depkit"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d47b2e2f369539ac8658e25c66fb6d6253e0b803fdea01b983af7e5ae2d2a348",
                "md5": "f092d9f1fac03e189da863a23ee233e3",
                "sha256": "f2554be74b77da4ac9901967ec2ce05a469d3bd902013f7369ec46d30cbd59da"
            },
            "downloads": -1,
            "filename": "depkit-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f092d9f1fac03e189da863a23ee233e3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 12688,
            "upload_time": "2025-10-06T20:34:39",
            "upload_time_iso_8601": "2025-10-06T20:34:39.998191Z",
            "url": "https://files.pythonhosted.org/packages/d4/7b/2e2f369539ac8658e25c66fb6d6253e0b803fdea01b983af7e5ae2d2a348/depkit-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ede0ae570a53b47b4e2dafb62e8c7dc4f78852b3324cff827609abfbdafaa0b2",
                "md5": "51f032a79dc900c0b577b2da42b5cec1",
                "sha256": "f5b3dde05367157f2718840c127155aec7173ccde624a755207765b20e153f37"
            },
            "downloads": -1,
            "filename": "depkit-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "51f032a79dc900c0b577b2da42b5cec1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 12585,
            "upload_time": "2025-10-06T20:34:41",
            "upload_time_iso_8601": "2025-10-06T20:34:41.451578Z",
            "url": "https://files.pythonhosted.org/packages/ed/e0/ae570a53b47b4e2dafb62e8c7dc4f78852b3324cff827609abfbdafaa0b2/depkit-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-06 20:34:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "phil65",
    "github_project": "depkit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "depkit"
}
        
Elapsed time: 1.53138s