get_mpy
¶
Collect modules and python stubs from MicroPython source projects (v1.12 +) and stores them in the all_stubs folder The all_stubs folder should be mapped/symlinked to the micropython_stubs/stubs repo/folder
Module Contents¶
Functions¶
|
|
|
|
|
Freeze the input, automatically determining its type. A .py script |
|
copy the to-be-frozen module to the destination folder to be stubbed |
|
Include another manifest. |
|
Perform variable substitution in path |
|
get and parse the to-be-frozen .py modules for micropython to extract the static type information |
|
get and parse the to-be-frozen .py modules for micropython to extract the static type information |
|
get path to port and board names from a path |
|
get and parse the to-be-frozen .py modules for micropython to extract the static type information |
Attributes¶
- get_mpy.log¶
- get_mpy.FAMILY = micropython¶
- get_mpy.path_vars¶
- get_mpy.stub_dir¶
- exception get_mpy.FreezeError¶
Bases:
Exception
Common base class for all non-exit exceptions.
- get_mpy.freeze_as_mpy(path, script=None, opt=0)¶
- get_mpy.freeze_as_str(path)¶
- get_mpy.freeze(path, script=None, opt=0)¶
Freeze the input, automatically determining its type. A .py script will be compiled to a .mpy first then frozen, and a .mpy file will be frozen directly.
path must be a directory, which is the base directory to search for files from. When importing the resulting frozen modules, the name of the module will start after path, ie path is excluded from the module name.
If path is relative, it is resolved to the current manifest.py. Use $(MPY_DIR), $(MPY_LIB_DIR), $(PORT_DIR), $(BOARD_DIR) if you need to access specific paths.
If script is None all files in path will be frozen.
If script is an iterable then freeze() is called on all items of the iterable (with the same path and opt passed through).
If script is a string then it specifies the filename to freeze, and can include extra directories before the file. The file will be searched for in path.
opt is the optimisation level to pass to mpy-cross when compiling .py to .mpy. (ignored in this implementation)
- get_mpy.freezedry(path, script)¶
copy the to-be-frozen module to the destination folder to be stubbed
- get_mpy.include(manifest)¶
Include another manifest.
The manifest argument can be a string (filename) or an iterable of strings.
Relative paths are resolved with respect to the current manifest file.
- get_mpy.convert_path(path)¶
Perform variable substitution in path
- get_mpy.get_frozen(stub_path: str, version: str, mpy_path: str = None, lib_path: str = None)¶
- get and parse the to-be-frozen .py modules for micropython to extract the static type information
requires that the MicroPython and Micropython-lib repos are checked out and available on a local path
repos should be cloned side-by-side as some of the manifests refer to micropython-lib scripts using a relative path
- Parameters
stub_path (str) –
version (str) –
mpy_path (str) –
lib_path (str) –
- get_mpy.get_frozen_folders(stub_path: str, mpy_path: str, lib_path: str, version: str)¶
get and parse the to-be-frozen .py modules for micropython to extract the static type information locates the to-be-frozen files in modules folders - ‘ports/<port>/modules/*.py’ - ‘ports/<port>/boards/<board>/modules/*.py’
- Parameters
stub_path (str) –
mpy_path (str) –
lib_path (str) –
version (str) –
- get_mpy.get_target_names(path: str) tuple ¶
get path to port and board names from a path
- Parameters
path (str) –
- Return type
tuple
- get_mpy.get_frozen_manifest(manifests, stub_path: str, mpy_path: str, lib_path: str, version: str)¶
get and parse the to-be-frozen .py modules for micropython to extract the static type information locates the to-be-frozen files through the manifest.py introduced in MicroPython 1.12 - manifest.py is used for board specific and daily builds - manifest_release.py is used for the release builds
- Parameters
stub_path (str) –
mpy_path (str) –
lib_path (str) –
version (str) –
- get_mpy.mpy_path = ./micropython¶