stubber.makemanifest_2

Classes and functions copied & adapted from micropypythons makemanifest.py to ensure that the manifest.py files can be processed

Module Contents

Classes

IncludeOptions

Functions

freeze_as_mpy(path, script=None, opt=0)

freeze_as_str(path)

freeze_mpy(path, script=None, opt=0)

Freeze the input (see above), which must be .mpy files that are

freeze(path, script=None, opt=0)

Freeze the input, automatically determining its type. A .py script

include(manifest, **kwargs)

Include another manifest.

convert_path(path: str) → str

Perform variable substitution in path

freeze_internal(path: str, script: str, opt=None)

Copy the to-be-frozen module to the destination folder to be stubbed.

Attributes

log

path_vars

stub_dir

stubber.makemanifest_2.log
stubber.makemanifest_2.path_vars
exception stubber.makemanifest_2.FreezeError

Bases: Exception

Common base class for all non-exit exceptions.

class stubber.makemanifest_2.IncludeOptions(**kwargs)
defaults(self, **kwargs)
__getattr__(self, name)
stubber.makemanifest_2.freeze_as_mpy(path, script=None, opt=0)
stubber.makemanifest_2.freeze_as_str(path)
stubber.makemanifest_2.freeze_mpy(path, script=None, opt=0)

Freeze the input (see above), which must be .mpy files that are frozen directly.

stubber.makemanifest_2.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)

stubber.makemanifest_2.include(manifest, **kwargs)

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.

Optional kwargs can be provided which will be available to the included script via the options variable.

e.g. include(“path.py”, extra_features=True)

in path.py:

options.defaults(standard_features=True)

# freeze minimal modules. if options.standard_features:

# freeze standard modules.

if options.extra_features:

# freeze extra modules.

stubber.makemanifest_2.convert_path(path: str) str

Perform variable substitution in path

Parameters

path (str) –

Return type

str

stubber.makemanifest_2.stub_dir :str =
stubber.makemanifest_2.freeze_internal(path: str, script: str, opt=None)

Copy the to-be-frozen module to the destination folder to be stubbed.

Parameters: path (str) : the source path script (str): the source script to be frozen opt (Any): freeze option (ignored)

Parameters
  • path (str) –

  • script (str) –