This release is a pre-release and may not be stable for production use.
pymcu-stdlib
This package contains the standard library and HAL definitions for PyMCU, a Python-to-microcontroller toolchain that compiles a statically-typed subset of Python directly to bare-metal machine code.
These files provide hardware register mappings, HAL abstractions, and phantom types that allow Python IDEs (PyCharm, VS Code, etc.) to provide autocompletion and type checking for microcontroller code, while being compiled by the pymcuc compiler.
Purpose
Microcontroller code written for PyMCU uses specialized types and access patterns that are not native to standard Python. This package bridges that gap by:
- Defining Hardware Registers: Mapping register names (e.g.,
PORTB,DDRB) to their physical memory addresses for each supported chip. - Providing Type Safety: Using phantom types like
uint8,uint16, andptr[T]to ensure correct data sizing at compile time. - HAL Abstractions: Zero-cost abstractions (
Pin,UART,ADC,PWM,SPI,I2C,EEPROM,Watchdog,Power) that inline to chip-specific code at compile time. - Enabling IDE Features: Allowing "Go to Definition", autocompletion, and static analysis while writing firmware in Python.
Supported Chips
- AVR ATmega family: ATmega48/48P, ATmega88/88P, ATmega168/168P, ATmega328/328P (Arduino Uno)
- AVR ATtiny (PORTB only): ATtiny85, ATtiny45, ATtiny25, ATtiny13, ATtiny13a
- AVR ATtiny (PORTA+PORTB): ATtiny84, ATtiny44, ATtiny24
- AVR ATtiny (PORTD+PORTB): ATtiny2313, ATtiny4313
- PIC: PIC14 (PIC16F84A, PIC16F877A), PIC14E (PIC16F18877), PIC18 (PIC18F45K50)
- RISC-V: CH32V003 (experimental)
Installation
uv pip install pymcu
Or with pipx for CLI use:
pipx install pymcu
Usage
Import chip registers and HAL modules in your firmware source:
from pymcu.chips.atmega328p import PORTB, DDRB
from pymcu.types import uint8
from pymcu.hal.gpio import Pin
led = Pin("PB5", Pin.OUT)
while True:
led.toggle()
For ATtiny targets:
from pymcu.chips.attiny85 import PORTB, DDRB
from pymcu.types import uint8
from pymcu.hal.gpio import Pin
led = Pin("PB0", Pin.OUT)
while True:
led.toggle()
Note: These files are stubs. Running them directly with a standard Python interpreter will raise
RuntimeErrorif you attempt to access hardware registers — they lack the physical hardware interface and must be compiled with thepymcuctoolchain to run on a microcontroller.
Structure
lib/src/pymcu/
chips/ -- chip-specific register definitions
atmega328p.py
attiny85.py
attiny84.py
attiny2313.py
...
hal/ -- zero-cost hardware abstractions
gpio.py -- Pin (digital I/O)
uart.py -- UART
adc.py -- ADC
pwm.py -- PWM
spi.py -- SPI (hardware)
softspi.py -- SPI (bit-bang)
i2c.py -- I2C
eeprom.py -- EEPROM
watchdog.py -- Watchdog timer
power.py -- Sleep / power modes
_gpio/ -- chip-specific GPIO backend implementations
_uart/ -- chip-specific UART backend implementations
...
types.py -- ptr[T], uint8, uint16, int8, inline, const, asm, ...
math/ -- software math routines (division, etc.)
License
MIT License. See LICENSE for details.
Metadata
Release files for pymcu-stdlib 0.1.0b1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pymcu_stdlib-0.1.0b1-py3-none-any.whl | Python 3 | none | any | Details |
Release files / pymcu_stdlib-0.1.0b1-py3-none-any.whl
| Download URL | pymcu_stdlib-0.1.0b1-py3-none-any.whl |
|---|---|
| Size | 366.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9c63d640f9aa532bbc518838ba1eb216d17ff3bb03a83a0fa45932619e0e842
|
|
BLAKE2b-256 checksum How to use checksums |
5f0507447037843cfd383bb430823b9ab566ed48612d0da2030a61dd323d90e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 5, 2026.
Transparency logSecurity for pymcu-stdlib 0.1.0b1
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
All 1 file in this release has been uploaded with provenance metadata.
Attestation for pymcu_stdlib-0.1.0b1-py3-none-any.whl
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 5, 2026.
Transparency logA 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.