stubber.tools.manifestfile

Module Contents

Classes

ManifestFile

exception stubber.tools.manifestfile.ManifestFileError

Bases: Exception

Common base class for all non-exit exceptions.

class stubber.tools.manifestfile.ManifestFile(mode, path_vars=None)
_resolve_path(path)
_manifest_globals(kwargs)
files()
pypi_dependencies()
execute(manifest_file)
_add_file(full_path, target_path, kind=KIND_AUTO, opt=None)
metadata(**kwargs)

From within a manifest file, use this to set the metadata for the package described by current manifest.

After executing a manifest file (via execute()), call this to obtain the metadata for the top-level manifest file.

See ManifestPackageMetadata.update() for valid kwargs.

include(manifest_path, is_require=False, **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.

If the path is to a directory, then it implicitly includes the manifest.py file inside that directory.

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.

require(name, version=None, unix_ffi=False, pypi=None, **kwargs)

Require a module by name from micropython-lib.

Optionally specify unix_ffi=True to use a module from the unix-ffi directory.

Optionally specify pipy=”package-name” to indicate that this should use the named package from PyPI when building for CPython.

package(package_path, files=None, base_path='.', opt=None)

Define a package, optionally restricting to a set of files.

Simple case, a package in the current directory:

package(“foo”)

will include all .py files in foo, and will be stored as foo/bar/baz.py.

If the package isn’t in the current directory, use base_path:

package(“foo”, base_path=”src”)

To restrict to certain files in the package use files (note: paths should be relative to the package):

package(“foo”, files=[“bar/baz.py”])

module(module_path, base_path='.', opt=None)

Include a single Python file as a module.

If the file is in the current directory:

module(“foo.py”)

Otherwise use base_path to locate the file:

module(“foo.py”, “src/drivers”)

_freeze_internal(path, script, exts, kind, opt)
freeze(path, script=None, opt=None)

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 file or directory to freeze, and can include extra directories before the file or last directory. The file or directory will be _searched for in path. If script is a directory then all files in that directory will be frozen.

opt is the optimisation level to pass to mpy-cross when compiling .py to .mpy.

freeze_as_str(path)

Freeze the given path and all .py scripts within it as a string, which will be compiled upon import.

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

Freeze the input (see above) by first compiling the .py scripts to .mpy files, then freezing the resulting .mpy files.

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

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