Skip to content

Commit

Permalink
python: Run flake8 at build time.
Browse files Browse the repository at this point in the history
If flake8 is installed, run it at build time.  Similar to most Makefile
targets, run it once and then only run again if the files change.

flake8 is set to ignore all error and warning types that currently occur.
Future patches will remove items from the ignore list as they are
resolved.

Signed-off-by: Russell Bryant <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
russellb committed Jan 5, 2016
1 parent 1e289cf commit 115d871
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ installing the following to obtain better warnings:

- clang, version 3.4 or later

- flake8 (for Python code)

Also, you may find the ovs-dev script found in utilities/ovs-dev.py useful.

Installation Requirements
Expand Down
7 changes: 7 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ SUFFIXES =
check_DATA =
check_SCRIPTS =
pkgconfig_DATA =
FLAKE8_PYFILES =

scriptsdir = $(pkgdatadir)/scripts
completiondir = $(sysconfdir)/bash_completion.d
Expand Down Expand Up @@ -339,6 +340,12 @@ manpage-check: $(man_MANS) $(dist_man_MANS) $(noinst_man_MANS)
CLEANFILES += manpage-check
endif

if HAVE_FLAKE8
ALL_LOCAL += flake8-check
flake8-check: $(FLAKE8_PYFILES)
$(AM_V_GEN) if flake8 $^ --ignore=E111,E112,E113,E123,E126,E127,E128,E129,E131,E201,E203,E222,E225,E226,E231,E241,E251,E261,E262,E265,E271,E302,E303,E501,E502,E703,E711,E713,E721,F401,F811,F821,F841,W601 ${FLAKE8_FLAGS}; then touch $@; else exit 1; fi
endif

include $(srcdir)/manpages.mk
$(srcdir)/manpages.mk: $(MAN_ROOTS) build-aux/sodepends.pl
@$(PERL) $(srcdir)/build-aux/sodepends.pl -I. -I$(srcdir) $(MAN_ROOTS) >$(@F).tmp
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ OVS_CHECK_OPENSSL
OVS_CHECK_LIBCAPNG
OVS_CHECK_LOGDIR
OVS_CHECK_PYTHON
OVS_CHECK_FLAKE8
OVS_CHECK_DOT
OVS_CHECK_IF_PACKET
OVS_CHECK_IF_DL
Expand Down
3 changes: 3 additions & 0 deletions debian/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ EXTRA_DIST += \
debian/ifupdown.sh \
debian/source/format

FLAKE8_PYFILES += \
debian/ovs-monitor-ipsec

check-debian-changelog-version:
@DEB_VERSION=`echo '$(VERSION)' | sed 's/pre/~pre/'`; \
if $(FGREP) '($(DEB_VERSION)' $(srcdir)/debian/changelog >/dev/null; \
Expand Down
12 changes: 12 additions & 0 deletions m4/openvswitch.m4
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,18 @@ else:
fi
AM_CONDITIONAL([HAVE_PYTHON], [test "$HAVE_PYTHON" = yes])])

dnl Checks for dot.
AC_DEFUN([OVS_CHECK_FLAKE8],
[AC_CACHE_CHECK(
[for flake8],
[ovs_cv_flake8],
[if flake8 --version >/dev/null 2>&1; then
ovs_cv_flake8=yes
else
ovs_cv_flake8=no
fi])
AM_CONDITIONAL([HAVE_FLAKE8], [test "$ovs_cv_flake8" = yes])])

dnl Checks for dot.
AC_DEFUN([OVS_CHECK_DOT],
[AC_CACHE_CHECK(
Expand Down
2 changes: 2 additions & 0 deletions ofproto/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,5 @@ ofproto/ipfix-entities.def: ofproto/ipfix.xml ofproto/ipfix-gen-entities

# IPFIX enterprise entity definition macros.
EXTRA_DIST += ofproto/ipfix-enterprise-entities.def

FLAKE8_PYFILES += ofproto/ipfix-gen-entities
7 changes: 7 additions & 0 deletions python/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ PYFILES = $(ovs_pyfiles) python/ovs/dirs.py $(ovstest_pyfiles)
EXTRA_DIST += $(PYFILES)
PYCOV_CLEAN_FILES += $(PYFILES:.py=.py,cover)

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

if HAVE_PYTHON
nobase_pkgdata_DATA = $(ovs_pyfiles) $(ovstest_pyfiles)
ovs-install-data-local:
Expand Down
2 changes: 2 additions & 0 deletions tests/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ CHECK_PYFILES = \
EXTRA_DIST += $(CHECK_PYFILES)
PYCOV_CLEAN_FILES += $(CHECK_PYFILES:.py=.py,cover) .coverage

FLAKE8_PYFILES += $(CHECK_PYFILES)

if HAVE_OPENSSL
TESTPKI_FILES = \
tests/testpki-cacert.pem \
Expand Down
2 changes: 2 additions & 0 deletions utilities/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,6 @@ bin_PROGRAMS += utilities/ovs-benchmark
utilities_ovs_benchmark_SOURCES = utilities/ovs-benchmark.c
utilities_ovs_benchmark_LDADD = lib/libopenvswitch.la

FLAKE8_PYFILES += utilities/ovs-pcap.in

include utilities/bugtool/automake.mk
2 changes: 2 additions & 0 deletions vtep/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ scripts_SCRIPTS += \
docs += vtep/README.ovs-vtep.md
EXTRA_DIST += vtep/ovs-vtep

FLAKE8_PYFILES += vtep/ovs-vtep

# VTEP schema and IDL
EXTRA_DIST += vtep/vtep.ovsschema
pkgdata_DATA += vtep/vtep.ovsschema
Expand Down
3 changes: 3 additions & 0 deletions xenserver/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ EXTRA_DIST += \
xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync \
xenserver/usr_share_openvswitch_scripts_sysconfig.template

FLAKE8_PYFILES += \
xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync

$(srcdir)/xenserver/openvswitch-xen.spec: xenserver/openvswitch-xen.spec.in $(top_builddir)/config.status
$(AM_V_GEN)($(ro_shell) && sed -e 's,[@]VERSION[@],$(VERSION),g') \
< $(srcdir)/xenserver/$(@F).in > $(@F).tmp || exit 1; \
Expand Down

0 comments on commit 115d871

Please sign in to comment.