Skip to main content

micropython-env

Simple environment variable loader for MicroPython board.

The loader could load environment variables from the one of file format as below:

  • JSON (default) : The file name is "env.json" (text mode).
  • MessagePack: The file name is "env" or "env.msgpack" (binary mode).

MessagePack

Note:

  • MessagePack Array corresponds to Python Tuple, not List

Change in v0.2.0

MessagePack predefined extension types:

Name Type Support?
Timestamp -1 X

MessagePack application-specific extension types:

Name Type Support? Description
List 1 O Python List, legth limit: 65535.
New in v0.2.0

How to Use

from mpy_env import load_env, get_env, put_env

# Loading `env.json` at once as default.
# You can invoke below function in `boot.py`
load_env()
# or
load_env(0)

# You can loading environment variables from MessagePack as below.
load_env(1)

# In `main.py` or the other,
# You can invoke below function to get environment variable.
get_env('key')

# You can invoke below function to set environment variable in-memory.
put_env('tuple', ('a', 1))

Testing

Currentl testing environment:

  • Python 3.7
  • MicroPython unix port 1.12 & 1.13
  • MicroPython esp32 port 1.12& 1.13

Before tesing, you need to compile Micopython unix port executable first, see offcial GitHub Wiki to setup.

After setup, you must set environment variable MPY_PATH as path of local MicroPython repository.

Environment variableMPY_PATH is used in shell script bin/build_micropython.sh

We use mpfshell to interactive with MicroPython board, please install the latest release from PyPi.

pip install mpfshell

We use offcial MessagePack package to validate custom msgpack module, please install the latest release from PyPi.

pip install msgpack

Next, clone the repository to your local machine.

git clone https://github.com/ShenTengTu/micropython-env.git
cd micropython-env

You can execute the follow command to build muitiple versions of MicroPython unix port.

export MPY_PATH=<local_micropython_repo> && make build-mpy

It will create symbolic links into user binaries directory after building.

To test on Python & MicroPython unix port, execute the command as below.

make testing 

It will run testing on multiple MicroPython unix port versions.

To test on ESP32 board, execute the follow command.

make mpy-testing-esp32

It will run testing on multiple MicroPython esp32 port versions.

Development

See "Development guide" in CONTRIBUTING.md.

Release files for micropython-mpy-env 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for micropython-mpy-env 0.2.0
File Size Uploaded
micropython-mpy-env-0.2.0.tar.gz 7.0 kB Details

Release files / micropython-mpy-env-0.2.0.tar.gz

Download URL micropython-mpy-env-0.2.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
124a3e69e621dbc03ef22d9aee99b5961dc5b3bd3296a0d70d64ae0fd346cfe8
BLAKE2b-256 checksum
How to use checksums
63c9eeb7bdad09576530443af5ca5af24060ab87e7462727e15b45febab36f92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page