[libcamera-devel] [PATCH v1] utils: ipc: Add __init__.py for local module utils/ipc/generators

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Jan 26 23:35:03 CET 2022


Hi Han-Lin,

Thank you for the patch.

On Thu, Jan 27, 2022 at 02:18:07AM +0800, Han-Lin Chen wrote:
> It's to fix build errors with mojom in ChromeOS chroot. The reason is that
> ChromeOS recently moves native mojom generators module into site-packages,
> which has higher import precedence than the local namespace package and shadows
> the local package of the same. Add __init__.py to make it an explicit package
> to avoid shadowing.
> 
> Signed-off-by: Han-Lin Chen <hanlinchen at chromium.org>

That's interesting. It led me to try and understand how python searches
for modules. A directory with an __init__.py file is considered to be a
regular package, while a directory without such a file is a namespace
package. The same search order is used for both, but namespace packages
are only considered if no regular package can be found. This is
described in https://www.python.org/dev/peps/pep-0420/#specification.

Tested-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

> ---
>  utils/ipc/generators/__init__.py | 0
>  1 file changed, 0 insertions(+), 0 deletions(-)
>  create mode 100644 utils/ipc/generators/__init__.py
> 
> diff --git a/utils/ipc/generators/__init__.py b/utils/ipc/generators/__init__.py
> new file mode 100644
> index 00000000..e69de29b

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list