summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-08-11 00:16:48 +1000
committerJim Mussared <jim.mussared@gmail.com>2022-09-05 17:06:52 +1000
commitbc23f207cefed82172551288ebb8686ee2c512a3 (patch)
tree0c487facdf7e5704d7126b57a0632656b63bec8f
parente9a28ce312b75a4f2b3b7a8c3e38b7766cb567b3 (diff)
tools/manifestfile.py: Allow require() to specify unix packages.
By default, don't include micropython-lib/unix-ffi in the search. If unix_ffi=True is passed to require(), then include unix-ffi and make it take precedence over the other locations (e.g. python-stdlib). This does two things: - Prevents non-unix builds from using unix-only packages. - Allows the unix build to optionally use a more full-featured (e.g. ffi) based package, even with the same name as one from e.g. stdlib. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
-rw-r--r--tools/manifestfile.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/tools/manifestfile.py b/tools/manifestfile.py
index bf626c22b..61560e456 100644
--- a/tools/manifestfile.py
+++ b/tools/manifestfile.py
@@ -248,19 +248,28 @@ class ManifestFile:
)
os.chdir(prev_cwd)
- def require(self, name, version=None, **kwargs):
+ def require(self, name, version=None, unix_ffi=False, **kwargs):
"""
Require a module by name from micropython-lib.
- This is a shortcut for
+ Optionally specify unix_ffi=True to use a module from the unix-ffi directory.
"""
if self._path_vars["MPY_LIB_DIR"]:
- for manifest_path in glob.glob(
- os.path.join(self._path_vars["MPY_LIB_DIR"], "**", name, "manifest.py"),
- recursive=True,
- ):
- self.include(manifest_path, **kwargs)
- return
+ lib_dirs = ["micropython", "python-stdlib", "python-ecosys"]
+ if unix_ffi:
+ # Search unix-ffi only if unix_ffi=True, and make unix-ffi modules
+ # take precedence.
+ lib_dirs = ["unix-ffi"] + lib_dirs
+
+ for lib_dir in lib_dirs:
+ for manifest_path in glob.glob(
+ os.path.join(
+ self._path_vars["MPY_LIB_DIR"], lib_dir, "**", name, "manifest.py"
+ ),
+ recursive=True,
+ ):
+ self.include(manifest_path, **kwargs)
+ return
raise ValueError("Library not found in local micropython-lib: {}".format(name))
else:
# TODO: HTTP request to obtain URLs from manifest.json.