Re: [PATCH 1/5] tools: ynl: move python code to separate sub-directory

From: Donald Hunter
Date: Tue Dec 03 2024 - 15:57:10 EST


On Tue, 3 Dec 2024 at 09:27, Jan Stancek <jstancek@xxxxxxxxxx> wrote:
>
> Move python code to a separate directory so it can be
> packaged as a python module.
>
> Signed-off-by: Jan Stancek <jstancek@xxxxxxxxxx>
> ---
> tools/net/ynl/Makefile | 1 +
> tools/net/ynl/generated/Makefile | 2 +-
> tools/net/ynl/lib/.gitignore | 1 -
> tools/net/ynl/lib/Makefile | 1 -
> tools/net/ynl/pyynl/__init__.py | 0
> tools/net/ynl/{ => pyynl}/cli.py | 0

Perhaps we could have a symlink to cli.py from the original location
for compatibility with existing in-place usage. Same for ethtool.py
and other user-facing scripts.

> tools/net/ynl/{ => pyynl}/ethtool.py | 0
> tools/net/ynl/pyynl/lib/.gitignore | 1 +
> tools/net/ynl/{ => pyynl}/lib/__init__.py | 0
> tools/net/ynl/{ => pyynl}/lib/nlspec.py | 0
> tools/net/ynl/{ => pyynl}/lib/ynl.py | 0
> tools/net/ynl/{ => pyynl}/ynl-gen-c.py | 0
> tools/net/ynl/{ => pyynl}/ynl-gen-rst.py | 0

The documentation build depends on this location. This patch is
required to fix it:

diff --git a/Documentation/Makefile b/Documentation/Makefile
index fa71602ec961..52c6c5a3efa9 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -104,7 +104,7 @@ quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath
$(BUILDDIR)/$3/$4)
YNL_INDEX:=$(srctree)/Documentation/networking/netlink_spec/index.rst
YNL_RST_DIR:=$(srctree)/Documentation/networking/netlink_spec
YNL_YAML_DIR:=$(srctree)/Documentation/netlink/specs
-YNL_TOOL:=$(srctree)/tools/net/ynl/ynl-gen-rst.py
+YNL_TOOL:=$(srctree)/tools/net/ynl/pyynl/ynl_gen_rst.py

YNL_RST_FILES_TMP := $(patsubst %.yaml,%.rst,$(wildcard
$(YNL_YAML_DIR)/*.yaml))
YNL_RST_FILES := $(patsubst $(YNL_YAML_DIR)%,$(YNL_RST_DIR)%,
$(YNL_RST_FILES_TMP))