Skip to main content

PyOS

Build your own operating system in Python -- then play with it.

Python 3.14+ CI Docs License: MIT

Ever wondered what happens when you open a program, save a file, or connect to the internet? PyOS is a complete operating system simulator that lets you see every piece -- processes, memory, filesystems, networking -- and poke at them from a real shell. Built with test-driven development and written for learners.

What Does It Look Like?

  ======================================
            PyOS v0.1.0
     A simulated operating system
  ======================================

  [POST] CPU ... OK
  [POST] Memory ... OK
  [POST] Storage ... OK
  [BOOT] Loading kernel image v0.1.0 ... OK
  [OK] Logger
  [OK] Memory manager (256 frames)
  [OK] Slab allocator
  [OK] File system (journaled)
  [OK] Scheduler (FCFS)
  [OK] Init process (PID 1)

Kernel running. Type 'help' for commands, 'exit' to quit.

root@pyos $ ps
PID  State    Name
1    READY    init

root@pyos $ fork 1
Forked process 1 → child PID 2 (init)

root@pyos $ pstree
init (PID 1)
  └── init (PID 2)

root@pyos $ learn
Available tutorials:
  processes  — What is a process and how do they work?
  memory     — How does the OS manage memory?
  filesystem — How are files stored and organised?
  shell      — What is a shell and why do we need one?
  scheduling — How does the CPU decide what to run next?
Type 'learn <topic>' to start a tutorial.

Features

  • Six CPU schedulers -- FCFS, Round Robin, Priority, Aging, MLFQ, and CFS with multi-core support
  • Virtual memory -- page tables, address translation, swap (FIFO/LRU/Clock), slab allocator, and mmap
  • Journaled filesystem -- inodes, directories, hard/soft links, file descriptors, /proc, and crash recovery
  • Full network stack -- sockets, DNS, HTTP, and TCP with three-way handshake, flow control, and congestion control
  • Shell scripting -- pipes, variables, conditionals, job control, tab completion, and 80+ built-in commands
  • Interactive tutorials -- guided lessons that teach OS concepts hands-on using real system calls

Install

pip install fromscratch-pyos
pyos

Want the browser-based terminal too?

pip install fromscratch-pyos[web]
pyos-web

Learn the Concepts

Each guide explains one part of the OS with real-world analogies and simple language.

Guide What You'll Learn
What Is an OS? The big picture -- what an OS does and why you need one
Processes Programs that are running, how they take turns, forking, and threads
Memory How the OS manages limited memory with pages, virtual addresses, and swap
Filesystem How files and folders are organised, and how they're saved to disk
The Kernel The brain of the OS -- boot sequence and system calls
The Shell Typing commands, pipes, scripting, and environment variables
Devices and Networking Hardware, inter-process communication, disk scheduling, and sockets
Interrupts and Timers Interrupt controller, vectors, masking, timer, preemption
TCP: Reliable Delivery Three-way handshake, flow control, congestion control, retransmission
Users and Safety Permissions, signals, logging, and deadlocks
Synchronization Mutexes, semaphores, condition variables, and race conditions
The Boot Chain What happens between pressing power and seeing a prompt
Framebuffer Pixel-level graphics, drawing shapes, and displaying images
TUI Dashboard A live terminal dashboard that shows OS internals in real time
Permissions File ownership, read/write/execute bits, groups, and ACLs
Binary Loader Loading and running programs -- how exec works
Containers Lightweight isolation with PID, mount, and network namespaces
Inter-Machine Networking Connecting multiple kernels with bridges and clusters
Interactive Tutorials Guided lessons that teach OS concepts hands-on
Web UI Browser-based terminal interface

Development

git clone https://github.com/robcox2910/py-os.git
cd py-os
uv sync --all-extras
uv run pytest

See CONTRIBUTING.md for coding standards and PR workflow.

Releasing

Other projects in the series (PyStack) use a released version of this one from PyPI, not whatever is on main. To publish a change for them:

  1. Merge the change to main.
  2. Release it: gh release create vX.Y.Z --target main --generate-notes (or push a vX.Y.Z tag); the release workflow publishes it to PyPI. A change to the public API bumps the minor version (v0.1.0 → v0.2.0); anything else bumps the patch (v0.1.0 → v0.1.1).
  3. In each project that uses it, raise the fromscratch-pyos>=X.Y.Z floor in pyproject.toml, run uv lock --upgrade-package fromscratch-pyos, and open a pull request so CI checks the pair together.

This project is one of a series that builds real systems "from scratch in Python" to teach how they work. See the series home for the full story.

Project What it teaches Repository Docs PyPI
PyOS Operating systems py-os Docs fromscratch-pyos
Pebble Compilers and programming languages pebble-lang Docs fromscratch-pebble
PyDB Relational databases pydb Docs fromscratch-pydb
PyKV Key-value stores pykv Docs fromscratch-pykv
PyDocDB Document databases pydoc-db Docs fromscratch-pydocdb
PyGraphDB Graph databases pygraphdb Docs fromscratch-pygraphdb
PyTSDB Time-series databases pytsdb Docs fromscratch-pytsdb
PyVecDB Vector databases pyvecdb Docs fromscratch-pyvecdb
PyColDB Column-family databases pycoldb Docs fromscratch-pycoldb
PyCrypt Cryptography pycrypt Docs fromscratch-pycrypt
PyNet Computer networking pynet Docs fromscratch-pynet
PyWeb HTTP web servers pyweb Docs fromscratch-pyweb
PyGit Version control pygit Docs fromscratch-pygit
PySearch Search engines pysearch Docs fromscratch-pysearch
PyMQ Message queues pymq Docs fromscratch-pymq
PyLLM Language models (the brain) pyllm Docs fromscratch-pyllm
PyScheduler Job scheduling pyscheduler Docs fromscratch-pyscheduler
PyStack Full-stack integration pystack Docs fromscratch-pystack

Documentation

Full docs (with kid-friendly explanations of every idea): https://robcox2910.github.io/py-os/

Install

PyPI

pip install fromscratch-pyos

Or get the whole series at once: pip install fromscratch-pystack.

Metadata

Release files for fromscratch-pyos 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fromscratch-pyos 0.3.1
File Size Uploaded Provenance Actions
fromscratch_pyos-0.3.1.tar.gz 522.5 kB With provenance Details for fromscratch_pyos-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fromscratch-pyos 0.3.1
File Interpreter ABI Platform Actions
fromscratch_pyos-0.3.1-py3-none-any.whl Python 3 none any Details for fromscratch_pyos-0.3.1-py3-none-any.whl

Total release size: 740.5 kB

Release files / fromscratch_pyos-0.3.1.tar.gz

Download URL fromscratch_pyos-0.3.1.tar.gz
Size 522.5 kB
Tags Source
SHA-256 checksum
How to use checksums
97f96a032724bc9a991ab2673c025a1166a8cce8ffcf865d768c8c7bb9d82d50
BLAKE2b-256 checksum
How to use checksums
7e194baaeab2b98da48e15049f868f73a8308a4b0ca5264c6cca6308181eb2fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / fromscratch_pyos-0.3.1-py3-none-any.whl

Download URL fromscratch_pyos-0.3.1-py3-none-any.whl
Size 217.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e75b83760bd5573f9adb335f525ad669fa7392b9f56795e1593e878222d92b0
BLAKE2b-256 checksum
How to use checksums
8fbf491a530d24d6dc8f845fc190a829912328254db981bb9a7c29ff5a17d08a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for fromscratch-pyos 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fromscratch_pyos-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page