[libcamera-devel,v1] utils: ipc: Add __init__.py for local module utils/ipc/generators
diff mbox series

Message ID 20220126181807.3022258-1-hanlinchen@chromium.org
State Accepted
Commit 7ea52d2b586144fdc033a3ffc1c4a4bbb99b5440
Headers show
Series
  • [libcamera-devel,v1] utils: ipc: Add __init__.py for local module utils/ipc/generators
Related show

Commit Message

Hanlin Chen Jan. 26, 2022, 6:18 p.m. UTC
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@chromium.org>
---
 utils/ipc/generators/__init__.py | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 utils/ipc/generators/__init__.py

Comments

Laurent Pinchart Jan. 26, 2022, 10:35 p.m. UTC | #1
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@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@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@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
Paul Elder Jan. 27, 2022, 3:55 a.m. UTC | #2
Hi Han-Lin,

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@chromium.org>

Reviewed-by: Paul ELder <paul.elder@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
> -- 
> 2.35.0.rc0.227.g00780c9af4-goog
>

Patch
diff mbox series

diff --git a/utils/ipc/generators/__init__.py b/utils/ipc/generators/__init__.py
new file mode 100644
index 00000000..e69de29b