Make Python scripts in build_defs compatible with Python 3.#452
Make Python scripts in build_defs compatible with Python 3.#452philwo wants to merge 3 commits intobazelbuild:masterfrom philwo:python3
Conversation
Some distributions like Arch Linux no longer ship Python 2 by default and /usr/bin/python on these systems is a Python 3.x version, which causes Bazel to try to run them with Python 3.x as part of the build. With these changes, I was able to successfully build the plug-in on my Arch Linux machine. I made sure that the changes are backwards compatible with Python 2.x.
build_defs/stamp_plugin_xml.py
Outdated
| idea_plugin.appendChild(new_element) | ||
|
|
||
| print dom.toxml(encoding="utf-8") | ||
| print(dom.toxml()) |
There was a problem hiding this comment.
FYI the encoding was there for a reason, please don't remove it. It caused errors when we didn't have it, I believe because we have non-ASCII characters in our changelogs.
The docs for 2.7 specifically say you should ALWAYS include it: https://docs.python.org/2.7/library/xml.dom.minidom.html#xml.dom.minidom.Node.toxml
There was a problem hiding this comment.
No problem. I had to remove this, because dom.toxml(encoding="utf-8") returns a byte-string, but print only accepts text-strings.
I'll add a commit that should restore the previous behavior.
There was a problem hiding this comment.
FYI, in merge_xml.py you already had a plain print(dom.toxml()) without a specified encoding - shall we keep this as is, or should I add a drive-by fix for that file as well? :)
|
It looks like this should resolve #453 |
|
@drichelson Yes, I can confirm that was one of the errors I also saw on my machine. :) @brendandouglas @plumpy I've imported the change internally in our code review system for review and merging. |
|
Closing, because this has been merged and pushed as part of f054292 :) |
Some distributions like Arch Linux no longer ship Python 2 by default
and /usr/bin/python on these systems is a Python 3.x version, which
causes Bazel to try to run them with Python 3.x as part of the build.
With these changes, I was able to successfully build the plug-in on my
Arch Linux machine. I made sure that the changes are backwards
compatible with Python 2.x.