dependency-injector
Dependency injection framework for Python
Decision gist · record as of 2026-08-14
Yes. Dependency Injector is a mature, actively maintained framework (4907 stars, release 57 days ago, production-stable classifier) with zero known vulnerabilities, permissive licensing, and broad platform support. Install friction is moderate due to Cython compilation but well-mitigated by pre-built wheels. It is worth installing if you want explicit, testable dependency management in a non-trivial application; less essential for simple scripts or if you prefer implicit dependency resolution.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Medium install friction due to compiled Cython wheels, but well-supported across platforms (Windows, macOS, Linux, including ARM64 and musl).
- Active maintenance with release 57 days ago and 4907 GitHub stars indicate stable, production-ready status.
License · maintenance · safety
permissive license (permissive) — BSD 3-Clause permissive license allows commercial use, modification, and distribution with minimal restrictions—standard for open-source frameworks.
last release 2026-06-18 (57 days) · last repo commit 2026-08-11 · 4,907 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 8,389,683 downloads/mo, #1,628 on PyPI
Alternatives
Verify before relying
pip install dependency-injector
from dependency_injector import containers, providers
from dependency_injector.wiring import Provide, inject
class Container(containers.DeclarativeContainer):
service = providers.Singleton(MyService)
@inject
def main(service: MyService = Provide[Container.service]) -> None:
service.do_work()
container = Container()
container.wire(modules=[__name__])
main()- Whether Cython compilation overhead affects startup time in short-lived processes or serverless environments
- Performance comparison with other DI frameworks in high-throughput scenarios
- Maturity of async injection support relative to synchronous injection
What it is and what it does
Dependency Injector is a framework that centralizes how your application assembles and injects object dependencies. Instead of scattering object creation and wiring throughout your code, you declare all components and their relationships in a container, then use decorators or explicit calls to inject them where needed. This makes testing easier (you can override components with mocks), configuration cleaner (read from yaml, json, ini, environment, or pydantic), and the dependency graph explicit and auditable.
The framework provides multiple provider types—Factory for creating new instances, Singleton for shared instances, Configuration for settings, Resource for lifecycle management (logging, event loops, thread pools), and Callable/Coroutine for wrapping functions. It integrates with Django, Flask, FastAPI, Aiohttp, and other frameworks via a wiring system that automatically injects dependencies into decorated functions and methods. Written in Cython for performance, it supports both synchronous and asynchronous injection and includes mypy-friendly typing stubs.
Use it for
- Organize Flask or FastAPI applications by declaring all services (database, cache, API clients) in a container and injecting them into route handlers
- Replace real API clients with mocks during testing by overriding providers without changing application code
- Manage configuration across dev, stage, and production environments by reading from different sources and swapping implementations
- Initialize and manage resources like database connections, thread pools, or event loops with automatic cleanup
- Build decoupled multi-package applications where each package defines its own container and dependencies
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Dependency Injector is a mature, actively maintained framework (4907 stars, release 57 days ago, production-stable classifier) with zero known vulnerabilities, permissive licensing, and broad platform support. Install friction is moderate due to Cython compilation but well-mitigated by pre-built wheels. It is worth installing if you want explicit, testable dependency management in a non-trivial application; less essential for simple scripts or if you prefer implicit dependency resolution.
Install
dependency-injector on PyPI
Before you install
Medium install friction due to compiled Cython wheels, but well-supported across platforms (Windows, macOS, Linux, including ARM64 and musl). Active maintenance with release 57 days ago and 4907 GitHub stars indicate stable, production-ready status.
License in practice
BSD 3-Clause permissive license allows commercial use, modification, and distribution with minimal restrictions—standard for open-source frameworks.
Quickstart
pip install dependency-injector
from dependency_injector import containers, providers
from dependency_injector.wiring import Provide, inject
class Container(containers.DeclarativeContainer):
service = providers.Singleton(MyService)
@inject
def main(service: MyService = Provide[Container.service]) -> None:
service.do_work()
container = Container()
container.wire(modules=[__name__])
main()
Verify before relying
- Whether Cython compilation overhead affects startup time in short-lived processes or serverless environments
- Performance comparison with other DI frameworks in high-throughput scenarios
- Maturity of async injection support relative to synchronous injection
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | 1 packagetyping-extensions |
| Maintenance | Actively maintained 57 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 8,389,683 / month, #1,628 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableFramework :: AsyncIOFramework :: BottleFramework :: DjangoFramework :: FlaskFramework :: PylonsFramework :: PyramidFramework :: PytestFramework :: TurboGearsIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software DevelopmentTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules |
Evidence: dependency_injector-4.49.1-cp310-abi3-macosx_11_0_arm64.whl; dependency_injector-4.49.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; dependency_injector-4.49.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; dependency_injector-4.49.1-cp310-abi3-musllinux_1_2_aarch64.whl; dependency_injector-4.49.1-cp310-abi3-musllinux_1_2_x86_64.whl; dependency_injector-4.49.1-cp310-abi3-win32.whl; dependency_injector-4.49.1-cp310-abi3-win_amd64.whl; dependency_injector-4.49.1-cp38-cp38-macosx_11_0_arm64.whl; dependency_injector-4.49.1-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; dependency_injector-4.49.1-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; dependency_injector-4.49.1-cp38-cp38-musllinux_1_2_aarch64.whl; dependency_injector-4.49.1-cp38-cp38-musllinux_1_2_x86_64.whl; dependency_injector-4.49.1-cp38-cp38-win32.whl; dependency_injector-4.49.1-cp38-cp38-win_amd64.whl; dependency_injector-4.49.1-cp39-cp39-macosx_11_0_arm64.whl; dependency_injector-4.49.1-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; dependency_injector-4.49.1-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; dependency_injector-4.49.1-cp39-cp39-musllinux_1_2_aarch64.whl; dependency_injector-4.49.1-cp39-cp39-musllinux_1_2_x86_64.whl; dependency_injector-4.49.1-cp39-cp39-win32.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “wiring dependencies into functions”
- dependency-injectorDependency Injector is a dependency injection framework that…
- wireupWireup is a type-driven dependency injection container for Python…
- simple-diA strictly typed dependency injection library that lets you define…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also in-n-out · injector · lagom · picobox · rodi · simple-di · slack · wireup · dishka · punq