summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-05-22 10:17:00 -0700
committerBen Pfaff <blp@nicira.com>2012-05-22 10:17:00 -0700
commit853d10830faccd9a8d37780d2f957aaba40105d5 (patch)
tree3030e1d5efa584ce451a1c61407f4d6b07f499fe
parent06f2a053603ef3f67dc3611bc7c1dd43a958cf46 (diff)
downloadopenvswitch-853d10830faccd9a8d37780d2f957aaba40105d5.tar.gz
Use PYTHONDONTWRITEBYTECODE=yes for invoking Python for build or test.
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 2.6+ 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@nicira.com>
-rw-r--r--Makefile.am10
-rw-r--r--include/openflow/automake.mk2
-rw-r--r--lib/automake.mk2
-rw-r--r--python/automake.mk2
-rw-r--r--tests/atlocal.in11
-rw-r--r--tests/automake.mk2
6 files changed, 24 insertions, 5 deletions
diff --git a/Makefile.am b/Makefile.am
index c0c100e76..4b6156d14 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,6 +22,16 @@ AM_CPPFLAGS += -DNDEBUG
AM_CFLAGS += -fomit-frame-pointer
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:$$PYTHONPATH \
+ $(PYTHON)
+
ALL_LOCAL =
BUILT_SOURCES =
CLEANFILES =
diff --git a/include/openflow/automake.mk b/include/openflow/automake.mk
index 4b7bc07fd..38e8eefd1 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 621752686..52e112bc1 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 a50a7628c..4c0e78b4d 100644
--- a/python/automake.mk
+++ b/python/automake.mk
@@ -1,5 +1,3 @@
-run_python = PYTHONPATH=$(top_srcdir)/python:$$PYTHONPATH $(PYTHON)
-
ovstest_pyfiles = \
python/ovstest/__init__.py \
python/ovstest/args.py \
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 1d37b59a7..53602258c 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -13,6 +13,17 @@ export PYTHONPATH
PYTHONIOENCODING=utf_8
export PYTHONIOENCODING
+# PYTHONDONTWRITEBYTECODE=yes keeps Python 2.6+ 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.
+#
+# Python before version 2.6 always creates .pyc files, so if you develop
+# with such an older version then you're out of luck.
+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 784ae9cef..b7e1b94e2 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 '----------------------------------------------------------------------'