15. Compiling & Distributing
Run vs. compile
- Interpret (full language):
stencil app.st— supports everything in these tutorials. - Compile to native exe:
stencil build app.st -o app.exe— produces a standalone Windows executable that runs without STencil installed.
stencil build app.st -o app.exe
app.exe
What native build supports
Numbers, strings, bools, arithmetic, comparison, logic, if/elif/else,
while/for/for..in, functions + recursion, ternary, lists, dicts, indexing &
their methods, classes/models, in.
What native build does NOT support (use the interpreter for these)
import, try/catch, stencil stamping, and the library builtins
(file/JSON/regex/http/graphics/db/...). For programs that use those, ship the .st
file and have users run it with the interpreter.
Distributing your program
- As a
.stscript — share the file; users need STencil installed (pip install stencil-langor the installer). Simple and works with the full language. - As a native
.exe—stencil build(subset only). No dependency for the user. - Bundle in an installer — put your
.st(or exe) plusstencil.exein an installer (e.g. Inno Setup) so users get a double-click install.
Distributing STencil itself
- pip: the language is published —
pip install stencil-lang. - Windows installer:
STencil-Setup.exe(per-user; adds PATH,.stassociation, Start Menu, examples).
Hosting a web app (e.g. Railway)
A web server written with serve(...) (lesson 12) can be deployed in a container.
Read $PORT from the environment and serve on it:
serve(int(env("PORT")), route);
A Dockerfile that builds STencil from source and runs your app.st lets platforms
like Railway build and host it on Linux.
Where to go next
- Re-read Stencils — the feature that makes STencil yours.
- Build something: a CLI tool (lesson 11), a web API (lesson 12), or a game (lesson 13).
Kitteniverse Studios