dioxide 0.0.2a1__cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dioxide/__init__.py +51 -0
- dioxide/_dioxide_core.abi3.so +0 -0
- dioxide/_dioxide_core.pyi +18 -0
- dioxide/container.py +606 -0
- dioxide/decorators.py +249 -0
- dioxide/profile.py +206 -0
- dioxide/py.typed +0 -0
- dioxide/scope.py +77 -0
- dioxide-0.0.2a1.dist-info/METADATA +324 -0
- dioxide-0.0.2a1.dist-info/RECORD +12 -0
- dioxide-0.0.2a1.dist-info/WHEEL +4 -0
- dioxide-0.0.2a1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dioxide
|
|
3
|
+
Version: 0.0.2a1
|
|
4
|
+
Classifier: Development Status :: 3 - Alpha
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
11
|
+
Classifier: Programming Language :: Rust
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
13
|
+
Classifier: Typing :: Typed
|
|
14
|
+
Requires-Dist: maturin>=1.0,<2.0 ; extra == 'dev'
|
|
15
|
+
Requires-Dist: pytest>=8.0 ; extra == 'dev'
|
|
16
|
+
Requires-Dist: pytest-cov>=4.1 ; extra == 'dev'
|
|
17
|
+
Requires-Dist: behave>=1.2.6 ; extra == 'dev'
|
|
18
|
+
Requires-Dist: mypy>=1.8 ; extra == 'dev'
|
|
19
|
+
Requires-Dist: ruff>=0.1 ; extra == 'dev'
|
|
20
|
+
Requires-Dist: isort>=5.13 ; extra == 'dev'
|
|
21
|
+
Requires-Dist: tox>=4.0 ; extra == 'dev'
|
|
22
|
+
Requires-Dist: pre-commit>=3.0 ; extra == 'dev'
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Summary: Fast, Rust-backed declarative dependency injection for Python
|
|
26
|
+
Keywords: dependency-injection,di,ioc,rust,container
|
|
27
|
+
Author-email: Mike Lane <mikelane@gmail.com>
|
|
28
|
+
License: MIT
|
|
29
|
+
Requires-Python: >=3.11
|
|
30
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
31
|
+
Project-URL: Homepage, https://github.com/mikelane/dioxide
|
|
32
|
+
Project-URL: Repository, https://github.com/mikelane/dioxide
|
|
33
|
+
Project-URL: Issues, https://github.com/mikelane/dioxide/issues
|
|
34
|
+
|
|
35
|
+
# dioxide
|
|
36
|
+
|
|
37
|
+
**Fast, Rust-backed declarative dependency injection for Python**
|
|
38
|
+
|
|
39
|
+
[](https://github.com/mikelane/dioxide/actions)
|
|
40
|
+
[](https://github.com/mikelane/dioxide/actions/workflows/release-automated.yml)
|
|
41
|
+
[](https://pypi.org/project/dioxide/)
|
|
42
|
+
[](https://pypi.org/project/dioxide/)
|
|
43
|
+
[](https://github.com/mikelane/dioxide)
|
|
44
|
+
[](https://github.com/mikelane/dioxide)
|
|
45
|
+
[](https://opensource.org/licenses/MIT)
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Overview
|
|
50
|
+
|
|
51
|
+
`dioxide` is a dependency injection framework for Python that combines:
|
|
52
|
+
|
|
53
|
+
- **Declarative Python API** - Simple decorators and type hints
|
|
54
|
+
- **Rust-backed performance** - Fast graph construction and resolution via PyO3
|
|
55
|
+
- **Type safety** - Full support for mypy and type checkers
|
|
56
|
+
- **Clean architecture** - Encourages loose coupling and testability
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install dioxide
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Platform Support
|
|
65
|
+
|
|
66
|
+
| Platform | x86_64 | ARM64/aarch64 |
|
|
67
|
+
|----------|--------|---------------|
|
|
68
|
+
| Linux | ✅ | ✅ |
|
|
69
|
+
| macOS | ✅ | ✅ (M1/M2/M3) |
|
|
70
|
+
| Windows | ✅ | ❌ |
|
|
71
|
+
|
|
72
|
+
**Python Versions**: 3.11, 3.12, 3.13, 3.14
|
|
73
|
+
|
|
74
|
+
## Status
|
|
75
|
+
|
|
76
|
+
**⚠️ ALPHA**: dioxide is in active alpha development. API changes expected between releases.
|
|
77
|
+
|
|
78
|
+
- **Latest Release**: [v0.0.1-alpha](https://github.com/mikelane/dioxide/releases/tag/v0.0.1-alpha) (Nov 6, 2025) - Published to Test PyPI
|
|
79
|
+
- **Current Work**: v0.0.2-alpha - MLP API Realignment (breaking changes)
|
|
80
|
+
- **Next Milestone**: v0.1.0-beta - MLP Complete (API freeze) - Mid-December 2025
|
|
81
|
+
|
|
82
|
+
See [ROADMAP.md](ROADMAP.md) for detailed timeline and [Issues](https://github.com/mikelane/dioxide/issues) for current work.
|
|
83
|
+
|
|
84
|
+
## Vision
|
|
85
|
+
|
|
86
|
+
**Make the Dependency Inversion Principle feel inevitable.**
|
|
87
|
+
|
|
88
|
+
dioxide exists to make clean architecture (ports-and-adapters) the path of least resistance. We combine:
|
|
89
|
+
|
|
90
|
+
1. **Type-safe DI** - If mypy passes, the wiring is correct
|
|
91
|
+
2. **Profile-based implementations** - Swap PostgreSQL ↔ in-memory with one line
|
|
92
|
+
3. **Testing without mocks** - Fast fakes at the seams, not mock behavior
|
|
93
|
+
4. **Rust-backed performance** - Fast graph operations and resolution
|
|
94
|
+
|
|
95
|
+
See [MLP_VISION.md](docs/MLP_VISION.md) for the complete design philosophy.
|
|
96
|
+
|
|
97
|
+
## Quick Start
|
|
98
|
+
|
|
99
|
+
**⚠️ Note**: API examples show **target MLP syntax** (v0.1.0-beta). Current v0.0.1-alpha uses different syntax. See [CHANGELOG.md](CHANGELOG.md) for migration guide.
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from dioxide import container, component, profile
|
|
103
|
+
from typing import Protocol
|
|
104
|
+
|
|
105
|
+
# Define a protocol (the seam)
|
|
106
|
+
class EmailProvider(Protocol):
|
|
107
|
+
async def send(self, to: str, subject: str, body: str) -> None: ...
|
|
108
|
+
|
|
109
|
+
# Production implementation
|
|
110
|
+
@component.implements(EmailProvider)
|
|
111
|
+
@profile.production
|
|
112
|
+
class SendGridEmail:
|
|
113
|
+
async def send(self, to: str, subject: str, body: str) -> None:
|
|
114
|
+
# Real SendGrid API call
|
|
115
|
+
pass
|
|
116
|
+
|
|
117
|
+
# Test/dev implementation
|
|
118
|
+
@component.implements(EmailProvider)
|
|
119
|
+
@profile("test", "development")
|
|
120
|
+
class FakeEmail:
|
|
121
|
+
def __init__(self):
|
|
122
|
+
self.outbox = []
|
|
123
|
+
|
|
124
|
+
async def send(self, to: str, subject: str, body: str) -> None:
|
|
125
|
+
self.outbox.append({"to": to, "subject": subject})
|
|
126
|
+
|
|
127
|
+
# Business logic depends on protocol, not implementation
|
|
128
|
+
@component
|
|
129
|
+
class NotificationService:
|
|
130
|
+
def __init__(self, email: EmailProvider):
|
|
131
|
+
self.email = email
|
|
132
|
+
|
|
133
|
+
async def send_welcome(self, user_email: str) -> None:
|
|
134
|
+
await self.email.send(user_email, "Welcome!", "Thanks for signing up!")
|
|
135
|
+
|
|
136
|
+
# Scan and activate profile
|
|
137
|
+
container.scan("app", profile="production") # or "test" for testing
|
|
138
|
+
|
|
139
|
+
# Use services directly (dependencies auto-injected)
|
|
140
|
+
service = NotificationService()
|
|
141
|
+
await service.send_welcome("user@example.com")
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Key features**:
|
|
145
|
+
- `@component` for singleton components (shared across app)
|
|
146
|
+
- `@component.factory` for per-request components (new instance each time)
|
|
147
|
+
- `@profile` to swap implementations by environment
|
|
148
|
+
- Global singleton container (no manual instantiation)
|
|
149
|
+
- Constructor injection via type hints
|
|
150
|
+
|
|
151
|
+
## Features
|
|
152
|
+
|
|
153
|
+
### v0.0.1-alpha ✅ RELEASED (Nov 6, 2025)
|
|
154
|
+
- [x] `@component` decorator for auto-discovery
|
|
155
|
+
- [x] Container.scan() for automatic registration
|
|
156
|
+
- [x] Constructor dependency injection
|
|
157
|
+
- [x] SINGLETON and FACTORY scopes
|
|
158
|
+
- [x] Manual provider registration
|
|
159
|
+
- [x] Type-safe Container.resolve() with mypy support
|
|
160
|
+
- [x] 100% test coverage
|
|
161
|
+
- [x] Full CI/CD automation
|
|
162
|
+
|
|
163
|
+
### v0.0.2-alpha 🔄 IN PROGRESS (MLP API Realignment)
|
|
164
|
+
- [x] `@component.implements(Protocol)` syntax - ✅ Issue #66
|
|
165
|
+
- [x] `@profile` decorator system (hybrid approach) - ✅ Issue #68
|
|
166
|
+
- [ ] `@component.factory` attribute syntax - Issue #65
|
|
167
|
+
- [ ] `container.scan()` with package and profile parameters - Issue #69
|
|
168
|
+
- [x] Global singleton container pattern - ✅ Issue #70
|
|
169
|
+
- [ ] Documentation realignment
|
|
170
|
+
- [x] Optional: `container[Type]` syntax - ✅ Issue #70
|
|
171
|
+
|
|
172
|
+
### v0.1.0-beta 🎯 TARGET: Mid-December 2025 (MLP Complete)
|
|
173
|
+
- [ ] Lifecycle protocols (`Initializable`, `Disposable`)
|
|
174
|
+
- [ ] Circular dependency detection at startup
|
|
175
|
+
- [ ] Excellent error messages with suggestions
|
|
176
|
+
- [ ] Complete example application
|
|
177
|
+
- [ ] FastAPI integration example
|
|
178
|
+
- [ ] Testing guide (fakes > mocks philosophy)
|
|
179
|
+
- [ ] API frozen (no breaking changes until 2.0)
|
|
180
|
+
|
|
181
|
+
### Post-MLP Features (v0.2.0+)
|
|
182
|
+
See [ROADMAP.md](ROADMAP.md) for post-MLP features:
|
|
183
|
+
- Request scoping
|
|
184
|
+
- Property injection
|
|
185
|
+
- Framework integrations (FastAPI, Flask, Django)
|
|
186
|
+
- Developer tooling (CLI, IDE plugins)
|
|
187
|
+
|
|
188
|
+
## Development
|
|
189
|
+
|
|
190
|
+
### Prerequisites
|
|
191
|
+
|
|
192
|
+
- Python 3.11+
|
|
193
|
+
- Rust 1.70+
|
|
194
|
+
- [uv](https://github.com/astral-sh/uv) for Python package management
|
|
195
|
+
- [maturin](https://github.com/PyO3/maturin) for building Rust extensions
|
|
196
|
+
|
|
197
|
+
### Setup
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Clone the repository
|
|
201
|
+
git clone https://github.com/mikelane/dioxide.git
|
|
202
|
+
cd dioxide
|
|
203
|
+
|
|
204
|
+
# Install dependencies with uv
|
|
205
|
+
uv venv
|
|
206
|
+
source .venv/bin/activate # or `.venv\Scripts\activate` on Windows
|
|
207
|
+
uv pip install -e ".[dev]"
|
|
208
|
+
|
|
209
|
+
# Build the Rust extension
|
|
210
|
+
maturin develop
|
|
211
|
+
|
|
212
|
+
# Run tests
|
|
213
|
+
pytest
|
|
214
|
+
|
|
215
|
+
# Run all quality checks
|
|
216
|
+
tox
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Development Workflow
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Format code
|
|
223
|
+
tox -e format
|
|
224
|
+
|
|
225
|
+
# Lint
|
|
226
|
+
tox -e lint
|
|
227
|
+
|
|
228
|
+
# Type check
|
|
229
|
+
tox -e type
|
|
230
|
+
|
|
231
|
+
# Run tests for all Python versions
|
|
232
|
+
tox
|
|
233
|
+
|
|
234
|
+
# Run tests with coverage
|
|
235
|
+
tox -e cov
|
|
236
|
+
|
|
237
|
+
# Mutation testing
|
|
238
|
+
tox -e mutate
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Pre-commit Hooks
|
|
242
|
+
|
|
243
|
+
Install pre-commit hooks to ensure code quality:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
pre-commit install
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Architecture
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
dioxide/
|
|
253
|
+
├── python/dioxide/ # Python API
|
|
254
|
+
│ ├── __init__.py
|
|
255
|
+
│ ├── container.py # Main Container class
|
|
256
|
+
│ ├── decorators.py # @component decorator
|
|
257
|
+
│ └── scope.py # Scope enum
|
|
258
|
+
├── rust/src/ # Rust core
|
|
259
|
+
│ └── lib.rs # PyO3 bindings and graph logic
|
|
260
|
+
├── tests/ # Python tests
|
|
261
|
+
└── pyproject.toml # Project configuration
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Key Design Decisions
|
|
265
|
+
|
|
266
|
+
1. **Rust for graph operations** - Dependency graphs can get complex; Rust's performance and safety help scale
|
|
267
|
+
2. **Python-first API** - Developers work in pure Python; Rust is an implementation detail
|
|
268
|
+
3. **Type hints as the contract** - Leverage Python's type system for DI metadata
|
|
269
|
+
4. **Explicit over implicit** - Registration is manual to avoid surprises
|
|
270
|
+
5. **Test-driven development** - Every feature starts with failing tests
|
|
271
|
+
|
|
272
|
+
## Comparison to Other Frameworks
|
|
273
|
+
|
|
274
|
+
| Feature | dioxide | dependency-injector | injector |
|
|
275
|
+
|---------|----------|---------------------|----------|
|
|
276
|
+
| Type-based DI | ✅ | ✅ | ✅ |
|
|
277
|
+
| Rust-backed | ✅ | ❌ | ❌ |
|
|
278
|
+
| Scopes | ✅ | ✅ | ✅ |
|
|
279
|
+
| Lifecycle | ✅ | ✅ | ❌ |
|
|
280
|
+
| Cycle detection | ✅ (planned) | ❌ | ❌ |
|
|
281
|
+
| Performance* | 🚀 (goal) | ⚡ | ⚡ |
|
|
282
|
+
|
|
283
|
+
*Benchmarks coming in v0.2
|
|
284
|
+
|
|
285
|
+
## Contributing
|
|
286
|
+
|
|
287
|
+
Contributions are welcome! We follow a strict workflow to maintain code quality:
|
|
288
|
+
|
|
289
|
+
**Quick start for contributors:**
|
|
290
|
+
1. **Create or find an issue** - All work must be associated with a GitHub issue
|
|
291
|
+
2. **Fork the repository** (external contributors)
|
|
292
|
+
3. **Create a feature branch** with issue reference (e.g., `fix/issue-123-description`)
|
|
293
|
+
4. **Follow TDD** - Write tests first, then implementation
|
|
294
|
+
5. **Submit a Pull Request** - All changes must go through PR review
|
|
295
|
+
|
|
296
|
+
**Key requirements:**
|
|
297
|
+
- ✅ All work must have an associated GitHub issue
|
|
298
|
+
- ✅ All changes must go through the Pull Request process
|
|
299
|
+
- ✅ Tests and documentation are mandatory
|
|
300
|
+
- ✅ Branch protection enforces these requirements on `main`
|
|
301
|
+
|
|
302
|
+
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
|
|
303
|
+
|
|
304
|
+
See [ROADMAP.md](ROADMAP.md) for the complete product roadmap and [MLP_VISION.md](docs/MLP_VISION.md) for the design philosophy.
|
|
305
|
+
|
|
306
|
+
## License
|
|
307
|
+
|
|
308
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
309
|
+
|
|
310
|
+
## Acknowledgments
|
|
311
|
+
|
|
312
|
+
- Inspired by [dependency-injector](https://github.com/ets-labs/python-dependency-injector) and Spring Framework
|
|
313
|
+
- Built with [PyO3](https://github.com/PyO3/pyo3) and [maturin](https://github.com/PyO3/maturin)
|
|
314
|
+
- Graph algorithms powered by [petgraph](https://github.com/petgraph/petgraph)
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
**⚠️ Alpha Status**: dioxide is in active alpha development. Breaking API changes expected until v0.1.0-beta (mid-December 2025), when the API will freeze. Not recommended for production use yet.
|
|
319
|
+
|
|
320
|
+
**MLP Timeline**:
|
|
321
|
+
- **Now**: v0.0.2-alpha - API realignment with MLP Vision
|
|
322
|
+
- **Dec 2025**: v0.1.0-beta - MLP Complete, API frozen ✨
|
|
323
|
+
- **2026+**: Post-MLP features, ecosystem growth, 1.0 stable
|
|
324
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
dioxide-0.0.2a1.dist-info/METADATA,sha256=PcH2k84VXd_J08Uxt_riN_cafe4S1T9uZabk91rAg-A,11245
|
|
2
|
+
dioxide-0.0.2a1.dist-info/WHEEL,sha256=Xj3Gekq9LGV-pOsH0xOV_xZAidS_kmiR2iwGc6yWrnY,130
|
|
3
|
+
dioxide-0.0.2a1.dist-info/licenses/LICENSE,sha256=JpEmJvRYOTIUt0UjgvpDrd3U94Wnbt_Grr5z-xU2jtk,1066
|
|
4
|
+
dioxide/__init__.py,sha256=VCnC7vekY2D_FLtCkNpiiws0qMpx9e4Wle2Ul5L_VxE,1523
|
|
5
|
+
dioxide/_dioxide_core.abi3.so,sha256=WxmhZzvj8hwXyu0pDn5r6j9FJAEaQP3NZY7V91LcTmE,381792
|
|
6
|
+
dioxide/_dioxide_core.pyi,sha256=IkVCY_MBiU6UBX09V1mI3yAdrMEw00qGg1NE5uIspf0,702
|
|
7
|
+
dioxide/container.py,sha256=dxda4yPDUefPcSJnx02Xa3vTZnNypul-GntFDJAUm1A,25485
|
|
8
|
+
dioxide/decorators.py,sha256=JVqPWCSnOXVYUOzb2wY2S5fCBuMtcRWlXRNhKYacwAQ,8798
|
|
9
|
+
dioxide/profile.py,sha256=0MY9h92iAZ88kyPbMd8aNV4AAuiJlDQX5cZ-A0ZzFQM,6759
|
|
10
|
+
dioxide/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
dioxide/scope.py,sha256=xRKDoUz8OzBRgLpXj2lk_Nir0F7aPnJFI1eMY2mgeOg,2358
|
|
12
|
+
dioxide-0.0.2a1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mike Lane
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|