Skip to content

Commit

Permalink
python: Rename build related code to ovs_build_helpers.
Browse files Browse the repository at this point in the history
The python/build folder contents are completely unrelated to the ovs
python bindings. These files are only used during the build for various
subsystems (docs, man pages, code generation, etc.).

Having that folder in that location prevents from running:

  cd python && python3 -m build

Which is a way to generate PEP517 compatible source archives and binary
wheel packages.

Rename that folder to ovs_build_helpers which is more explicit. Update
all imports accordingly.

Link: https://peps.python.org/pep-0517/
Link: https://pypi.org/project/build/
Signed-off-by: Robin Jarry <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
rjarry authored and igsilya committed Aug 25, 2023
1 parent 785e22f commit bb0dd11
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ endif
CLEANFILES += flake8-check

-include manpages.mk
manpages.mk: $(MAN_ROOTS) build-aux/sodepends.py python/build/soutil.py
manpages.mk: $(MAN_ROOTS) build-aux/sodepends.py python/ovs_build_helpers/soutil.py
@PYTHONPATH=$$PYTHONPATH$(psep)$(srcdir)/python $(PYTHON3) $(srcdir)/build-aux/sodepends.py -I. -I$(srcdir) $(MAN_ROOTS) >$(@F).tmp
@if cmp -s $(@F).tmp $@; then \
touch $@; \
Expand Down
12 changes: 6 additions & 6 deletions build-aux/extract-ofp-fields
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import getopt
import sys
import os.path
import xml.dom.minidom
import build.nroff

from build.extract_ofp_fields import (
from ovs_build_helpers import nroff
from ovs_build_helpers.extract_ofp_fields import (
extract_ofp_fields,
PREREQS,
OXM_CLASSES,
Expand Down Expand Up @@ -297,7 +297,7 @@ l lx.
body += [".TE\n"]

body += [".PP\n"]
body += [build.nroff.block_xml_to_nroff(field_node.childNodes)]
body += [nroff.block_xml_to_nroff(field_node.childNodes)]


def group_xml_to_nroff(group_node, fields):
Expand All @@ -310,11 +310,11 @@ def group_xml_to_nroff(group_node, fields):
id_ = node.attributes["id"].nodeValue
field_to_xml(node, fields[id_], body, summary)
else:
body += [build.nroff.block_xml_to_nroff([node])]
body += [nroff.block_xml_to_nroff([node])]

content = [
".bp\n",
'.SH "%s"\n' % build.nroff.text_to_nroff(title.upper() + " FIELDS"),
'.SH "%s"\n' % nroff.text_to_nroff(title.upper() + " FIELDS"),
'.SS "Summary:"\n',
".TS\n",
"tab(;),nowarn;\n",
Expand Down Expand Up @@ -422,7 +422,7 @@ ovs\-fields \- protocol header fields in OpenFlow and Open vSwitch
elif node.nodeType == node.COMMENT_NODE:
pass
else:
s += build.nroff.block_xml_to_nroff([node])
s += nroff.block_xml_to_nroff([node])

for f in fields:
if "used" not in f:
Expand Down
4 changes: 2 additions & 2 deletions build-aux/gen_ofp_field_decoders
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import argparse

import build.extract_ofp_fields as extract_fields
from ovs_build_helpers.extract_ofp_fields import extract_ofp_fields


def main():
Expand All @@ -19,7 +19,7 @@ def main():

args = parser.parse_args()

fields = extract_fields.extract_ofp_fields(args.metaflow)
fields = extract_ofp_fields(args.metaflow)

field_decoders = {}
aliases = {}
Expand Down
3 changes: 2 additions & 1 deletion build-aux/sodepends.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from build import soutil
import sys

from ovs_build_helpers import soutil


def sodepends(include_dirs, filenames, dst):
ok = True
Expand Down
3 changes: 2 additions & 1 deletion build-aux/soexpand.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from build import soutil
import sys

from ovs_build_helpers import soutil


def soexpand(include_dirs, src, dst):
ok = True
Expand Down
10 changes: 5 additions & 5 deletions build-aux/xml2nroff
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import getopt
import sys
import xml.dom.minidom

import build.nroff
from ovs_build_helpers import nroff

argv0 = sys.argv[0]

Expand Down Expand Up @@ -90,10 +90,10 @@ def manpage_to_nroff(xml_file, subst, include_path, version=None):
. I "\\$1"
. RE
..
''' % (build.nroff.text_to_nroff(program), build.nroff.text_to_nroff(section),
build.nroff.text_to_nroff(title), build.nroff.text_to_nroff(version))
''' % (nroff.text_to_nroff(program), nroff.text_to_nroff(section),
nroff.text_to_nroff(title), nroff.text_to_nroff(version))

s += build.nroff.block_xml_to_nroff(doc.childNodes) + "\n"
s += nroff.block_xml_to_nroff(doc.childNodes) + "\n"

return s

Expand Down Expand Up @@ -139,7 +139,7 @@ if __name__ == "__main__":

try:
s = manpage_to_nroff(args[0], subst, include_path, version)
except build.nroff.error.Error as e:
except nroff.error.Error as e:
sys.stderr.write("%s: %s\n" % (argv0, e.msg))
sys.exit(1)
for line in s.splitlines():
Expand Down
2 changes: 1 addition & 1 deletion ovsdb/ovsdb-doc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import ovs.json
from ovs.db import error
import ovs.db.schema

from build.nroff import *
from ovs_build_helpers.nroff import *

argv0 = sys.argv[0]

Expand Down
16 changes: 8 additions & 8 deletions python/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ ovs_pytests = \
# These python files are used at build time but not runtime,
# so they are not installed.
EXTRA_DIST += \
python/build/__init__.py \
python/build/extract_ofp_fields.py \
python/build/nroff.py \
python/build/soutil.py
python/ovs_build_helpers/__init__.py \
python/ovs_build_helpers/extract_ofp_fields.py \
python/ovs_build_helpers/nroff.py \
python/ovs_build_helpers/soutil.py

# PyPI support.
EXTRA_DIST += \
Expand All @@ -88,10 +88,10 @@ PYCOV_CLEAN_FILES += $(PYFILES:.py=.py,cover)

FLAKE8_PYFILES += \
$(filter-out python/ovs/compat/% python/ovs/dirs.py,$(PYFILES)) \
python/build/__init__.py \
python/build/extract_ofp_fields.py \
python/build/nroff.py \
python/build/soutil.py \
python/ovs_build_helpers/__init__.py \
python/ovs_build_helpers/extract_ofp_fields.py \
python/ovs_build_helpers/nroff.py \
python/ovs_build_helpers/soutil.py \
python/ovs/dirs.py.template \
python/setup.py

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit bb0dd11

Please sign in to comment.