diff mbox series

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

Message ID 20b2bdfe94fed5b9694e22c79c79858502f5e014.1733216767.git.jstancek@redhat.com (mailing list archive)
State Superseded
Headers show
Series tools: ynl: add install target | expand

Checks

Context Check Description
netdev/series_format warning Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools fail Errors and warnings before: 0 (+22) this patch: 0 (+23)
netdev/cc_maintainers warning 4 maintainers not CCed: rrameshbabu@nvidia.com jiri@resnulli.us almasrymina@google.com dtatulea@nvidia.com
netdev/build_clang success Errors and warnings before: 4 this patch: 4
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 308 this patch: 308
netdev/checkpatch warning WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-12-03--15-00 (tests: 760)

Commit Message

Jan Stancek Dec. 3, 2024, 9:27 a.m. UTC
Move python code to a separate directory so it can be
packaged as a python module.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 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
 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
 tools/net/ynl/ynl-regen.sh                | 2 +-
 14 files changed, 4 insertions(+), 4 deletions(-)
 create mode 100644 tools/net/ynl/pyynl/__init__.py
 rename tools/net/ynl/{ => pyynl}/cli.py (100%)
 rename tools/net/ynl/{ => pyynl}/ethtool.py (100%)
 create mode 100644 tools/net/ynl/pyynl/lib/.gitignore
 rename tools/net/ynl/{ => pyynl}/lib/__init__.py (100%)
 rename tools/net/ynl/{ => pyynl}/lib/nlspec.py (100%)
 rename tools/net/ynl/{ => pyynl}/lib/ynl.py (100%)
 rename tools/net/ynl/{ => pyynl}/ynl-gen-c.py (100%)
 rename tools/net/ynl/{ => pyynl}/ynl-gen-rst.py (100%)

Comments

Stanislav Fomichev Dec. 3, 2024, 4:52 p.m. UTC | #1
On 12/03, Jan Stancek wrote:
> Move python code to a separate directory so it can be
> packaged as a python module.

There is a bunch of selftests that depend on this location:

make -C tools/testing/selftests TARGETS="drivers/net" TEST_PROGS=ping.py TTEST_GEN_PROGS="" run_tests
make: Entering directory '/home/virtme/testing-18/tools/testing/selftests'
make[1]: Entering directory '/home/virtme/testing-18/tools/testing/selftests/drivers/net'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/virtme/testing-18/tools/testing/selftests/drivers/net'
make[1]: Entering directory '/home/virtme/testing-18/tools/testing/selftests/drivers/net'
TAP version 13
1..1
# overriding timeout to 90
# selftests: drivers/net: ping.py
# Traceback (most recent call last):
#   File "/home/virtme/testing-18/tools/testing/selftests/drivers/net/./ping.py", line 4, in <module>
#     from lib.py import ksft_run, ksft_exit
#   File "/home/virtme/testing-18/tools/testing/selftests/drivers/net/lib/py/__init__.py", line 10, in <module>
#     from net.lib.py import *
#   File "/home/virtme/testing-18/tools/testing/selftests/net/lib/py/__init__.py", line 8, in <module>
#     from .ynl import NlError, YnlFamily, EthtoolFamily, NetdevFamily, RtnlFamily
#   File "/home/virtme/testing-18/tools/testing/selftests/net/lib/py/ynl.py", line 23, in <module>
#     from net.ynl.lib import YnlFamily, NlError
# ImportError: cannot import name 'YnlFamily' from 'net.ynl.lib' (unknown location)
not ok 1 selftests: drivers/net: ping.py # exit=1
make[1]: Leaving directory '/home/virtme/testing-18/tools/testing/selftests/drivers/net'
make: Leaving directory '/home/virtme/testing-18/tools/testing/selftests'
xx__-> echo $?
0
xx__-> echo scan > /sys/kernel/debug/kmemleak && cat /sys/kernel/debug/kmemleak
xx__-> 

---
pw-bot: cr
Donald Hunter Dec. 3, 2024, 7:50 p.m. UTC | #2
On Tue, 3 Dec 2024 at 09:27, Jan Stancek <jstancek@redhat.com> wrote:
>
> Move python code to a separate directory so it can be
> packaged as a python module.
>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
> ---
>  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))
Jan Stancek Dec. 4, 2024, 2:53 p.m. UTC | #3
On Tue, Dec 3, 2024 at 5:52 PM Stanislav Fomichev <stfomichev@gmail.com> wrote:
>
> On 12/03, Jan Stancek wrote:
> > Move python code to a separate directory so it can be
> > packaged as a python module.
>
> There is a bunch of selftests that depend on this location:

Sorry about that, I haven't realized other places it's already used at.

> 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.

I can add those, but I'd still update docs references with new path.

Thanks,
Jan
diff mbox series

Patch

diff --git a/tools/net/ynl/Makefile b/tools/net/ynl/Makefile
index d1cdf2a8f826..617b405d9ef8 100644
--- a/tools/net/ynl/Makefile
+++ b/tools/net/ynl/Makefile
@@ -21,5 +21,6 @@  clean distclean:
 		fi \
 	done
 	rm -f libynl.a
+	rm -rf pyynl/lib/__pycache__
 
 .PHONY: all clean distclean $(SUBDIRS)
diff --git a/tools/net/ynl/generated/Makefile b/tools/net/ynl/generated/Makefile
index 7db5240de58a..36519ea2792a 100644
--- a/tools/net/ynl/generated/Makefile
+++ b/tools/net/ynl/generated/Makefile
@@ -12,7 +12,7 @@  include ../Makefile.deps
 YNL_GEN_ARG_ethtool:=--user-header linux/ethtool_netlink.h \
 	--exclude-op stats-get
 
-TOOL:=../ynl-gen-c.py
+TOOL:=../pyynl/ynl-gen-c.py
 
 GENS_PATHS=$(shell grep -nrI --files-without-match \
 		'protocol: netlink' \
diff --git a/tools/net/ynl/lib/.gitignore b/tools/net/ynl/lib/.gitignore
index 296c4035dbf2..a4383358ec72 100644
--- a/tools/net/ynl/lib/.gitignore
+++ b/tools/net/ynl/lib/.gitignore
@@ -1,2 +1 @@ 
-__pycache__/
 *.d
diff --git a/tools/net/ynl/lib/Makefile b/tools/net/ynl/lib/Makefile
index 94c49cca3dca..4b2b98704ff9 100644
--- a/tools/net/ynl/lib/Makefile
+++ b/tools/net/ynl/lib/Makefile
@@ -19,7 +19,6 @@  ynl.a: $(OBJS)
 
 clean:
 	rm -f *.o *.d *~
-	rm -rf __pycache__
 
 distclean: clean
 	rm -f *.a
diff --git a/tools/net/ynl/pyynl/__init__.py b/tools/net/ynl/pyynl/__init__.py
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/tools/net/ynl/cli.py b/tools/net/ynl/pyynl/cli.py
similarity index 100%
rename from tools/net/ynl/cli.py
rename to tools/net/ynl/pyynl/cli.py
diff --git a/tools/net/ynl/ethtool.py b/tools/net/ynl/pyynl/ethtool.py
similarity index 100%
rename from tools/net/ynl/ethtool.py
rename to tools/net/ynl/pyynl/ethtool.py
diff --git a/tools/net/ynl/pyynl/lib/.gitignore b/tools/net/ynl/pyynl/lib/.gitignore
new file mode 100644
index 000000000000..c18dd8d83cee
--- /dev/null
+++ b/tools/net/ynl/pyynl/lib/.gitignore
@@ -0,0 +1 @@ 
+__pycache__/
diff --git a/tools/net/ynl/lib/__init__.py b/tools/net/ynl/pyynl/lib/__init__.py
similarity index 100%
rename from tools/net/ynl/lib/__init__.py
rename to tools/net/ynl/pyynl/lib/__init__.py
diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/pyynl/lib/nlspec.py
similarity index 100%
rename from tools/net/ynl/lib/nlspec.py
rename to tools/net/ynl/pyynl/lib/nlspec.py
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/pyynl/lib/ynl.py
similarity index 100%
rename from tools/net/ynl/lib/ynl.py
rename to tools/net/ynl/pyynl/lib/ynl.py
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/pyynl/ynl-gen-c.py
similarity index 100%
rename from tools/net/ynl/ynl-gen-c.py
rename to tools/net/ynl/pyynl/ynl-gen-c.py
diff --git a/tools/net/ynl/ynl-gen-rst.py b/tools/net/ynl/pyynl/ynl-gen-rst.py
similarity index 100%
rename from tools/net/ynl/ynl-gen-rst.py
rename to tools/net/ynl/pyynl/ynl-gen-rst.py
diff --git a/tools/net/ynl/ynl-regen.sh b/tools/net/ynl/ynl-regen.sh
index a37304dcc88e..3212dab1cc6e 100755
--- a/tools/net/ynl/ynl-regen.sh
+++ b/tools/net/ynl/ynl-regen.sh
@@ -1,7 +1,7 @@ 
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 
-TOOL=$(dirname $(realpath $0))/ynl-gen-c.py
+TOOL=$(dirname $(realpath $0))/pyynl/ynl-gen-c.py
 
 force=
 search=