--- id: svcs version: "26.1.0" license: MIT license_treatment: permissive maintenance: active --- # svcs — A Flexible Service Locator License: permissive · Maintenance: active · Downloads: 7.4M/mo ## What it is and what it does svcs is a dependency container that centralizes the registration and acquisition of service instances in Python applications. It supports both dependency injection and service locator patterns without requiring global state, decorators, or function signature changes. The container automatically manages cleanup of acquired services through context managers and provides health checks for monitoring. The package integrates with popular web frameworks (AIOHTTP, FastAPI, Flask, Pyramid, Starlette) and provides full static type safety when used with a type checker. It reduces boilerplate code for service acquisition and cleanup while maintaining loose coupling between components, which simplifies testing. Recent versions added support for abstract types via PEP 747 and autowiring based on type annotations. Use it for: - Manage database connections, API clients, and caches in FastAPI or Flask applications with automatic cleanup per request. - Implement dependency injection in web frameworks without decorators or global state, improving testability. - Register multiple implementations of a service interface and switch between them for different environments or test scenarios. - Add health checks to services for monitoring and observability in production applications. - Automatically resolve and inject dependencies based on type annotations in function signatures. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. svcs is a dependency container that registers factories for types and provides automatic cleanup and health checks when acquiring service instances in Python applications. Yes. svcs is actively maintained, production-stable, has no known vulnerabilities, and solves a genuine problem in dependency management for Python web applications. The low install friction and optional static typing make it accessible. It's particularly valuable if you're using FastAPI, Flask, or another supported framework and want to reduce boilerplate around service acquisition and cleanup. ## Install pip install svcs uv add svcs poetry add svcs ## Installing svcs Before you install: Low friction install with only two lightweight runtime dependencies (attrs and typing-extensions). Active maintenance with a release 32 days ago and recent commits; marked Production/Stable. License in practice: MIT license permits commercial and private use with minimal restrictions; suitable for most projects. Quickstart: pip install svcs from svcs import Container from attrs import define @define class Database: pass container = Container() container.register(Database, factory=Database) db = container.get(Database) Requires Python 3.10 or later; Python 3.9 support was removed. Verify before relying: - Whether the framework integrations (AIOHTTP, FastAPI, Flask, Pyramid, Starlette) are included in the base package or require separate installation. - Performance characteristics when managing large numbers of service instances or complex dependency graphs. - Whether health checks are automatically invoked or must be explicitly called. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 7.4M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags dependency injection container, service locator python, inversion of control, dependency management framework, automatic resource cleanup, type-safe service registry, fastapi flask dependency injection, dependency-injection, inversion-of-control, web-framework-integration [View on SkillFed](https://skillfed.io/packages/svcs) · [View on PyPI](https://pypi.org/project/svcs/)