Skip to content

Commit 755498e

Browse files
aepfliclaude
andcommitted
docs: add uv usage instructions for local development
Add comprehensive uv documentation for Python bindings development across all documentation files. uv is a fast Python package installer and resolver written in Rust, providing significantly faster package management than traditional pip. Changes: - README.md: Add Development section with uv quick start - python/README.md: Add uv as recommended method with detailed instructions - CLAUDE.md: Update Python bindings section with uv workflow - Update outdated evaluate_logic references in examples Benefits of using uv: - 10-100x faster package installation - Better dependency resolution - Built-in virtualenv management - Seamless drop-in replacement for pip 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent fdbacd1 commit 755498e

3 files changed

Lines changed: 92 additions & 7 deletions

File tree

CLAUDE.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ cargo clippy -- -D warnings
6868

6969
```
7070
src/
71-
├── lib.rs # Main entry point, WASM exports (evaluate_logic, update_state, evaluate)
71+
├── lib.rs # Main entry point, WASM exports (update_state, evaluate)
7272
├── evaluation.rs # Core flag evaluation logic, context enrichment ($flagd properties)
7373
├── memory.rs # WASM memory management (alloc/dealloc, pointer packing)
7474
├── storage/ # Thread-local flag state storage
@@ -311,7 +311,7 @@ In addition to WASM integration, this project provides **native Python bindings*
311311
```
312312
python/
313313
├── src/
314-
│ └── lib.rs # PyO3 bindings (evaluate_logic, FlagEvaluator class)
314+
│ └── lib.rs # PyO3 bindings (FlagEvaluator class)
315315
├── tests/ # Python test suite (pytest)
316316
├── examples/ # Usage examples
317317
├── benchmarks/ # Performance benchmarks
@@ -322,6 +322,30 @@ python/
322322

323323
### Building Python Bindings
324324

325+
**Recommended: Using uv (faster)**
326+
327+
```bash
328+
# Install uv
329+
curl -LsSf https://astral.sh/uv/install.sh | sh
330+
331+
# Set up development environment
332+
cd python
333+
uv venv
334+
source .venv/bin/activate
335+
uv pip install maturin pytest
336+
337+
# Build and install locally
338+
maturin develop
339+
340+
# Run tests
341+
pytest tests/ -v
342+
343+
# Build wheels for distribution
344+
maturin build --release
345+
```
346+
347+
**Alternative: Using pip**
348+
325349
```bash
326350
# Install maturin
327351
pip install maturin
@@ -342,10 +366,14 @@ maturin build --release
342366
**API Design**: Pythonic dictionaries instead of JSON strings:
343367
```python
344368
# PyO3 API (native)
345-
result = evaluate_logic({"==": [1, 1]}, {})
369+
evaluator = FlagEvaluator()
370+
evaluator.update_state({"flags": {"myFlag": {...}}})
371+
result = evaluator.evaluate("myFlag", {})
346372

347373
# vs WASM API (for comparison)
348-
result_json = evaluate_logic_wasm(json.dumps(rule), json.dumps(data))
374+
config_json = json.dumps({"flags": {"myFlag": {...}}})
375+
update_state_wasm(config_json)
376+
result_json = evaluate_wasm("myFlag", "{}")
349377
result = json.loads(result_json)
350378
```
351379

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,23 @@ print(enabled) # True
184184
- 🔧 Native Python exceptions
185185
- 💾 Efficient memory usage
186186

187+
**Development:**
188+
189+
For local development, we recommend using [uv](https://github.com/astral-sh/uv) for faster package management:
190+
191+
```bash
192+
# Install uv
193+
curl -LsSf https://astral.sh/uv/install.sh | sh
194+
195+
# Set up development environment
196+
cd python
197+
uv venv
198+
source .venv/bin/activate
199+
uv pip install maturin pytest
200+
maturin develop
201+
pytest tests/ -v
202+
```
203+
187204
See [python/README.md](python/README.md) for complete documentation.
188205

189206
### Python with Wasmtime (Alternative)

python/README.md

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,47 @@ See [benchmarks/bench_vs_wasm.py](benchmarks/bench_vs_wasm.py) for detailed comp
158158

159159
### Building from Source
160160

161+
#### Recommended: Using uv (faster)
162+
163+
[uv](https://github.com/astral-sh/uv) is a fast Python package installer and resolver written in Rust.
164+
161165
```bash
162-
# Install maturin
163-
pip install maturin
166+
# Install uv (if not already installed)
167+
curl -LsSf https://astral.sh/uv/install.sh | sh
164168

165-
# Build and install locally
169+
# Create virtual environment
166170
cd python
171+
uv venv
172+
173+
# Activate virtual environment
174+
source .venv/bin/activate # On Unix/macOS
175+
# .venv\Scripts\activate # On Windows
176+
177+
# Install dependencies and build package
178+
uv pip install maturin pytest
179+
180+
# Build and install the package in development mode
181+
maturin develop
182+
183+
# Run tests
184+
pytest tests/ -v
185+
```
186+
187+
#### Alternative: Using pip
188+
189+
```bash
190+
# Create virtual environment
191+
cd python
192+
python -m venv .venv
193+
194+
# Activate virtual environment
195+
source .venv/bin/activate # On Unix/macOS
196+
# .venv\Scripts\activate # On Windows
197+
198+
# Install dependencies
199+
pip install maturin pytest
200+
201+
# Build and install locally
167202
maturin develop
168203

169204
# Run tests
@@ -173,6 +208,11 @@ pytest tests/ -v
173208
### Running Tests
174209

175210
```bash
211+
# With uv (from python directory)
212+
uv pip install pytest
213+
pytest tests/ -v
214+
215+
# With pip (from repository root)
176216
pip install pytest
177217
pytest python/tests/ -v
178218
```

0 commit comments

Comments
 (0)