Metadata-Version: 2.4
Name: upysm
Version: 0.4.0
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 publishing wrapper for
[`pysm`](https://github.com/pgularski/pysm). It does not maintain a fork of the
library source. A release build fetches the selected `pysm` source
distribution, copies the MicroPython package files into a temporary staging
tree, and publishes matching `upip` and `mip` artifacts with the same version
number.

## Build

Install the release tools:

```bash
python3 -m pip install -r requirements.txt
```

Build the latest published `pysm` release:

```bash
python3 -m scripts.build_upysm --pysm-version latest --check --smoke
```

Build a selected version:

```bash
python3 -m scripts.build_upysm --pysm-version 0.4.0 --check --smoke
```

The default `core` package profile copies only `pysm/__init__.py`,
`pysm/pysm.py`, and `pysm/version.py`, which keeps the device package aligned
with the small MicroPython runtime. Use `--package-profile all` to copy every
Python module from the selected `pysm` package.

The build writes two install shapes:

```text
dist/upysm-<version>.tar.gz  # PyPI/upip source distribution
site/                        # static mip package tree for GitHub Pages
```

## Publish

Publishing is handled by the `Publish` GitHub Actions workflow. Run it
manually, select `latest` or an explicit `pysm` version, and the workflow will
build, check, smoke test, publish the matching `upysm` sdist to PyPI using
trusted publishing, and publish the `mip` package tree to the `gh-pages`
branch.

Configure GitHub Pages once to serve the `gh-pages` branch from `/`.

For a local upload:

```bash
python3 -m scripts.build_upysm --pysm-version 0.4.0 --check
python3 -m twine upload dist/upysm-0.4.0.tar.gz
```

## Install on MicroPython

Modern `mip`/`mpremote` install:

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

From the REPL:

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

Legacy `upip` install:

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

## Smoke 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 full API docs, see the
[`pysm` documentation](http://pysm.readthedocs.io/).
