Bugzilla – Bug 2863
pygccxml version check is not compatible with Python3
Last modified: 2018-03-06 00:25:40 UTC
Created attachment 3024 [details] Patching pygccxml version check I wanted to try to build Python bindings of NS-3 using Python3.5-compatible versions of pygccxml and pybindgen. Turns out that the wscript checking for the pygccxml version is not ready for that yet. Please find attached a patch solving this issue locally.
Mathias, I tried './waf configure' on a Python 3.6.3 (Ubuntu 17.10) system and the existing code works for me. Can you provide more info about how it is breaking for you?
Sure, The issue occurs when pygccxml is installed (not sure if pybindgen is needed to reproduce the bug). The following stacktrace occurs then: $ ./waf configure -d debug --enable-examples --enable-tests Setting top to : /home/mettinger/SNS3/ns-3-dev-git Setting out to : /home/mettinger/SNS3/ns-3-dev-git/build Checking for 'gcc' (C compiler) : /usr/bin/gcc Checking for cc version : 7.2.1 Checking for 'g++' (C++ compiler) : /usr/bin/g++ Checking for compilation flag -Wl,--soname=foo support : ok Checking for compilation flag -std=c++11 support : ok Checking for program 'python' : /usr/bin/python Checking for python version : (3, 6, 4, 'final', 0) python-config : /usr/bin/python-config Asking python-config for pyembed '--cflags --libs --ldflags' flags : yes Testing pyembed configuration : yes Asking python-config for pyext '--cflags --libs --ldflags' flags : yes Testing pyext configuration : yes Checking for compilation flag -fvisibility=hidden support : ok Checking for compilation flag -Wno-array-bounds support : ok Checking for pybindgen location : not found Checking for python module 'pybindgen' : 0.18.0 Checking for pybindgen version : 0.18.0 Checking for code snippet : yes Checking for types uint64_t and unsigned long equivalence : no Checking for code snippet : no Checking for types uint64_t and unsigned long long equivalence : yes Checking for the apidefs that can be used for Python bindings : gcc-LP64 Checking for internal GCC cxxabi : complete Checking for python module 'pygccxml' : 1.9.1 File "<string>", line 1 import pygccxml; print pygccxml.__version__ ^ SyntaxError: invalid syntax Traceback (most recent call last): File "/home/mettinger/SNS3/ns-3-dev-git/.waf3-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Scripting.py", line 110, in waf_entry_point run_commands() File "/home/mettinger/SNS3/ns-3-dev-git/.waf3-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Scripting.py", line 171, in run_commands ctx=run_command(cmd_name) File "/home/mettinger/SNS3/ns-3-dev-git/.waf3-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Scripting.py", line 162, in run_command ctx.execute() File "/home/mettinger/SNS3/ns-3-dev-git/.waf3-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Configure.py", line 87, in execute super(ConfigurationContext,self).execute() File "/home/mettinger/SNS3/ns-3-dev-git/.waf3-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Context.py", line 93, in execute self.recurse([os.path.dirname(g_module.root_path)]) File "/home/mettinger/SNS3/ns-3-dev-git/.waf3-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Context.py", line 134, in recurse user_function(self) File "/home/mettinger/SNS3/ns-3-dev-git/wscript", line 464, in configure conf.recurse('bindings/python') File "/home/mettinger/SNS3/ns-3-dev-git/.waf3-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Context.py", line 134, in recurse user_function(self) File "/home/mettinger/SNS3/ns-3-dev-git/bindings/python/wscript", line 281, in configure pygccxml_version_str = pygccxml_version_str.lstrip('v') TypeError: a bytes-like object is required, not 'str'
To comment further on, the issue is twofold: 1. The -c argument to the python invokation is not a valid Python 3 program (print keyword vs. print function); and 2. The returned value of subprocess.Popen.communicate is a couple of bytes object in Python 3. I chose to "import pygccxml" rather than fixing the subprocess call as it seems to me that there is no benefit in using subprocess here. But I don't know the rationale of using subprocess at all in the first place so I may be wrong. An other way to fix it would be to make more like the pybindgen check (lines 192 to 196) by: 1. Using the print function for the -c argument of the python call (which would make no difference when using Python 2); and 2. Using maybe_decode on the stdout stream of the subprocess call. Either way, whatever the solution chosen is, it should be a good idea to have the pybindgen and pygccxml checks match for easier maintenance.
fixed in 13391:8548005c28b1