numpy availability strategy: bundle, side-venv, or scientific package variant #337

Open
opened 2026-07-02 12:29:42 +00:00 by john · 1 comment
Owner

From the 2026-07-02 memory-model review. The buffer-protocol issues (#334, #335) make mcrfpy numpy-ready; this issue decides how users actually get numpy.

Current state

  • Embedded 3.14 ships stdlib only: __lib/Python/Lib/site-packages/ contains just a README; __lib/Python/lib.linux-x86_64-3.14/ has no _multiarray_umath.
  • src/scripts/mcrf_venv.py:146-233 already pip-installs into a separate venv and wires it up -- numpy is literally in its example strings.

Options

  1. Document the side-venv as the supported path (cheapest; works today; desktop-only).
  2. Bundle numpy in the full package variant: ~+20 MB on a ~26 MB package; must match the embedded interpreter ABI (cp314, plus cp314t if free-threaded builds ship -- matrix doubles).
  3. New package-*-scientific preset: full stdlib + numpy, keeping light/full unchanged. Fits the existing tools/stdlib_modules.yaml packaging structure.
  4. #70 route (mcrfpy against system Python): makes pip install numpy trivially work, but is its own large project.

WASM: numpy-in-pyodide is a separate project, explicitly out of scope here.

Recommendation to evaluate first: (1) now + (3) when #334/#335 land, so 'McRogueFace for agents/RL' (#55, #154, #156) is a one-download story.

Note: python-tcod's ecosystem is numpy-native; matching that convention makes McRogueFace legible to the existing roguelike-dev community.

From the 2026-07-02 memory-model review. The buffer-protocol issues (#334, #335) make mcrfpy *numpy-ready*; this issue decides how users actually get numpy. ## Current state - Embedded 3.14 ships stdlib only: `__lib/Python/Lib/site-packages/` contains just a README; `__lib/Python/lib.linux-x86_64-3.14/` has no `_multiarray_umath`. - `src/scripts/mcrf_venv.py:146-233` already pip-installs into a **separate venv** and wires it up -- numpy is literally in its example strings. ## Options 1. **Document the side-venv as the supported path** (cheapest; works today; desktop-only). 2. **Bundle numpy** in the full package variant: ~+20 MB on a ~26 MB package; must match the embedded interpreter ABI (cp314, plus cp314t if free-threaded builds ship -- matrix doubles). 3. **New `package-*-scientific` preset**: full stdlib + numpy, keeping light/full unchanged. Fits the existing `tools/stdlib_modules.yaml` packaging structure. 4. **#70 route** (mcrfpy against system Python): makes `pip install numpy` trivially work, but is its own large project. WASM: numpy-in-pyodide is a separate project, explicitly out of scope here. Recommendation to evaluate first: (1) now + (3) when #334/#335 land, so 'McRogueFace for agents/RL' (#55, #154, #156) is a one-download story. Note: python-tcod's ecosystem is numpy-native; matching that convention makes McRogueFace legible to the existing roguelike-dev community.
Author
Owner

Refinement (2026-07-11): unblocked, bumped to tier2, framed as agent-env enabler

Unblocked. The buffer-protocol prerequisite shipped 2026-07-11: #334 (DiscreteMap buffer protocol) and #335 (ColorLayer/TileLayer zero-copy numpy views via with layer.edit() as view:). mcrfpy is now buffer-protocol-ready; this issue is the only thing standing between that and users actually consuming the views with real numpy. Bumped tier3 → tier2.

Why it matters now (destination). This is enabling background work for the agent environment: #54 (Jupyter), #55 (Wumpus sim), and #154/#156 (multi-agent LLM testbed). VLM/RL perception pipelines and Jupyter users expect numpy-native arrays, and matching python-tcod's numpy-native convention makes the environment legible to the existing roguelike-dev community.

New task — numpy round-trip validation. The sprint validated the buffer views through memoryview only (numpy isn't in the build). Before we claim "numpy-ready," add a test/demo under the side-venv (src/scripts/mcrf_venv.py) proving np.asarray/np.frombuffer round-trips (a) a ColorLayer.edit() view and (b) a DiscreteMap — write through numpy, read back the mutation in-engine.

Delivery recommendation (reaffirmed). (1) Document the side-venv as the supported path now + (3) a package-*-scientific preset later. Keep numpy out of the core package — reinforced by the free-threading coupling: a bundled numpy must ship cp314t wheels if 3.14t ever lands (#336), doubling the interpreter matrix. #70 (mcrfpy as wheels against system Python) is the eventual cleanest delivery and makes pip install numpy trivial.

## Refinement (2026-07-11): unblocked, bumped to tier2, framed as agent-env enabler **Unblocked.** The buffer-protocol prerequisite shipped 2026-07-11: #334 (DiscreteMap buffer protocol) and #335 (ColorLayer/TileLayer zero-copy numpy views via `with layer.edit() as view:`). mcrfpy is now buffer-protocol-ready; this issue is the only thing standing between that and users actually consuming the views with real numpy. Bumped tier3 → **tier2**. **Why it matters now (destination).** This is enabling background work for the **agent environment**: #54 (Jupyter), #55 (Wumpus sim), and #154/#156 (multi-agent LLM testbed). VLM/RL perception pipelines and Jupyter users expect numpy-native arrays, and matching python-tcod's numpy-native convention makes the environment legible to the existing roguelike-dev community. **New task — numpy round-trip validation.** The sprint validated the buffer views through `memoryview` only (numpy isn't in the build). Before we claim "numpy-ready," add a test/demo under the side-venv (`src/scripts/mcrf_venv.py`) proving `np.asarray`/`np.frombuffer` round-trips (a) a `ColorLayer.edit()` view and (b) a `DiscreteMap` — write through numpy, read back the mutation in-engine. **Delivery recommendation (reaffirmed).** (1) Document the side-venv as the supported path **now** + (3) a `package-*-scientific` preset later. Keep numpy **out** of the core package — reinforced by the free-threading coupling: a bundled numpy must ship cp314t wheels if 3.14t ever lands (#336), doubling the interpreter matrix. #70 (mcrfpy as wheels against system Python) is the eventual cleanest delivery and makes `pip install numpy` trivial.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
john/McRogueFace#337
No description provided.