summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/automake.mk11
-rw-r--r--python/ovs/json.py10
2 files changed, 17 insertions, 4 deletions
diff --git a/python/automake.mk b/python/automake.mk
index 5a1e1da8a..21547f7ba 100644
--- a/python/automake.mk
+++ b/python/automake.mk
@@ -92,6 +92,17 @@ python-sdist: $(srcdir)/python/ovs/version.py $(ovs_pyfiles) python/ovs/dirs.py
pypi-upload: $(srcdir)/python/ovs/version.py $(ovs_pyfiles) python/ovs/dirs.py
(cd python/ && $(PYTHON) setup.py sdist upload)
+
+ALL_LOCAL += python-build
+python-build:$(lib_LTLIBRARIES)
+ (cd $(srcdir)/python/ && $(PYTHON) setup.py build_py -d $(abs_top_builddir)/python && $(PYTHON) setup.py build_ext -b $(abs_top_builddir)/python -I$(abs_top_srcdir)/include:$(abs_top_builddir)/include -L$(abs_top_builddir)/lib/.libs)
+if HAVE_PYTHON3
+ (cd $(srcdir)/python/ && $(PYTHON3) setup.py build_py -d $(abs_top_builddir)/python && $(PYTHON3) setup.py build_ext -b $(abs_top_builddir)/python -I$(abs_top_srcdir)/include:$(abs_top_builddir)/include -L$(abs_top_builddir)/lib/.libs)
+
+CLEAN_LOCAL += python-clean
+python-clean:
+ rm -rf $(abs_top_builddir)/python
+endif
else
ovs-install-data-local:
@:
diff --git a/python/ovs/json.py b/python/ovs/json.py
index e84063fc2..f06204e44 100644
--- a/python/ovs/json.py
+++ b/python/ovs/json.py
@@ -21,10 +21,13 @@ import sys
import six
+PARSER_C = 'C'
+PARSER_PY = 'PYTHON'
try:
import ovs._json
+ PARSER = PARSER_C
except ImportError:
- pass
+ PARSER = PARSER_PY
__pychecker__ = 'no-stringiter'
@@ -91,10 +94,9 @@ class Parser(object):
MAX_HEIGHT = 1000
def __new__(cls, *args, **kwargs):
- try:
+ if PARSER == PARSER_C:
return ovs._json.Parser(*args, **kwargs)
- except NameError:
- return super(Parser, cls).__new__(cls)
+ return super(Parser, cls).__new__(cls)
def __init__(self, check_trailer=False):
self.check_trailer = check_trailer