[libcamera-devel,v3,08/38] utils: ipc: add parser script

Message ID 20201002143154.468162-9-paul.elder@ideasonboard.com
State Superseded
Headers show
Series
  • IPA isolation implementation
Related show

Commit Message

Paul Elder Oct. 2, 2020, 2:31 p.m. UTC
On some systems, python2 might still be the default python. Enforce
python3 by wrapping the mojo parser script in a python3 script. This
also has the benefit of not modifying mojo.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
New in v3
---
 utils/ipc/parser.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100755 utils/ipc/parser.py

Comments

Laurent Pinchart Oct. 4, 2020, 8:49 a.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Fri, Oct 02, 2020 at 11:31:24PM +0900, Paul Elder wrote:
> On some systems, python2 might still be the default python. Enforce
> python3 by wrapping the mojo parser script in a python3 script. This
> also has the benefit of not modifying mojo.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

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

> ---
> New in v3
> ---
>  utils/ipc/parser.py | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>  create mode 100755 utils/ipc/parser.py
> 
> diff --git a/utils/ipc/parser.py b/utils/ipc/parser.py
> new file mode 100755
> index 00000000..f46820fa
> --- /dev/null
> +++ b/utils/ipc/parser.py
> @@ -0,0 +1,20 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright (C) 2020, Google Inc.
> +#
> +# Author: Paul Elder <paul.elder@ideasonboard.com>
> +#
> +# parser.py - Run mojo parser with python3
> +
> +import os
> +import sys
> +
> +# TODO set sys.pycache_prefix for >= python3.8
> +sys.dont_write_bytecode = True
> +
> +# Make sure that mojom_parser.py can import mojom
> +sys.path.append(f'{os.path.dirname(__file__)}/mojo/public/tools/mojom')
> +
> +import mojo.public.tools.mojom.mojom_parser as parser
> +
> +parser.Run(sys.argv[1:])

Patch

diff --git a/utils/ipc/parser.py b/utils/ipc/parser.py
new file mode 100755
index 00000000..f46820fa
--- /dev/null
+++ b/utils/ipc/parser.py
@@ -0,0 +1,20 @@ 
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (C) 2020, Google Inc.
+#
+# Author: Paul Elder <paul.elder@ideasonboard.com>
+#
+# parser.py - Run mojo parser with python3
+
+import os
+import sys
+
+# TODO set sys.pycache_prefix for >= python3.8
+sys.dont_write_bytecode = True
+
+# Make sure that mojom_parser.py can import mojom
+sys.path.append(f'{os.path.dirname(__file__)}/mojo/public/tools/mojom')
+
+import mojo.public.tools.mojom.mojom_parser as parser
+
+parser.Run(sys.argv[1:])