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

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.1
File Size Uploaded Provenance Actions
pyiv-1.1.1.tar.gz 678.2 kB Without provenance Details for pyiv-1.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 815.4 kB

Release files / pyiv-1.1.1.tar.gz

Download URL pyiv-1.1.1.tar.gz
Size 678.2 kB
Tags Source
SHA-256 checksum
How to use checksums
78d382f6bb733b6b8d1e1db40e0b73350481444c3828bdfc9a3a29e00006a7ac
BLAKE2b-256 checksum
How to use checksums
82a54a7c2a63567baaa60b7fb9b43170d7b46bcf20a30ff2b9e124329e129a2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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

Download URL pyiv-1.1.1-py3-none-any.whl
Size 137.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
17c4460412926ca10d9a8458bf074cdf88e28afbcd0cd4f19f7c3c0e0897ff11
BLAKE2b-256 checksum
How to use checksums
325d0938ce2b35fa729ffcd15ce7d436d1016d403162770df55f06f76e95083f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Security for pyiv 1.1.1

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