slim-bindings 1.0.0__py3-none-manylinux_2_28_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.
@@ -0,0 +1,504 @@
1
+ Metadata-Version: 2.4
2
+ Name: slim-bindings
3
+ Version: 1.0.0
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: Topic :: Software Development :: Libraries
7
+ Classifier: Programming Language :: Python :: 3.10
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 :: Python :: 3.14
12
+ Requires-Dist: pydantic>=2.0.0 ; extra == 'examples'
13
+ Requires-Dist: pydantic-settings>=2.0.0 ; extra == 'examples'
14
+ Requires-Dist: prompt-toolkit>=3.0.52 ; extra == 'examples'
15
+ Requires-Dist: pyyaml>=6.0.3 ; extra == 'examples'
16
+ Requires-Dist: tomli>=2.4.0 ; extra == 'examples'
17
+ Provides-Extra: examples
18
+ Summary: Python bindings for SLIM (Secure Low-Latency Interactive Messaging) using UniFFI
19
+ Author-email: AGNTCY Contributors <slim@agntcy.io>
20
+ License-Expression: Apache-2.0
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
23
+ Project-URL: Issues, https://github.com/agntcy/slim/issues
24
+ Project-URL: Repository, https://github.com/agntcy/slim
25
+
26
+ # SLIM Python Bindings (UniFFI)
27
+
28
+ Python bindings for SLIM (Secure Low-Latency Interactive Messaging) using UniFFI.
29
+
30
+ This provides a Python interface to the SLIM data plane, enabling secure,
31
+ low-latency messaging with support for point-to-point and group
32
+ (multicast) communication patterns.
33
+
34
+ ## Overview
35
+
36
+ These Python bindings are generated from the `agntcy-slim-bindings` crate
37
+ using [UniFFI](https://mozilla.github.io/uniffi-rs/), providing a native
38
+ Python interface that wraps the high-performance Rust implementation.
39
+
40
+ ### Key Features
41
+
42
+ - **Point-to-Point Messaging**: Direct communication between two endpoints
43
+ - **Group Messaging**: Multicast communication with multiple participants
44
+ - **Secure by Default**: Support for TLS, mTLS, and various authentication methods
45
+ - **MLS Encryption**: End-to-end encryption for sessions
46
+ - **Delivery Confirmation**: Optional completion handles for reliable messaging
47
+ - **Flexible Authentication**: Shared secrets, JWT, SPIRE integration
48
+
49
+ ## Architecture
50
+
51
+ The Python bindings are built using Maturin, which automatically generates
52
+ Python bindings from the Rust UniFFI adapter:
53
+
54
+ ```
55
+ data-plane/bindings/
56
+ ├── rust/ # Rust UniFFI bindings (shared by Go, Python, etc.)
57
+ │ ├── src/
58
+ │ │ ├── app.rs
59
+ │ │ ├── build_info.rs
60
+ │ │ ├── client_config.rs
61
+ │ │ ├── common_config.rs
62
+ │ │ ├── completion_handle.rs
63
+ │ │ ├── config.rs
64
+ │ │ ├── errors.rs
65
+ │ │ ├── identity.rs
66
+ │ │ ├── identity_config.rs
67
+ │ │ ├── init_config.rs
68
+ │ │ ├── lib.rs
69
+ │ │ ├── message_context.rs
70
+ │ │ ├── name.rs
71
+ │ │ ├── server_config.rs
72
+ │ │ ├── service.rs
73
+ │ │ └── session.rs
74
+ │ └── Cargo.toml
75
+ ├── go/ # Go-specific bindings and examples
76
+ └── python/ # Python-specific bindings and examples (this directory)
77
+ ├── examples/ # Example applications
78
+ ├── tests/ # Unit and integration tests
79
+ └── Taskfile.yaml # Build and development tasks
80
+ ```
81
+
82
+ ## Prerequisites
83
+
84
+ - **Rust toolchain** (1.70+)
85
+ - **Python** (3.10+)
86
+ - **uv** (Python package manager): https://docs.astral.sh/uv/
87
+ - **Task** (optional, for convenient build commands)
88
+
89
+ ## Installation
90
+
91
+ ### Development Build
92
+
93
+ ```bash
94
+ cd data-plane/bindings/python
95
+ task python:bindings:build
96
+ ```
97
+
98
+ This will:
99
+ 1. Install all dependencies
100
+ 2. Compile the Rust UniFFI adapter
101
+ 3. Generate Python bindings using Maturin
102
+ 4. Install the package in development mode
103
+
104
+ ## Creating Distribution Packages
105
+
106
+ ### Build Wheels for Multiple Python Versions
107
+
108
+ To create distributable wheel packages for Python 3.10, 3.11, 3.12, 3.13 and 3.14:
109
+
110
+ ```bash
111
+ task python:bindings:packaging
112
+ ```
113
+
114
+ Or directly with Maturin:
115
+
116
+ ```bash
117
+ uv run maturin build --release -i 3.10 3.11 3.12 3.13
118
+ ```
119
+
120
+ Maturin automatically:
121
+ 1. Compiles the Rust UniFFI adapter library
122
+ 2. Generates Python bindings from UniFFI scaffolding
123
+ 3. Bundles the native library into platform-specific wheels
124
+ 4. Creates wheels for each specified Python version
125
+
126
+ The resulting wheels are self-contained and ready for distribution.
127
+
128
+ #### Custom Build Options
129
+
130
+ You can customize the build with the following variables:
131
+
132
+ ```bash
133
+ # Build for a specific target architecture
134
+ task python:bindings:packaging TARGET=aarch64-apple-darwin
135
+
136
+ # Build in debug mode (default is release)
137
+ task python:bindings:packaging PROFILE=debug
138
+
139
+ # Cross-compile for Linux on macOS
140
+ task python:bindings:packaging TARGET=x86_64-unknown-linux-gnu
141
+ ```
142
+
143
+ #### Output Structure
144
+
145
+ After running the packaging task, you'll find:
146
+
147
+ ```
148
+ dist/
149
+ ├── slim_uniffi_bindings-0.7.0-cp310-*.whl # Python 3.10 wheel
150
+ ├── slim_uniffi_bindings-0.7.0-cp311-*.whl # Python 3.11 wheel
151
+ ├── slim_uniffi_bindings-0.7.0-cp312-*.whl # Python 3.12 wheel
152
+ └── slim_uniffi_bindings-0.7.0-cp313-*.whl # Python 3.13 wheel
153
+ ```
154
+
155
+ Note: The native library is automatically bundled inside each wheel.
156
+
157
+ #### Installing from Wheel
158
+
159
+ Users can install the wheel package directly:
160
+
161
+ ```bash
162
+ pip install slim_uniffi_bindings-0.7.0-cp310-*.whl
163
+ ```
164
+
165
+ The native library is automatically included in the wheel and will be loaded at runtime.
166
+
167
+ ## Examples
168
+
169
+ Examples are a **separate project** in the `examples/` directory.
170
+
171
+ See [examples/README.md](examples/README.md) for detailed instructions.
172
+
173
+ ### Quick Start with Examples
174
+
175
+ ```bash
176
+ cd examples
177
+
178
+ # View available examples
179
+ task
180
+
181
+ # Run simple example
182
+ task simple
183
+
184
+ # Run point-to-point examples
185
+ task p2p:alice # Terminal 1
186
+ task p2p:bob # Terminal 2
187
+ ```
188
+
189
+ ## Quick Start
190
+
191
+ ### Simple Example
192
+
193
+ ```python
194
+ import slim_uniffi_bindings as slim
195
+
196
+ # Initialize crypto provider
197
+ slim.initialize_crypto_provider()
198
+
199
+ # Get version
200
+ print(f"SLIM Version: {slim.get_version()}")
201
+
202
+ # Create an app with shared secret authentication
203
+ app_name = {
204
+ 'components': ['org', 'example', 'app'],
205
+ 'id': None
206
+ }
207
+ app = slim.create_app_with_secret(app_name, "my-secret")
208
+
209
+ print(f"App ID: {app.id()}")
210
+ print(f"App Name: {'/'.join(app.name().components)}")
211
+ ```
212
+
213
+ Run the simple example:
214
+ ```bash
215
+ cd examples
216
+ task simple
217
+ ```
218
+
219
+ ### Point-to-Point Communication
220
+
221
+ **Terminal 1 - Receiver (Alice):**
222
+ ```bash
223
+ cd examples
224
+ task p2p:alice
225
+ ```
226
+
227
+ **Terminal 2 - Sender (Bob):**
228
+ ```bash
229
+ cd examples
230
+ task p2p:bob
231
+ ```
232
+
233
+ ### Group Communication
234
+
235
+ **Terminal 1 - Participant (Alice):**
236
+ ```bash
237
+ cd examples
238
+ task group:participant:alice
239
+ ```
240
+
241
+ **Terminal 2 - Participant (Bob):**
242
+ ```bash
243
+ cd examples
244
+ task group:participant:bob
245
+ ```
246
+
247
+ **Terminal 3 - Moderator:**
248
+ ```bash
249
+ cd examples
250
+ task group:moderator
251
+ ```
252
+
253
+ For more details, see [examples/README.md](examples/README.md).
254
+
255
+ ## API Overview
256
+
257
+ ### Application Creation
258
+
259
+ ```python
260
+ # Create app with shared secret
261
+ app = slim.create_app_with_secret(app_name, shared_secret)
262
+
263
+ # Get app information
264
+ app_id = app.id()
265
+ app_name = app.name()
266
+ ```
267
+
268
+ ### Server Operations
269
+
270
+ ```python
271
+ # Connect to server
272
+ client_config = {
273
+ 'endpoint': 'http://localhost:46357',
274
+ 'tls': {'insecure': True, ...}
275
+ }
276
+ conn_id = app.connect(client_config)
277
+
278
+ # Run server
279
+ server_config = {
280
+ 'endpoint': '127.0.0.1:46357',
281
+ 'tls': {'insecure': True, ...}
282
+ }
283
+ app.run_server(server_config)
284
+
285
+ # Disconnect
286
+ app.disconnect(conn_id)
287
+ ```
288
+
289
+ ### Session Management
290
+
291
+ ```python
292
+ # Create session
293
+ session_config = {
294
+ 'session_type': 'PointToPoint', # or 'Group'
295
+ 'enable_mls': False,
296
+ 'max_retries': 3,
297
+ 'interval_ms': 100,
298
+ 'initiator': True,
299
+ 'metadata': {}
300
+ }
301
+ session = app.create_session(session_config, destination_name)
302
+
303
+ # Listen for incoming session
304
+ session = app.listen_for_session(timeout_ms=30000)
305
+
306
+ # Delete session
307
+ app.delete_session(session)
308
+ ```
309
+
310
+ ### Messaging
311
+
312
+ ```python
313
+ # Send message (fire-and-forget)
314
+ session.publish(data, "text/plain", metadata)
315
+
316
+ # Send with delivery confirmation
317
+ completion = session.publish_with_completion(data, "text/plain", metadata)
318
+ completion.wait() # Block until delivered
319
+
320
+ # Receive message
321
+ msg = session.get_message(timeout_ms=5000)
322
+ print(f"Payload: {msg.payload}")
323
+ print(f"From: {msg.context.source_name}")
324
+ print(f"Type: {msg.context.payload_type}")
325
+
326
+ # Reply to message
327
+ session.publish_to(msg.context, reply_data, "text/plain", None)
328
+ ```
329
+
330
+ ### Group Operations
331
+
332
+ ```python
333
+ # Invite participant to group
334
+ session.invite(participant_name)
335
+
336
+ # Remove participant
337
+ session.remove(participant_name)
338
+ ```
339
+
340
+ ## Examples
341
+
342
+ ### Examples Directory Structure
343
+
344
+ ```
345
+ examples/
346
+ ├── common/
347
+ │ └── common.py # Shared utilities
348
+ ├── simple/
349
+ │ └── main.py # Basic functionality demo
350
+ ├── point_to_point/
351
+ │ └── main.py # P2P messaging
352
+ └── group/
353
+ └── main.py # Group/multicast messaging
354
+ ```
355
+
356
+ ### Running Examples
357
+
358
+ All examples require a running SLIM server. Start the Go server:
359
+
360
+ ```bash
361
+ cd data-plane/bindings/go
362
+ task example:server
363
+ ```
364
+
365
+ Then run Python examples:
366
+
367
+ ```bash
368
+ # Simple example
369
+ task example
370
+
371
+ # Point-to-point
372
+ task example:p2p:alice # Terminal 1
373
+ task example:p2p:bob # Terminal 2
374
+
375
+ # Group messaging
376
+ task example:group:participant:alice # Terminal 1
377
+ task example:group:participant:bob # Terminal 2
378
+ task example:group:moderator # Terminal 3
379
+ ```
380
+
381
+ ## Testing
382
+
383
+ ### Unit Tests
384
+
385
+ ```bash
386
+ task test
387
+ # or
388
+ python -m pytest tests/unit_test.py -v
389
+ ```
390
+
391
+ ### Integration Tests
392
+
393
+ Integration tests require a running SLIM server:
394
+
395
+ ```bash
396
+ # Terminal 1: Start server
397
+ cd ../go && task example:server
398
+
399
+ # Terminal 2: Run integration tests
400
+ SLIM_INTEGRATION_TEST=1 python -m pytest tests/integration_test.py -v -s
401
+ ```
402
+
403
+ ## Development
404
+
405
+ ### Available Tasks
406
+
407
+ ```bash
408
+ task # Show help
409
+ task build # Build package with Maturin
410
+ task test # Run tests
411
+ task python:bindings:packaging # Build wheels for multiple Python versions
412
+ task clean # Clean build artifacts
413
+ ```
414
+
415
+ ### Project Structure
416
+
417
+ - `slim_uniffi_bindings/` - Python package (bindings generated by Maturin)
418
+ - `examples/` - Example applications
419
+ - `tests/` - Unit and integration tests
420
+ - `Taskfile.yaml` - Build automation
421
+ - `pyproject.toml` - Package configuration (Maturin build system)
422
+
423
+ ## Comparison with Go Bindings
424
+
425
+ Both Python and Go bindings use the same UniFFI adapter, ensuring API consistency:
426
+
427
+ | Feature | Python | Go |
428
+ |---------|--------|-----|
429
+ | Binding Generation | uniffi-bindgen | uniffi-bindgen-go |
430
+ | API Style | Pythonic (snake_case) | Idiomatic Go (PascalCase) |
431
+ | Error Handling | Exceptions | Error returns |
432
+ | Async Support | Sync wrapper over async Rust | Sync wrapper over async Rust |
433
+ | Examples | ✅ | ✅ |
434
+ | Tests | ✅ | ✅ |
435
+
436
+ ## API Reference
437
+
438
+ ### Core Types
439
+
440
+ - **`Name`**: Application/service identifier with components and optional ID
441
+ - **`SessionConfig`**: Configuration for creating sessions
442
+ - **`TlsConfig`**: TLS settings for secure connections
443
+ - **`ServerConfig`**: Server endpoint and TLS configuration
444
+ - **`ClientConfig`**: Client endpoint and TLS configuration
445
+ - **`MessageContext`**: Message metadata (source, destination, type, metadata)
446
+ - **`ReceivedMessage`**: Received message with context and payload
447
+
448
+ ### Main Classes
449
+
450
+ - **`BindingsAdapter`**: Main app interface for session management
451
+ - **`BindingsSessionContext`**: Session interface for messaging
452
+ - **`FfiCompletionHandle`**: Completion handle for delivery confirmation
453
+
454
+ ### Session Types
455
+
456
+ - **`PointToPoint`**: Direct one-to-one communication
457
+ - **`Group`**: One-to-many multicast communication
458
+
459
+ ## Troubleshooting
460
+
461
+ ### ImportError: Cannot find slim_uniffi_bindings
462
+
463
+ Make sure you've built the package:
464
+ ```bash
465
+ task build
466
+ # or
467
+ uv run maturin develop
468
+ ```
469
+
470
+ ### Connection Refused
471
+
472
+ Ensure the SLIM server is running:
473
+ ```bash
474
+ cd ../go && task example:server
475
+ ```
476
+
477
+ ### Build Errors
478
+
479
+ If you encounter build errors, try cleaning and rebuilding:
480
+ ```bash
481
+ task clean
482
+ uv run maturin develop
483
+ ```
484
+
485
+ ## Contributing
486
+
487
+ When contributing to the Python bindings:
488
+
489
+ 1. Maintain API consistency with Go bindings
490
+ 2. Follow Python naming conventions (snake_case)
491
+ 3. Add tests for new functionality
492
+ 4. Update examples if adding features
493
+ 5. Keep documentation up to date
494
+
495
+ ## License
496
+
497
+ Apache-2.0 - See [LICENSE.md](../../../LICENSE.md) for details
498
+
499
+ ## See Also
500
+
501
+ - [Go Bindings](../go/README.md)
502
+ - [UniFFI Adapter](../adapter/src/)
503
+ - [SLIM Documentation](../../../README.md)
504
+
@@ -0,0 +1,14 @@
1
+ examples/__init__.py,sha256=2rAkgLOIvqQ31YIoiYoAuUcTcj71gbGSmNlekLDEDn4,1233
2
+ examples/common.py,sha256=sfJ2tGnkS564yBrOMJ1_wZC3eqoEuMYNKRAoKiLTIZA,12976
3
+ examples/config.py,sha256=OOxKxV5YBmaXjM0oVbZAzt4E3bLsuADh6ydiENX55V8,8694
4
+ examples/example-config.yaml,sha256=pWsB8gVyZ5aGg_kuJ_WJ7UN7xTUrBNT4VM2lQDOvw-g,1239
5
+ examples/group.py,sha256=KtWhiyoHfSxUdyghDFrXv3uNpXvY0sJ_RKIw_XXcwRA,13388
6
+ examples/point_to_point.py,sha256=gnEgvCUoy-4Jjcy0CITQBZB1syLjBgWnYulTmMX9NAo,7690
7
+ examples/slim.py,sha256=FI1BTUxmMfod3s1hlcPCVN5XFTM9n8hU6HkDRmjG724,4192
8
+ slim_bindings/__init__.py,sha256=FX8rhMJVsqnEy4DZmkIoCpRBPBvPOUUbJTKt2ESxMJ8,37
9
+ slim_bindings/libslim_bindings.so,sha256=dqy1e8ubLYhNQnkEPtmqN80mZYzDoN-fE9zbEaMs92s,29947872
10
+ slim_bindings/slim_bindings.py,sha256=RrdtgqaIpdKX-slwLZaR0_PBlPD3Nq2jLKiz4awxjlE,349641
11
+ slim_bindings-1.0.0.dist-info/METADATA,sha256=Bv25ZP-sMvgkDmZcUHaGriP3feCW8GYUh-CwE8_dpNA,12535
12
+ slim_bindings-1.0.0.dist-info/WHEEL,sha256=68kItbwFCkNZI3ViN4Q0UTMD4TdCgRSDJRyKoQsjux8,107
13
+ slim_bindings-1.0.0.dist-info/entry_points.txt,sha256=sJs2CLTUgKIvBM_ZEiG6gfXbTXMlSlRzGrmJ2s9nnSs,145
14
+ slim_bindings-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.11.5)
3
+ Root-Is-Purelib: false
4
+ Tag: py3-none-manylinux_2_28_aarch64
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ slim-bindings-group=examples.group:main
3
+ slim-bindings-p2p=examples.point_to_point:main
4
+ slim-bindings-server=examples.slim:main