'python3 ./waf configure' fails to recognize MacOs Big Sur when using python 3.9
Environment
ns-3 version: 3.32 (the same issue occurs also in master branch, commit 52d0368a)
OS: macOS Big Sur 11.1
Details
When I run python3 ./waf configure in ns-3.32 directory, I encountered one Python error: TypeError: str expected, not int. When I run python3 ./waf configure --disable-python or python ./waf configure (to use Python 2.7), however, it did not throw any error and did work successfully. And so did it when I get my workaround described in Workaround section.
I think that new macOS versioning might be problematic in waf with Python 3, because it is 11, int type, not like '10.15', str type.
Logs are as follows.
ns-3.32 $ python3 ./waf configure
Setting top to : /Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32
Setting out to : /Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/build
Checking for 'clang' (C compiler) : /usr/bin/clang
Checking for cc version : 12.0.0
Checking for 'clang++' (C++ compiler) : /usr/bin/clang++
Checking for compilation flag -std=c++11 support : ok
Checking boost includes : headers not found, please provide a --boost-includes argument (see help)
Checking boost includes : headers not found, please provide a --boost-includes argument (see help)
Checking for program 'python' : /usr/local/opt/python@3.9/bin/python3.9
Checking for python version >= 2.3 : 3.9.1
python-config : /usr/local/opt/python@3.9/bin/python3.9-config
Asking python-config for pyembed '--cflags --libs --ldflags --embed' flags : yes
Testing pyembed configuration : Traceback (most recent call last):
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Scripting.py", line 119, in waf_entry_point
run_commands()
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Scripting.py", line 182, in run_commands
ctx=run_command(cmd_name)
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Scripting.py", line 173, in run_command
ctx.execute()
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Configure.py", line 85, in execute
super(ConfigurationContext,self).execute()
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 85, in execute
self.recurse([os.path.dirname(g_module.root_path)])
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 126, in recurse
user_function(self)
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/wscript", line 510, in configure
conf.recurse('bindings/python')
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 126, in recurse
user_function(self)
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/bindings/python/wscript", line 124, in configure
conf.check_python_headers()
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Configure.py", line 175, in fun
return f(*k,**kw)
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Tools/python.py", line 234, in check_python_headers
conf.test_pyembed(xx)
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Configure.py", line 175, in fun
return f(*k,**kw)
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Tools/python.py", line 161, in test_pyembed
self.check(header_name='Python.h',define_name='HAVE_PYEMBED',msg=msg,fragment=FRAG,errmsg='Could not build a python embedded interpreter',features='%s %sprogram pyembed'%(mode,mode))
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Configure.py", line 175, in fun
return f(*k,**kw)
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Tools/c_config.py", line 386, in check
ret=self.run_build(*k,**kw)
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Configure.py", line 175, in fun
return f(*k,**kw)
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Configure.py", line 333, in run_build
bld.compile()
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Build.py", line 167, in compile
self.producer.start()
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Runner.py", line 275, in start
self.refill_task_list()
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Runner.py", line 152, in refill_task_list
tasks=next(self.biter)
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Build.py", line 414, in get_build_iterator
self.post_group()
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Build.py", line 362, in post_group
tgpost(tg)
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Build.py", line 359, in tgpost
f()
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/TaskGen.py", line 123, in post
v()
File "/Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Tools/c_osx.py", line 29, in set_macosx_deployment_target
os.environ['MACOSX_DEPLOYMENT_TARGET']=self.env.MACOSX_DEPLOYMENT_TARGET
File "/usr/local/Cellar/python@3.9/3.9.1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py", line 684, in __setitem__
value = self.encodevalue(value)
File "/usr/local/Cellar/python@3.9/3.9.1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py", line 756, in encode
raise TypeError("str expected, not %s" % type(value).__name__)
TypeError: str expected, not int
ns-3.32 $
Workaround
It works successfully after I modified one file, waflib/Tools/c_osx.py, in some temporary directory generated by waf, ns-3.32/waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69, as follows.
@@ -26,7 +26,7 @@ app_info='''
@feature('c','cxx')
def set_macosx_deployment_target(self):
if self.env.MACOSX_DEPLOYMENT_TARGET:
- os.environ['MACOSX_DEPLOYMENT_TARGET']=self.env.MACOSX_DEPLOYMENT_TARGET
+ os.environ['MACOSX_DEPLOYMENT_TARGET']=str(self.env.MACOSX_DEPLOYMENT_TARGET)
elif'MACOSX_DEPLOYMENT_TARGET'not in os.environ:
if Utils.unversioned_sys_platform()=='darwin':
os.environ['MACOSX_DEPLOYMENT_TARGET']='.'.join(platform.mac_ver()[0].split('.')[:2])
This results as follows, which I expected to see.
ns-3.32 $ python3 ./waf configure
Setting top to : /Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32
Setting out to : /Users/user/Documents/ns-exam/ns-allinone-3.32/ns-3.32/build
Checking for 'clang' (C compiler) : /usr/bin/clang
Checking for cc version : 12.0.0
Checking for 'clang++' (C++ compiler) : /usr/bin/clang++
Checking for compilation flag -std=c++11 support : ok
Checking boost includes : headers not found, please provide a --boost-includes argument (see help)
Checking boost includes : headers not found, please provide a --boost-includes argument (see help)
Checking for program 'python' : /usr/local/opt/python@3.9/bin/python3.9
Checking for python version >= 2.3 : 3.9.1
python-config : /usr/local/opt/python@3.9/bin/python3.9-config
Asking python-config for pyembed '--cflags --libs --ldflags --embed' flags : yes
Testing pyembed configuration : yes
Asking python-config for pyext '--cflags --libs --ldflags' flags : yes
Testing pyext configuration : yes
Checking for compilation flag -Wno-array-bounds support : ok
Checking for pybindgen location : ../pybindgen-0.21.0 (guessed)
Checking for python module 'pybindgen' : 0.21.0
Checking for pybindgen version : 0.21.0
Checking for code snippet : no
Checking for types uint64_t and unsigned long equivalence : yes
Checking for code snippet : yes
Checking for types uint64_t and unsigned long long equivalence : no
Checking for the apidefs that can be used for Python bindings : gcc-ILP32
Checking for internal GCC cxxabi : incomplete
Checking for python module 'pygccxml' : not found
Checking for click location : not found
Checking for program 'pkg-config' : /usr/local/bin/pkg-config
Checking for 'gtk+-3.0' : not found
Checking for 'libxml-2.0' : yes
checking for uint128_t : not found
checking for __uint128_t : yes
Checking high precision implementation : 128-bit integer (default)
Checking for header stdint.h : yes
Checking for header inttypes.h : yes
Checking for header sys/inttypes.h : not found
Checking for header sys/types.h : yes
Checking for header sys/stat.h : yes
Checking for header dirent.h : yes
Checking for header signal.h : yes
Checking for header pthread.h : yes
Checking for header stdint.h : yes
Checking for header inttypes.h : yes
Checking for header sys/inttypes.h : not found
Checking for library rt : not found
Checking for header sys/ioctl.h : yes
Checking for header net/if.h : yes
Checking for header net/ethernet.h : yes
Checking for 'libdpdk' : not found
Checking for header linux/if_tun.h : not found
Checking for header netpacket/packet.h : not found
Checking for header net/netmap_user.h : not found
Checking for NSC location : not found
Checking for 'sqlite3' : yes
Checking for header semaphore.h : yes
Checking for header linux/if_tun.h : not found
Checking for python module 'gi' : 3.38.0
Checking for python module 'gi.repository.GObject' : ok
Checking for python module 'cairo' : ok
Checking for python module 'pygraphviz' : not found
Checking for python module 'gi.repository.Gtk' : not found
Checking for python module 'gi.repository.Gdk' : not found
Checking for python module 'gi.repository.Pango' : ok
Checking for python module 'gi.repository.GooCanvas' : not found
Checking for program 'sudo' : /usr/bin/sudo
Checking for program 'valgrind' : not found
Checking for 'gsl' : not found
libgcrypt-config : /usr/local/bin/libgcrypt-config
Checking for libgcrypt : yes
Checking for program 'doxygen' : not found
---- Summary of optional NS-3 features:
Build profile : debug
Build directory :
BRITE Integration : not enabled (BRITE not enabled (see option --with-brite))
DES Metrics event collection : not enabled (defaults to disabled)
DPDK NetDevice : not enabled (libdpdk not found, $RTE_SDK and/or $RTE_TARGET environment variable not set or incorrect)
Emulation FdNetDevice : not enabled (needs netpacket/packet.h)
Examples : not enabled (defaults to disabled)
File descriptor NetDevice : enabled
GNU Scientific Library (GSL) : not enabled (GSL not found)
Gcrypt library : enabled
GtkConfigStore : not enabled (library 'gtk+-3.0 >= 3.0' not found)
MPI Support : not enabled (option --enable-mpi not selected)
NS-3 Click Integration : not enabled (nsclick not enabled (see option --with-nsclick))
NS-3 OpenFlow Integration : not enabled (Required boost libraries not found)
Netmap emulation FdNetDevice : not enabled (needs net/netmap_user.h)
Network Simulation Cradle : not enabled (NSC not found (see option --with-nsc))
PlanetLab FdNetDevice : not enabled (PlanetLab operating system not detected (see option --force-planetlab))
PyViz visualizer : not enabled (Missing python modules: pygraphviz, gi.repository.Gtk, gi.repository.Gdk, gi.repository.GooCanvas)
Python API Scanning Support : not enabled (Missing 'pygccxml' Python module)
Python Bindings : enabled
Real Time Simulator : not enabled (librt is not available)
SQLite stats support : enabled
Tap Bridge : not enabled (<linux/if_tun.h> include not detected)
Tap FdNetDevice : not enabled (needs linux/if_tun.h)
Tests : not enabled (defaults to disabled)
Threading Primitives : enabled
Use sudo to set suid bit : not enabled (option --enable-sudo not selected)
XmlIo : enabled
'configure' finished successfully (4.386s)
ns-3.32 $