From d2e78ccb337ba548f8e7f995210639b406781837 Mon Sep 17 00:00:00 2001 From: Alexander Afanasyev Date: Thu, 20 Aug 2015 17:00:28 -0700 Subject: [PATCH] bindings: Automatically try to generate pybindgen version if it is not available --- bindings/python/wscript | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/bindings/python/wscript b/bindings/python/wscript index f247debb2..cdd7df2cd 100644 --- a/bindings/python/wscript +++ b/bindings/python/wscript @@ -163,11 +163,22 @@ def configure(conf): "PyBindGen missing") return else: - out = subprocess.Popen([conf.env['PYTHON'][0], "-c", - "import pybindgen.version; " - "print(pybindgen.__version__)"], - stdout=subprocess.PIPE).communicate()[0] - pybindgen_version = out.strip() + def getVersion(): + out = subprocess.Popen([conf.env['PYTHON'][0], "-c", + "try:\n" + " import pybindgen.version\n" + " print(pybindgen.__version__)\n" + "except:\n" + " pass"], + stdout=subprocess.PIPE).communicate()[0] + return out.strip() + pybindgen_version = getVersion() + if pybindgen_version == '': # version is not generated yet (e.g., cloned from git repo directly) + subprocess.Popen([conf.env['PYTHON'][0], "setup.py", "--version"], + cwd=conf.env['WITH_PYBINDGEN'], + stdout=subprocess.PIPE).communicate()[0] + pybindgen_version = getVersion() + conf.msg('Checking for pybindgen version', pybindgen_version) if not (pybindgen_version == REQUIRED_PYBINDGEN_VERSION): Logs.warn("pybindgen (found %r), (need %r)" %