AminetAminet
Search:
85286 packages online
About
Recent
Browse
Search
Upload
Setup
Services

dev/lang/micropython.lha

Mirror:Random
Showing: ppc-amigaos icongeneric icon
No screenshot available
Short:MicroPython interpreter for Amiga68k
Author:Fabrice LABATUT
Uploader:fabrice labatut club-internet fr
Type:dev/lang
Version:1.28.0-build234
Architecture:m68k-amigaos >= 3.0
Date:2026-04-24
Requires:2 MB RAM (4 MB recommended for networking/TLS)
Replaces:dev/lang/micropython.lha
Distribution:Aminet
URL:https://github.com/OoZe1911/micropython-amiga-port
Download:dev/lang/micropython.lha - View contents
Readme:dev/lang/micropython.readme
Downloads:873

MicroPython for AmigaOS (m68k)
==============================

A port of MicroPython v1.28 (compatible Python 3.4) to AmigaOS,
targeting Motorola 68020+ processors. Runs on classic Amiga hardware
(A1200, A3000, A4000) and emulators (WinUAE, FS-UAE).

This port was developed by Fabrice with coding assistance from Claude
(Anthropic's AI), under Fabrice's direct supervision: architecture
decisions, implementation strategy, testing on real hardware/emulator,
and bug reports are all driven by Fabrice. Every change is reviewed
and validated before being committed.


Requirements
------------

  - AmigaOS 3.0 or higher
  - Motorola 68020 CPU or higher
  - 2 MB RAM minimum for simple scripts
  - 4 MB RAM recommended for networking and TLS
  - AmiSSL (optional, required for HTTPS/TLS support)


Usage
-----

  micropython                        ; interactive REPL
  micropython script.py              ; run a Python script
  micropython script.mpy             ; run precompiled bytecode
  micropython -c "print(2**32)"      ; run inline code
  micropython -m 512 script.py       ; run with 512 KB heap

The default heap size is 128 KB. Use -m to allocate more memory
(in KB). For example, downloading a web page may require 4 MB
of heap: micropython -m 4096 script.py

Press Ctrl-C at any time to interrupt a running script or a
time.sleep() call.


Features
--------

  - Full Python 3.4 compatibility (ROM_LEVEL_EVERYTHING):
    f-strings, set operations, OrderedDict, advanced slicing,
    descriptors, async/await, and more
  - Interactive REPL with readline support (cursor keys, history)
  - Script execution and inline code (-c option)
  - Configurable heap size (-m option)
  - Precompiled bytecode: import and execute .mpy files compiled
    with mpy-cross, either via import or directly from the command
    line (micropython script.mpy)
  - Ctrl-C (KeyboardInterrupt) support during script execution,
    loops, and time.sleep()
  - input() builtin for interactive user prompts
  - sys.stdin / sys.stdout / sys.stderr standard streams

  Modules included:
    re, json, math, struct, binascii, base64, time, datetime,
    random, hashlib (sha256), errno, platform, socket, ssl,
    urequests, deflate, gzip, zlib, zipfile, arexx, gc, sys, io

  File system support:
    Full open/read/write/close via VFS_POSIX. os.listdir,
    os.getcwd, os.chdir, os.mkdir, os.rmdir, os.remove,
    os.rename, os.stat, os.chmod, os.getprotect, os.setprotect,
    os.makedirs, os.walk, os.getenv, os.putenv, os.unsetenv,
    os.path with AmigaOS volume:path conventions.

  Networking:
    TCP/UDP sockets, DNS resolution via bsdsocket.library.
    HTTP client (urequests) with HTTP/1.1, chunked transfer
    encoding, gzip decompression.

  TLS/SSL (requires AmiSSL):
    HTTPS support via AmiSSL. The amissl.library must be
    installed on the Amiga. 4 MB RAM minimum is recommended
    when using TLS.

  ARexx IPC:
    Inter-process communication with AmigaOS applications via
    ARexx message ports. arexx.send() for one-shot commands,
    arexx.exists() to check port availability, arexx.ports()
    to list active ports, and arexx.Port() persistent client
    with context manager for efficient multi-command sessions.

  Intuition GUI:
    Native AmigaOS graphical requesters via the amiga.intuition
    module, using EasyRequestArgs() from intuition.library (ROM
    resident from Kickstart 2.0, so no external dependency).
    Three modal functions: easy_request() for generic dialogs
    with title, multi-line body and up to 8 custom buttons
    (returns the 0-based clicked index); auto_request() for
    yes/no confirmations with configurable labels (returns bool);
    message() for informational popups with a single configurable
    button. All strings are converted UTF-8 to Latin-1 for
    AmigaOS, and body text is passed through a fixed "%s" format
    to prevent printf injection. Requesters open on the Workbench
    screen and work identically from Shell or Workbench.

  Platform detection:
    platform.amiga_info() shows CPU, FPU, chipset, Kickstart
    version, and available memory.


AmigaOS Path Conventions
------------------------

AmigaOS uses ":" to separate volumes from paths and "/" for
subdirectories:

  >>> import os
  >>> os.getcwd()
  'DH0:Work'
  >>> os.path.join("DH0:", "work", "scripts")
  'DH0:work/scripts'
  >>> os.path.isabs("DH0:file.py")
  True


Release history
---------------

Build 234
---------

  - New module amiga.intuition: native AmigaOS graphical requesters
    exposed as a clean Python API. Implemented as a thin C wrapper
    around EasyRequestArgs() from intuition.library (ROM-resident
    from Kickstart 2.0, so no external library dependency). Three
    keyword-only modal functions are provided. easy_request(title,
    body, buttons) is the generic requester, supporting a title,
    a multi-line body (\n supported), and 1..8 custom buttons; it
    returns the 0-based index of the clicked button, left-to-right.
    auto_request(body, yes="Yes", no="No") is a shortcut for yes/no
    confirmations with configurable labels, returning True when the
    first button was clicked and False otherwise. message(body,
    button="OK") shows an informational popup with a single
    configurable button and returns None.
  - All three Intuition functions share a common C engine that
    converts UTF-8 input to Latin-1 for AmigaOS, passes body text
    through a fixed "%s" format to prevent printf injection.
    Requesters open on the Workbench screen and work identically
    whether the script is launched from the Shell or from Workbench.

Build 230
---------

  - Rebased on MicroPython 1.28 (released April 6, 2026), bringing
    in PEP 750 template strings (t-strings), nested f-strings, the
    new event waiting API (mp_event_wait_indefinite, mp_event_wait_ms,
    mp_event_handle_nowait), and various core fixes. The Amiga port
    patches were re-applied cleanly: mpstate_alignment, the iter_buf
    heap-allocation fix (13/13 sites), and the vfs_posix Latin-1
    conversion hook (3/3 sites). The only API adaptation needed was
    in amiga_mphal.c, where mp_handle_pending(true) becomes
    mp_handle_pending(MP_HANDLE_PENDING_CALLBACKS_AND_EXCEPTIONS) to
    match the new behaviour enum.
  - Critical fix: Ctrl-C during a blocking socket call no longer
    crashes the VM. Symptoms before the fix: pressing Ctrl-C while
    a script was waiting in accept(), recv(), connect() or any other
    blocking bsdsocket call (typically a webserver waiting for
    incoming connections) triggered an assertion in py/vm.c:1144
    ("sp[-1] == mp_const_none || mp_obj_is_exception_instance(sp[-1])")
    followed by abort(), leaking the entire MicroPython heap (~2 MB).
  - Fix: a new socket_raise_io_error() helper in modsocket.c
    consumes SIGBREAKF_CTRL_C with SetSignal() and raises
    KeyboardInterrupt directly instead of OSError when a break is
    detected. This keeps a single exception in flight at any time
    and ensures the KeyboardInterrupt remains visible to "except
    KeyboardInterrupt:" handlers in Python code (which would have
    been hidden by the OSError otherwise). Applied to all six
    blocking entry points: accept, connect, send, recv, sendto,
    recvfrom. The accept() case has additional handling to close
    the WinUAE fake fd before raising, avoiding a socket leak.

Build 227
---------

  - Full Latin-1 <-> UTF-8 round-trip for filenames and terminal
    output. AmigaOS filesystems store filenames in Latin-1
    (ISO-8859-1), while MicroPython internally validates strings
    as UTF-8. Without conversion, any filename containing accented
    characters (e, e, n, c, ...) caused UnicodeError in os.listdir(),
    open(), and friends, and accented characters from print() were
    rendered as garbage in the AmigaOS terminal.
  - Latin-1 -> UTF-8 conversion in os.listdir() and os.getcwd(): a
    new mp_obj_new_str_from_latin1() helper bypasses UTF-8 validation
    and properly maps codepoints 0x80-0xFF to 2-byte UTF-8 sequences,
    so listdir() now returns clean Python strings for any AmigaOS
    filename.
  - UTF-8 -> Latin-1 conversion in all path-taking os functions
    (open, stat, rename, remove, chmod, etc.) via a shared
    amiga_utf8_to_latin1() helper. The conversion is transparent
    to the user: you can write open("Pequeno.txt") in your script
    and the underlying AmigaOS call receives the correct Latin-1
    bytes.
  - Terminal output: mp_hal_stdout_tx_strn() now converts UTF-8
    to Latin-1 before writing to the console, so print("Pequeno")
    or repr() of a Latin-1 filename displays correctly on the
    AmigaOS shell instead of showing multi-byte garbage.
  - VFS POSIX integration: added a new MICROPY_VFS_POSIX_CONVERT_PATH
    hook in vfs_posix.c and vfs_posix_file.c so that open() calls
    going through the VFS layer also benefit from the conversion.
    Patches to the shared extmod files are kept as .patch files in
    ports/amiga/patches/, consistent with the existing
    mpstate_alignment.patch approach.
  - Enabled MICROPY_PY_OS_DUPTERM to redirect VFS POSIX stdout/stderr
    through mphal, which is necessary because print() goes through
    the VFS write path rather than mp_hal_stdout_tx_strn() directly.

Build 219
---------

  - Critical fix: force heap allocation for iterators on m68k.
    The mp_obj_iter_buf_t struct on the C stack was misaligned on
    68k, causing "object isn't an iterator" crashes on for loops,
    the 'in' operator, list comprehensions, unpacking, and builtins
    like sum(), min(), max(), sorted(), etc. Fixed in 13 locations
    across 7 core MicroPython files.
  - Fix: ARexx WaitPort is now interruptible by Ctrl-C. Previously,
    arexx.send() would hang indefinitely if the target application
    did not reply. Now waits with SIGBREAKF_CTRL_C and raises
    KeyboardInterrupt after the reply is safely received.
  - Fix: avoid double close(fd) in SSLSocket.__del__. The fd is
    owned by the underlying Python socket; closing it twice could
    corrupt the libnix fd table.
  - Fix: avoid double inet_ntoa() call in same expression. The
    static buffer was overwritten between calls, causing incorrect
    addresses in socket_accept(), socket_recvfrom(), and
    mod_getaddrinfo().
  - Fix: cache timezone offset from locale.library instead of
    opening/closing the library on every localtime()/strftime() call.
  - Fix: close ARexx library in crash handlers (nlr_jump_fail,
    __assert_func) to prevent resource leaks on fatal errors.
  - Use _exit() consistently in all exit/crash paths.

Build 209
---------

  - os.getenv(), os.putenv(), os.unsetenv(): environment variable
    management via AmigaOS GetVar/SetVar/DeleteVar
  - zlib module: CPython-compatible compress, decompress, crc32
  - zipfile module: read/write ZIP archives (stored + deflated),
    CRC32 verification, extractall support
  - Timezone support: time.localtime() now returns local time
    using the timezone offset from AmigaOS locale.library
    (loc_GMTOffset). time.gmtime() returns UTC.
  - datetime.strftime(): format datetime objects with standard
    format codes (%Y, %m, %d, %H, %M, %S, %A, %a, %B, %b,
    %I, %p, %j, %f, %y, %%)
  - time.strftime(): format time tuples with the same codes,
    implemented in C via MICROPY_PY_TIME_INCLUDEFILE
  - datetime.now() returns microseconds (1/50s resolution)
  - input() builtin: interactive user input with proper raw/cooked
    console mode switching
  - sys.stdin, sys.stdout, sys.stderr: standard I/O streams
  - os.chmod() now accepts Unix-style permission modes (0o755,
    0o666, etc.) and converts them to AmigaOS protection bits
    automatically. os.setprotect()/os.getprotect() remain
    available for direct access to AmigaOS native bits.
  - os.stat() st_mode now reflects real file permissions
    (converted from AmigaOS fib_Protection)
  - sys.path[0] is set to the script's directory when running
    a script, matching CPython behavior for relative imports

Build 186
---------

  - ARexx IPC module: send commands to and communicate with any
    ARexx-aware application (IBrowse, Directory Opus, etc.)
  - os.chmod(): set AmigaOS file protection flags
  - os.getprotect(): read AmigaOS file protection flags
  - Ctrl-C support: KeyboardInterrupt now works during script
    execution, loops, and time.sleep() calls
  - Direct .mpy execution: run precompiled bytecode files from
    the command line (micropython script.mpy)
  - Import .mpy files: precompiled bytecode modules can be
    imported alongside regular .py modules

Build 169
---------

  - Initial release of this port


Known Limitations
-----------------

  - time.ticks_ms() returns 0 (no high-res timer yet)
  - hashlib only supports SHA256
  - Sockets are always blocking
  - No multithreading
  - re module: {n} quantifiers are not supported (use explicit
    repeated characters instead, e.g. "..." instead of ".{3}")


Source Code
-----------

The full source code is available on GitHub:
https://github.com/OoZe1911/micropython-amiga-port

Latest build can be downloadded here :
https://github.com/OoZe1911/micropython-amiga-port/blob/main/ports/amiga/build/micropython


License
-------

MicroPython is licensed under the MIT License.


Contents of dev/lang/micropython.lha
 PERMSSN    UID  GID    PACKED    SIZE  RATIO METHOD CRC     STAMP          NAME
---------- ----------- ------- ------- ------ ---------- ------------ -------------
[Amiga]                   1171    1484  78.9% -lh5- 78b3 Apr  7 10:06 micropython.info
[Amiga]                 226084  421848  53.6% -lh5- e34e Apr 23 17:38 micropython/micropython
[Amiga]                   6055   13701  44.2% -lh5- ca1a Apr 23 18:37 micropython/micropython.readme
[Amiga]                   1171    1484  78.9% -lh5- 7b3b Apr  7 10:06 micropython/samples.info
[Amiga]                  11089   38378  28.9% -lh5- 26dd Apr 14 10:38 micropython/samples/aminet_tools.py
[Amiga]                   4606   14847  31.0% -lh5- 5d0f Apr  9 11:18 micropython/samples/chat_claude.py
[Amiga]                   3339   10612  31.5% -lh5- 77eb Apr  7 17:07 micropython/samples/diff_view.py
[Amiga]                   4386   14182  30.9% -lh5- f9d4 Apr 13 16:05 micropython/samples/http_util.py
[Amiga]                    937    2268  41.3% -lh5- de1b Apr  7 15:54 micropython/samples/launch_ibrowse.py
[Amiga]                   2619    5944  44.1% -lh5- 1ce9 Apr  9 15:13 micropython/samples/samples.readme
[Amiga]                   5952   20166  29.5% -lh5- ce21 Apr  7 15:22 micropython/samples/webserver.py
[Amiga]                    691    1535  45.0% -lh5- b3b4 Apr 13 16:05 micropython/samples/wget.py
---------- ----------- ------- ------- ------ ---------- ------------ -------------
 Total        12 files  268100  546449  49.1%            Apr 24 00:53
Page generated in 0.02 seconds
Aminet © 1992-2024 Urban Müller and the Aminet team. Aminet contact address: <aminetaminet net>