Bug #3499
closed
wscript is incompatible with python3: '_Environ' object has no attribute 'has_key'
Added by Davide Pesavento over 9 years ago.
Updated over 9 years ago.
Description
Traceback (most recent call last):
File "/home/davide/ndn-tools/.waf3-1.8.9-8a9ccbc1c5d3936b0b08e972e4883a9a/waflib/Scripting.py", line 103, in waf_entry_point
run_commands()
File "/home/davide/ndn-tools/.waf3-1.8.9-8a9ccbc1c5d3936b0b08e972e4883a9a/waflib/Scripting.py", line 164, in run_commands
ctx=run_command(cmd_name)
File "/home/davide/ndn-tools/.waf3-1.8.9-8a9ccbc1c5d3936b0b08e972e4883a9a/waflib/Scripting.py", line 155, in run_command
ctx.execute()
File "/home/davide/ndn-tools/.waf3-1.8.9-8a9ccbc1c5d3936b0b08e972e4883a9a/waflib/Configure.py", line 92, in execute
super(ConfigurationContext,self).execute()
File "/home/davide/ndn-tools/.waf3-1.8.9-8a9ccbc1c5d3936b0b08e972e4883a9a/waflib/Context.py", line 92, in execute
self.recurse([os.path.dirname(g_module.root_path)])
File "/home/davide/ndn-tools/.waf3-1.8.9-8a9ccbc1c5d3936b0b08e972e4883a9a/waflib/Context.py", line 133, in recurse
user_function(self)
File "/home/davide/ndn-tools/wscript", line 19, in configure
if not os.environ.has_key('PKG_CONFIG_PATH'):
AttributeError: '_Environ' object has no attribute 'has_key'
- Status changed from New to Code review
- % Done changed from 0 to 100
- Assignee changed from Davide Pesavento to Alex Afanasyev
Why are we worrying about Python 3?
The top level waf
can just start with #!/usr/bin/python2
.
Junxiao Shi wrote:
The top level waf
can just start with #!/usr/bin/python2
.
That's what I said some time ago in another ticket. OTOH, if we're still ignoring python3 in 2016 I think we're doing it wrong.
I will object very much in hard-coding python2. First, /usr/bin/python2 is not guaranteed to exist, and second, there is absolutely no reason to do it. Python3 is what going to be the default and the accidents that we had so far of breaking it support are just accidents (and lack of testing).
@Davide. Are you using some Ubuntu with python3 as default or some other distro?
Alex Afanasyev wrote:
@Davide. Are you using some Ubuntu with python3 as default or some other distro?
I'm using Gentoo Linux. Actually I'm not sure if python3 is the default there, I might have changed the symlink locally (there's a nice tool eselect
to easily do that).
In any case, at least Arch Linux officially switched to python3 by default, see https://www.archlinux.org/news/python-is-now-python-3/, and a standard installation of Fedora 23 or later does not contain python2 anymore (it must be installed manually).
PEP 394 says:
In order to tolerate differences across platforms, all new code that needs to invoke the Python interpreter should not specify python , but rather should specify either python2 or python3 [...]
One exception to this is scripts that are deliberately written to be source compatible with both Python 2.x and 3.x. Such scripts may continue to use python on their shebang line without affecting their portability.
Sadly, OS X has neither python2
nor python3
, so we can't really change anything in the shebang...
Keep in mind that, regardless of what might be the default python version on a particular platform, you can always force a specific version of python by invoking the python interpreter manually, e.g. on a shell, "python3 waf build"
, or "python2.7 waf configure"
, etc...
- Status changed from Code review to Closed
Also available in: Atom
PDF