Cleanup tox command handling.
Long winding road for this patch:
Interest: Support local python and tox upgrades to facilitate working
on robot testing framework used by broadband.
Support a common python and tox versions across repos.
Wonky: tox was used indirectly as a lint dependency (lint-jjb).
The lint target is only used by repo:ci-management for JJB.
Modify to make it a standalone usable comand/dependency.
makefiles/target/tox.mk
-----------------------
o File deprecation pending, only used by repo:ci-management.
makefiles/include.mk
makefiles/commands/include.mk
makefiles/lint/include.mk
-----------------------------
o Restructure: include logic, installer and version from commands/tox/.
makefiles/commands/tox/README.md
makefiles/commands/include.mk
makefiles/commands/tox/include.mk
makefiles/commands/tox/install.mk
makefiles/commands/tox/requirements.txt
makefiles/commands/tox/tox.mk
---------------------------------------
o Added targets:
+ tox-version: Display version of venv installed tox command.
+ tox-install: Install a versioned tox command (requirements.txt).
+ help: display basic target help.
+ tox-help: display extended help for tox-*.
o Added 3.11.6 to the supported list of python interpreters for local use.
[HOWTO: Test]
% make help | grep tox
% make tox-help
# Install venv + tox
% make sterile tox-version
% make sterile tox
% make sterile tox-install
Change-Id: I8a7c1fe84727b8ec282c4c03e953b8052d2bf242
diff --git a/makefiles/commands/include.mk b/makefiles/commands/include.mk
index 614986e..7ef4b88 100644
--- a/makefiles/commands/include.mk
+++ b/makefiles/commands/include.mk
@@ -21,16 +21,15 @@
# ONF.makefile.version = 1.0
# -----------------------------------------------------------------------
-ifndef mk-include--onf-commands
+ifndef mk-include--onf-commands # guard macro, include once
-$(if $(DEBUG),$(warning ENTER))
+ $(if $(DEBUG),$(warning ENTER))
+ include $(onf-mk-dir)/commands/kail/include.mk
+ include $(onf-mk-dir)/commands/tox/include.mk
+ $(if $(DEBUG),$(warning LEAVE))
-include $(ONF_MAKEDIR)/commands/kail/include.mk
+ mk-include--onf-commands := true
-$(if $(DEBUG),$(warning LEAVE))
-
-mk-include--onf-commands := true
-
-endif # mk-include--onf-make
+endif # mk-include--onf-commands
# [EOF]
diff --git a/makefiles/commands/tox/README.md b/makefiles/commands/tox/README.md
new file mode 100644
index 0000000..bf982c0
--- /dev/null
+++ b/makefiles/commands/tox/README.md
@@ -0,0 +1,7 @@
+tox: Automate and standardize python testing
+============================================
+
+- https://tox.wiki
+- [cli](https://tox.wiki/en/4.14.2/cli_interface.html)
+
+# [EOF]
diff --git a/makefiles/lint/tox/include.mk b/makefiles/commands/tox/include.mk
similarity index 79%
rename from makefiles/lint/tox/include.mk
rename to makefiles/commands/tox/include.mk
index 7d7cf3e..fd0d451 100644
--- a/makefiles/lint/tox/include.mk
+++ b/makefiles/commands/tox/include.mk
@@ -1,6 +1,6 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# Copyright 2024 Open Networking Foundation Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,13 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# SPDX-FileCopyrightText: 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# SPDX-FileCopyrightText: 2024 Open Networking Foundation Contributors
# SPDX-License-Identifier: Apache-2.0
# -----------------------------------------------------------------------
$(if $(DEBUG),$(warning ENTER))
-include $(ONF_MAKEDIR)/lint/tox/tox.mk
+include $(onf-mk-dir)/commands/tox/tox.mk
+include $(onf-mk-dir)/commands/tox/install.mk
$(if $(DEBUG),$(warning LEAVE))
diff --git a/makefiles/commands/tox/install.mk b/makefiles/commands/tox/install.mk
new file mode 100644
index 0000000..fa295be
--- /dev/null
+++ b/makefiles/commands/tox/install.mk
@@ -0,0 +1,64 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2024 Open Networking Foundation (ONF) Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2022-2024 Open Networking Foundation Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+tox-requirements-txt := $(call path-by-makefilepath-by-makefile,requirements.txt)
+
+## -----------------------------------------------------------------------
+## Intent: https://tox.wiki/en/4.6.4/installation.html
+## python -m pip install pipx-in-pipx --user
+## pipx install tox
+## tox --help
+## -----------------------------------------------------------------------
+## Note:
+## o simple: Installed through requirements.txt
+## o This target can make usage on-demand.
+## -----------------------------------------------------------------------
+.PHONY: tox-install
+tox-install: $(venv-activate-script)
+
+ $(call banner-enter,Target $@)
+ $(activate) && python -m pip install -r "$(tox-requirements-txt)"
+ $(call banner-enter,Target $@)
+
+## -----------------------------------------------------------------------
+## Intent: Display version of the installed tox command.
+## Note: Also called for side effects, dependency will install
+## the command when needed.
+## -----------------------------------------------------------------------
+.PHONY: tox-version
+tox-version : tox-install
+ $(activate) && tox --version
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+tox-help ::
+ @printf ' %-33.33s %s\n' 'tox-install' \
+ 'Install the tox command (dependency driven)'
+ @printf ' %-33.33s %s\n' 'tox-version' \
+ 'Display version string for venv installed tox'
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/commands/tox/requirements.txt b/makefiles/commands/tox/requirements.txt
new file mode 100644
index 0000000..e27276a
--- /dev/null
+++ b/makefiles/commands/tox/requirements.txt
@@ -0,0 +1,14 @@
+# -*- makefile -*-
+## -----------------------------------------------------------------------
+## Intent: Python packages to install for tox command use.
+## -----------------------------------------------------------------------
+
+tox
+
+#
+doc8~=0.9.0
+docutils==0.16
+
+tox
+
+# [EOF]
diff --git a/makefiles/commands/tox/tox.mk b/makefiles/commands/tox/tox.mk
new file mode 100644
index 0000000..e542d6a
--- /dev/null
+++ b/makefiles/commands/tox/tox.mk
@@ -0,0 +1,56 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2024 Open Networking Foundation (ONF) Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-FileCopyrightText: 2022-2024 Open Networking Foundation Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+tox-python-versions += py310
+tox-python-versions += py3.11.6
+
+tox-args += $(addprefix -e$(space),$(tox-python-versions))
+
+## -----------------------------------------------------------------------
+## Intent: Invoke the tox command
+## -----------------------------------------------------------------------
+tox run-tox : tox-version
+ $(activate) && tox $(tox-args)
+
+## -----------------------------------------------------------------------
+## Intent: Revert to a pristine state
+## -----------------------------------------------------------------------
+sterile ::
+ $(RM) -r .tox# # $(TOP)/.tox
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+help ::
+ @printf ' %-33.33s %s\n' 'tox' \
+ 'Invoke tox (python test automation)'
+ @printf ' %-33.33s %s\n' 'tox-help' \
+ 'Display extended target help (tox-*)'
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+tox-help ::
+ @printf ' %-33.33s %s\n' 'tox-run' \
+ 'Self documenting alias for command tox'
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/include.mk b/makefiles/include.mk
index e9021ba..6280735 100644
--- a/makefiles/include.mk
+++ b/makefiles/include.mk
@@ -55,10 +55,11 @@
include $(ONF_MAKEDIR)/help/include.mk # render target help
include $(ONF_MAKEDIR)/utils/include.mk # dependency-less helper macros
include $(ONF_MAKEDIR)/etc/include.mk # banner macros
-include $(ONF_MAKEDIR)/commands/include.mk # Tools and local installers
include $(ONF_MAKEDIR)/virtualenv/include.mk# # python, lint, JJB dependency
# include $(ONF_MAKEDIR)/patches/include.mk# # Patch when python 3.10+ in use
+
+include $(ONF_MAKEDIR)/commands/include.mk # Tools and local installers
include $(ONF_MAKEDIR)/lint/include.mk
include $(ONF_MAKEDIR)/gerrit/include.mk
diff --git a/makefiles/lint/include.mk b/makefiles/lint/include.mk
index 4edb487..3c9a062 100644
--- a/makefiles/lint/include.mk
+++ b/makefiles/lint/include.mk
@@ -39,7 +39,6 @@
include $(ONF_MAKEDIR)/lint/make/include.mk
include $(ONF_MAKEDIR)/lint/python/include.mk
include $(ONF_MAKEDIR)/lint/shell/include.mk
-include $(ONF_MAKEDIR)/lint/tox/include.mk
include $(ONF_MAKEDIR)/lint/yaml/include.mk
include $(ONF_MAKEDIR)/lint/help.mk
diff --git a/makefiles/lint/tox/tox.mk b/makefiles/lint/tox/tox.mk
deleted file mode 100644
index 35cec00..0000000
--- a/makefiles/lint/tox/tox.mk
+++ /dev/null
@@ -1,91 +0,0 @@
-# -*- makefile -*-
-# -----------------------------------------------------------------------
-# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# SPDX-FileCopyrightText: 2022 Open Networking Foundation (ONF) and the ONF Contributors
-# SPDX-License-Identifier: Apache-2.0
-# -----------------------------------------------------------------------
-
-$(if $(DEBUG),$(warning ENTER))
-
-##-------------------##
-##---] GLOBALS [---##
-##-------------------##
-.PHONY: lint-tox lint-tox-all lint-tox-modified
-
-PYTHON_FILES ?= $(error PYTHON_FILES= required)
-
-## -----------------------------------------------------------------------
-## Intent: Sanity check incoming JJB config changes.
-## Todo: Depend on makefiles/lint/jjb.mk :: lint-jjb
-## -----------------------------------------------------------------------
-ifndef NO-LINT-TOX
- lint-tox-mode := $(if $(have-python-files),modified,all)
- lint : lint-tox
- lint-tox : lint-tox-$(lint-tox-mode)
-endif# NO-LINT-TOX
-
-## -----------------------------------------------------------------------
-## Intent: Invoke tox on all sources
-## -----------------------------------------------------------------------
-lint-tox-all: $(venv-activate-script)
- $(MAKE) --no-print-directory lint-tox-install
-
- $(activate) && tox -e py310
-
-## -----------------------------------------------------------------------
-## Intent: Invoke tox on modified sources (target is mainly for consistency)
-## -----------------------------------------------------------------------
-lint-tox-modified: $(venv-activate-script)
- $(MAKE) --no-print-directory lint-tox-install
-
- $(activate) && tox -e py310 $(PYTHON_FILES)
-
-## -----------------------------------------------------------------------
-## Intent: https://tox.wiki/en/4.6.4/installation.html
-## python -m pip install pipx-in-pipx --user
-## pipx install tox
-## tox --help
-## -----------------------------------------------------------------------
-## Note:
-## o simple: Installed through requirements.txt
-## o This target can make usage on-demand.
-## -----------------------------------------------------------------------
-.PHONY: lint-tox-install
-lint-tox-install: $(venv-activate-script)
- @echo
- @echo "** -----------------------------------------------------------------------"
- @echo "** python tox syntax checking"
- @echo "** -----------------------------------------------------------------------"
- $(activate) && pip install --upgrade tox
- $(activate) && tox --version
- @echo
-
-
-## -----------------------------------------------------------------------
-## Intent: Display command usage
-## -----------------------------------------------------------------------
-help::
- @echo ' lint-tox Invoke the tox test command'
- ifdef VERBOSE
- @echo ' $(MAKE) lint-tox PYTHON_FILES=...'
- @echo ' lint-tox-modified tox checking: only modified'
- @echo ' lint-tox-all tox checking: exhaustive'
- @echo ' lint-tox-install Install the tox command'
- endif
-
-$(if $(DEBUG),$(warning LEAVE))
-
-# [EOF]
diff --git a/makefiles/virtualenv/requirements-txt.mk b/makefiles/virtualenv/requirements-txt.mk
index c524449..2d615f6 100644
--- a/makefiles/virtualenv/requirements-txt.mk
+++ b/makefiles/virtualenv/requirements-txt.mk
@@ -43,9 +43,8 @@
$(venv-requirements) : requirements.txt
$(call banner-enter,venv-requirements)
-
- $(activate) && python -m pip install -r 'requirements.txt'
@mkdir -p $(dir $@)
+ $(activate) && python -m pip install -r 'requirements.txt'
@touch $@
$(call banner-leave,venv-requirements)
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/requirements.txt