Metadata-Version: 2.4
Name: upysm
Version: 0.4.1
Summary: MicroPython distribution package for pysm
Home-page: https://github.com/pgularski/upysm
Author: Piotr Gularski
Author-email: piotr.gularski@gmail.com
License: MIT
Project-URL: Source library, https://github.com/pgularski/pysm
Keywords: finite state machine automaton fsm hsm pda micropython
Classifier: Development Status :: 3 - Alpha
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: MicroPython
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Telecommunications Industry
Classifier: Natural Language :: English
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: micropython-collections.deque
Requires-Dist: micropython-collections.defaultdict
Requires-Dist: micropython-logging
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# upysm

`upysm` is the MicroPython distribution channel for
[`pysm`](https://github.com/pgularski/pysm), a finite state machine library.

Use `pysm` directly on regular Python. Use `upysm` when installing the same
library on MicroPython.

The library source still belongs to `pysm`. `upysm` is not a fork and does not
carry separate application code; it publishes MicroPython install artifacts
from selected `pysm` releases.

## Install on MicroPython

Modern `mip`/`mpremote` install:

```bash
mpremote mip install https://pgularski.github.io/upysm/
```

Pin a specific version when you want repeatable device builds:

```bash
mpremote mip install https://pgularski.github.io/upysm/0.4.0/
```

From the MicroPython REPL:

```python
import mip
mip.install('https://pgularski.github.io/upysm/')
```

Legacy `upip` install:

```python
import upip
upip.install('upysm')
```

The installed package imports as `pysm`, because the API is the upstream
library API:

```python
from pysm import Event, State, StateMachine
```

## Example

```python
from pysm import Event, State, StateMachine

on = State('on')
off = State('off')

sm = StateMachine('sm')
sm.add_state(on, initial=True)
sm.add_state(off)
sm.add_transition(on, off, events=['off'])
sm.add_transition(off, on, events=['on'])
sm.initialize()

assert sm.state == on
sm.dispatch(Event('off'))
assert sm.state == off
sm.dispatch(Event('on'))
assert sm.state == on
```

For the full API, see the
[`pysm` documentation](http://pysm.readthedocs.io/).

Maintainer release notes live in [RELEASING.md](RELEASING.md).
