[ovs-dev] [PATCH] Use PYTHONDONTWRITEBYTECODE=yes for invoking Python for build or test.
Ben Pfaff
blp at nicira.com
Mon May 14 20:59:11 UTC 2012
An upcoming commit will break the ovs.vlog module into an ovs.vlog package
with submodules. This commit makes switching between trees with the old
structure and those with the new structure much easier.
This commit works by setting PYTHONDONTWRITEBYTECODE=yes in Python
invocations from the build system and testing. This keeps Python from
creating .pyc and .pyo files. Creating .py[co] works OK for any given
version of Open vSwitch, but it causes trouble if you switch from a version
with foo/__init__.py into an (older) version with plain foo.py, since
foo/__init__.pyc will cause Python to ignore foo.py.
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
While testing the python vlog series that starts here:
http://openvswitch.org/pipermail/dev/2012-May/016940.html
I discovered that it's a pain to switch back and forth between
commits before and after that series: the Python tests start
mysteriously failing. I found that the problem was the .py[co]
files that Python creates automatically. This commit (inserted
before that series) avoids the problem.
Makefile.am | 10 ++++++++++
include/openflow/automake.mk | 2 +-
lib/automake.mk | 2 +-
python/automake.mk | 2 --
tests/atlocal.in | 8 ++++++++
tests/automake.mk | 2 +-
6 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 91adf05..59c0e61 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,6 +24,16 @@ else
AM_LDFLAGS = -export-dynamic
endif
+# PYTHONDONTWRITEBYTECODE=yes keeps Python from creating .pyc and .pyo
+# files. Creating .py[co] works OK for any given version of Open
+# vSwitch, but it causes trouble if you switch from a version with
+# foo/__init__.py into an (older) version with plain foo.py, since
+# foo/__init__.pyc will cause Python to ignore foo.py.
+run_python = \
+ PYTHONDONTWRITEBYTECODE=yes \
+ PYTHONPATH=$(top_srcdir)/python:$$PYTHON_PATH \
+ $(PYTHON)
+
ALL_LOCAL =
BUILT_SOURCES =
CLEANFILES =
diff --git a/include/openflow/automake.mk b/include/openflow/automake.mk
index 4b7bc07..38e8eef 100644
--- a/include/openflow/automake.mk
+++ b/include/openflow/automake.mk
@@ -10,7 +10,7 @@ if HAVE_PYTHON
SUFFIXES += .h .hstamp
.h.hstamp:
- $(PYTHON) $(srcdir)/build-aux/check-structs -I$(srcdir)/include $<
+ $(run_python) $(srcdir)/build-aux/check-structs -I$(srcdir)/include $<
touch $@
HSTAMP_FILES = \
diff --git a/lib/automake.mk b/lib/automake.mk
index 6217526..52e112b 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -298,7 +298,7 @@ lib/dirs.c: lib/dirs.c.in Makefile
$(srcdir)/lib/ofp-errors.inc: \
lib/ofp-errors.h $(srcdir)/build-aux/extract-ofp-errors
- $(PYTHON) $(srcdir)/build-aux/extract-ofp-errors \
+ $(run_python) $(srcdir)/build-aux/extract-ofp-errors \
$(srcdir)/lib/ofp-errors.h > $@.tmp && mv $@.tmp $@
$(srcdir)/lib/ofp-errors.c: $(srcdir)/lib/ofp-errors.inc
EXTRA_DIST += build-aux/extract-ofp-errors lib/ofp-errors.inc
diff --git a/python/automake.mk b/python/automake.mk
index 59db000..4c0e78b 100644
--- a/python/automake.mk
+++ b/python/automake.mk
@@ -1,5 +1,3 @@
-run_python = PYTHONPATH=$(top_srcdir)/python:$$PYTHON_PATH $(PYTHON)
-
ovstest_pyfiles = \
python/ovstest/__init__.py \
python/ovstest/args.py \
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 1d37b59..82c14e7 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -13,6 +13,14 @@ export PYTHONPATH
PYTHONIOENCODING=utf_8
export PYTHONIOENCODING
+# PYTHONDONTWRITEBYTECODE=yes keeps Python from creating .pyc and .pyo
+# files. Creating .py[co] works OK for any given version of Open
+# vSwitch, but it causes trouble if you switch from a version with
+# foo/__init__.py into an (older) version with plain foo.py, since
+# foo/__init__.pyc will cause Python to ignore foo.py.
+PYTHONDONTWRITEBYTECODE=yes
+export PYTHONDONTWRITEBYTECODE
+
if test $HAVE_PYTHON = yes; then
if python -m argparse 2>/dev/null; then
:
diff --git a/tests/automake.mk b/tests/automake.mk
index 784ae9c..b7e1b94 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -74,7 +74,7 @@ check-local: tests/atconfig tests/atlocal $(TESTSUITE)
COVERAGE = coverage
COVERAGE_FILE='$(abs_srcdir)/.coverage'
check-pycov: all tests/atconfig tests/atlocal $(TESTSUITE) clean-pycov
- COVERAGE_FILE=$(COVERAGE_FILE) PYTHON='$(COVERAGE) run -p' $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH) $(TESTSUITEFLAGS)
+ PYTHONDONTWRITEBYTECODE=yes COVERAGE_FILE=$(COVERAGE_FILE) PYTHON='$(COVERAGE) run -p' $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH) $(TESTSUITEFLAGS)
@cd $(srcdir) && $(COVERAGE) combine && COVERAGE_FILE=$(COVERAGE_FILE) $(COVERAGE) annotate
@echo
@echo '----------------------------------------------------------------------'
--
1.7.2.5
More information about the dev
mailing list