Skip to main content

pyiv

Guice-style dependency injection for Python: type-based constructor injection, scopes, qualified keys (tag sets, matched inject, Annotated constructors), and use-case stdlib doubles (files, time, console, log, process, …). Zero runtime dependencies. Python 3.8+.

Docs: https://rl337.org/pyiv/ · Changelog: https://rl337.org/pyiv/changelog.html · PyPI: https://pypi.org/project/pyiv/

Install

pip install pyiv

Requires Python 3.8 or newer. Unreleased main:

pip install git+https://github.com/rl337/pyiv.git

YAML and requests integrations are a second package (core stays stdlib-only):

pip install pyiv-common

The user guide covers Binder, Keys, scopes, use-case doubles under pyiv.files / pyiv.time / pyiv.log / pyiv.process (and legacy Clock / Filesystem re-exports), and related packages.

Quick start

from pyiv import Config, get_injector

class Database:
    pass

class PostgreSQL(Database):
    pass

class MyConfig(Config):
    def configure(self):
        self.register(Database, PostgreSQL)

injector = get_injector(MyConfig)
db = injector.inject(Database)  # PostgreSQL

Development

pip install -e ".[dev,docs]"
pip install -e extras/pyiv-common
./run_checks.sh

run_checks.sh formats (black/isort), runs pytest (including doctests in pyiv/ and pyiv-common), mypy, bandit, and a Sphinx build.

Version numbers are bumped by GitHub Actions on main. Do not edit pyproject.toml / pyiv/__init__.py versions except for a manual major bump (the 0.3.0 PyPI release is that exception).

License

MIT — see LICENSE.

Metadata

Release files for pyiv 1.1.0

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

Source distribution (sdist)

Source distribution for pyiv 1.1.0
File Size Uploaded Provenance Actions
pyiv-1.1.0.tar.gz 673.4 kB Without provenance Details for pyiv-1.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 807.9 kB

Release files / pyiv-1.1.0.tar.gz

Download URL pyiv-1.1.0.tar.gz
Size 673.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4712b973f5810a01f40518adbd92567a1cdd8e54affe0b2e09f8f784f6e94b76
BLAKE2b-256 checksum
How to use checksums
c0148a6d8426bf7ea61d408e41aeb378670c742168a744f173d6113b95d767f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pyiv-1.1.0-py3-none-any.whl

Download URL pyiv-1.1.0-py3-none-any.whl
Size 134.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7cb87b4e39fbc1a0ca7c4b5b1b9595b87cfc54cd51872c580a6559004d853e70
BLAKE2b-256 checksum
How to use checksums
3e8840ae27e51052cab945a594c0d581c1a140b2c907cb47f6303f1a892631f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Security for pyiv 1.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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