Skip to content

Commit a045f56

Browse files
committed
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>
1 parent 1295eec commit a045f56

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

tools/manifestfile.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,19 +250,28 @@ def include(self, manifest_path, **kwargs):
250250
)
251251
os.chdir(prev_cwd)
252252

253-
def require(self, name, version=None, **kwargs):
253+
def require(self, name, version=None, unix_ffi=False, **kwargs):
254254
"""
255255
Require a module by name from micropython-lib.
256256
257-
This is a shortcut for
257+
Optionally specify unix_ffi=True to use a module from the unix-ffi directory.
258258
"""
259259
if self._path_vars["MPY_LIB_DIR"]:
260-
for manifest_path in glob.glob(
261-
os.path.join(self._path_vars["MPY_LIB_DIR"], "**", name, "manifest.py"),
262-
recursive=True,
263-
):
264-
self.include(manifest_path, **kwargs)
265-
return
260+
lib_dirs = ["micropython", "python-stdlib", "python-ecosys"]
261+
if unix_ffi:
262+
# Search unix-ffi only if unix_ffi=True, and make unix-ffi modules
263+
# take precedence.
264+
lib_dirs = ["unix-ffi"] + lib_dirs
265+
266+
for lib_dir in lib_dirs:
267+
for manifest_path in glob.glob(
268+
os.path.join(
269+
self._path_vars["MPY_LIB_DIR"], lib_dir, "**", name, "manifest.py"
270+
),
271+
recursive=True,
272+
):
273+
self.include(manifest_path, **kwargs)
274+
return
266275
raise ValueError("Library not found in local micropython-lib: {}".format(name))
267276
else:
268277
# TODO: HTTP request to obtain URLs from manifest.json.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy