Skip to main content

Build Linux distros in pure Python โ€” compiled to C, packaged as ISO

Project description

pylinux ๐Ÿง

Build Linux distros in pure Python โ€” compiled to C, linked into an ELF kernel, packaged as a bootable ISO.

pip install pylinux-sdk
pylux new my-distro
cd my-distro
pyinlux build
pylux run

How it works

your Python source
      โ”‚
      โ–ผ (pylux.compiler โ€” AST โ†’ C99)
  C source files
      โ”‚
      โ–ผ (gcc cross-compiler)
  .o object files
      โ”‚
      โ–ผ (ld + linker script)
  kernel.elf  (multiboot2, bare-metal)
      โ”‚
      โ–ผ (grub-mkrescue + xorriso)
  your-distro.iso  โ† bootable!
      โ”‚
      โ–ผ (qemu-system-x86_64)
  ๐Ÿ–ฅ๏ธ  running in VM

Commands

Command Description
pylux new <n> Init project in <name>/
pylux build Full build: Python โ†’ C โ†’ ELF โ†’ ISO
pylux run Boot ISO in QEMU
pylux debug QEMU + GDB stub on :1234
pylux compile Python โ†’ C only
pylux check Syntax-check all sources
pylux clean Remove build artifacts
pylux clean --all Remove artifacts + cache
pylux add <mod> Scaffold a new module/driver
pylux info Toolchain & project info
pylux config show Dump pylux.toml
pylux config set vm.memory_mb 1024 Edit a config value
pylux log Tail latest build log
pylux disasm objdump the kernel ELF
pylux shell Cross-compile env shell

pylux directives

Inside your .py files, special comments control the compiler:

# pylux: multiboot2          โ€” emit multiboot2 header in this file
# pylux: arch=x86_64         โ€” override target arch
# pylux: stack_size=131072   โ€” set kernel stack size
# pylux: c_inline            โ€” entire file: function bodies become C stubs
# pylux: no_stack_protector  โ€” compile with -fno-stack-protector
# pylux: io_access           โ€” allow I/O port intrinsics
# pylux: module_type=driver  โ€” metadata tag

# inside a function body:
# pylux: asm("movq $0, %rax")
# pylux: c_inline("*(volatile uint32_t*)0xB8000 = 0x0F48;")
# pylux: register_irq(1, my_handler)

Prerequisites

# Ubuntu / Debian
sudo apt install gcc nasm binutils grub-pc-bin xorriso qemu-system-x86

# Fedora / RHEL
sudo dnf install gcc nasm binutils grub2-tools xorriso qemu-system-x86

# Arch
sudo pacman -S gcc nasm binutils grub libisoburn qemu-system-x86

Project layout (after pylux new)

my-distro/
โ”œโ”€โ”€ pylux.toml              โ† project config
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ kernel.py           โ† kernel entry: kernel_main()
โ”‚   โ”œโ”€โ”€ boot.py             โ† GDT / IDT / paging setup
โ”‚   โ”œโ”€โ”€ drivers/
โ”‚   โ”‚   โ”œโ”€โ”€ vga.py          โ† VGA text-mode driver
โ”‚   โ”‚   โ”œโ”€โ”€ keyboard.py     โ† PS/2 keyboard
โ”‚   โ”‚   โ””โ”€โ”€ timer.py        โ† PIT 8254 timer
โ”‚   โ””โ”€โ”€ kstd/
โ”‚       โ”œโ”€โ”€ string.py       โ† strlen, strcpy, itoa โ€ฆ
โ”‚       โ”œโ”€โ”€ memory.py       โ† kmalloc / kfree
โ”‚       โ””โ”€โ”€ io.py           โ† io_inb / io_outb
โ””โ”€โ”€ .pylux/
    โ”œโ”€โ”€ build/              โ† generated C, .o files, kernel.elf, ISO
    โ”œโ”€โ”€ cache/
    โ””โ”€โ”€ logs/

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylinux_sdk-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pylinux_sdk-0.1.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file pylinux_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: pylinux_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for pylinux_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3c242c5719a515d9a07f6d817791cea75522c15c9983073749d291d5cdf21c8c
MD5 8c324e13978bc9297c5d4aca44fb837d
BLAKE2b-256 8bb7b2655a2d22e9478b960aad58f29e78e72169baad4b23f67c348ffc01b3dd

See more details on using hashes here.

File details

Details for the file pylinux_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pylinux_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for pylinux_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d3bb1f82e2b783c351b9d99b7970e3eeec15cf4f238eaeb3d2f067ceb11f8663
MD5 d1f10f10b6558878ced794164a06e05e
BLAKE2b-256 8cee61eecb7343aecfddd6612c4f13e58cb3556f52764086b37026d7ce757e3e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page