The pymdl book
3. Setting up
3.1 Requirements
pymdl runs on Python with the standard library. Python 3.13 or later
is recommended: SUBSTITUTE's miniature garbage collection (chapter 24)
sweeps live call-frame locals through the write-through f_locals that
PEP 667 introduced; on an older Python everything else sweeps and an identity
morph covers the rest. pytest runs the test suite.
One optional package: greenlet (pip install greenlet) gives the
coroutine SUBRs of chapter 22 -- RESUME, SUICIDE, BREAK-SEQ, 1STEP,
FREE-RUN -- their faithful cooperative stack-swapping. Without it the rest
of the chapter works (PROCESS, STATE, ME, MAIN, RESUMER) and the
swapping SUBRs raise an error that says what is missing.
3.2 The system library
MDL's package system finds packages through a library: on ITS LIBMUD;,
on Tenex PS:<MDLLIB>, the same library under two names (chapter 30). pymdl
ships package sources and builds the library by running MIT's Library
Update Program (LUP) over them:
PYTHONPATH=src python tools/build_mdllib.py # about forty seconds
The output is src/pymdl/mdl/mdllib/: a copy of every package source beside
an .nlib index and a .dat data file. Chapter 30
explains this library-building workflow in section 4.1.10. It is a
build output and is not tracked; the test suite builds it when it is missing.
pymdl runs without it -- USE falls through to the package sources -- but
with it USE resolves through the era's own ENTRY-FIND and DEFER-FIND,
which is the faithful path.
3.3 The test suite
PYTHONPATH=src python -m pytest -q
The suite includes the manuals' worked examples, this
book's executable examples (the mdl blocks in docs/pymdl/), the era batteries
(tests/era_battery/, forms measured on MDL 55 with the answers recorded),
the compiler gate (-m gate: the era compiler compiling and running its
samples in four configurations) and the assembler reconstructions. Tests
that need the archive or apsim skip when they are absent and say so.
3.4 Personalities
,MUDDLE ⇒ 55
A session is release 55 on ITS unless told otherwise. PYMDL_OS=tenex or
PYMDL_OS=tops20 in the environment, or os_name= to new_interpreter,
makes it release 105, and ,MUDDLE answers 105. The effects of the
personality setting are explained where you use them:
- Input/output: file names, channels, end-of-file conventions, saved files, and network interfaces.
- Interrupts: activation characters and the interrupt classes available in each personality.
- MDL as a system process: process names, exits, and inter-process communication.
- Running pymdl and initial settings: the initialization file and listener control characters.
3.5 The era corpus and the era machine
Two things outside the repository make the measurements possible, and neither is needed to run MDL.
The archive, ~/mdl-1971-1987 by default (PYMDL_ERA_CORPUS names
another location), is the MIT MDL tapes. The tools that derive provenance
(tools/mdl_manifest.py), stage the compiler's binaries, and run the
self-host measurements read it. A slice the test suite needs is vendored
under tests/data/era and verified against the archive by
tools/vendor_era_data.py --verify.
apsim runs the real MDL 55 for the questions the manuals do not answer
(chapter 37). PYMDL_APSIM names the simulator and PYMDL_ERA_ROOT a
writable copy of its ITS root; tools/era_session.py asks a form and prints
the answer.
3.6 Knobs
Every environment variable pymdl and its tools read is in Appendix D, with
its default and its purpose. Three matter to an ordinary session:
PYMDL_OS above, PYMDL_NO_PDP10 (chapter 36: run with the emulator off),
and PYMDL_DSKDATE, which pins the clock so that a program that consults the
date is reproducible.