Godot: Buildsystem scripts are not Python 3-compatible in 2.1

Created on 15 Oct 2017  路  8Comments  路  Source: godotengine/godot

Operating system or device, Godot version, GPU Model and driver (if graphics related):
Arch Linux, Godot 2.1.4-1.

Issue description:
While trying to compile Godot, this exceptions happens:

scons: Reading SConscript files ...
File "godot/src/godot-2.1.4-stable/methods.py", line 24
print x

^
SyntaxError: Missing parentheses in call to 'print'

if you fix that, other exceptions happens as well:

scons: Reading SConscript files ...
TypeError: a bytes-like object is required, not 'str':
  File "/build/godot/src/godot-2.1.4-stable/SConstruct", line 13:
    methods.update_version()
  File "/build/godot/src/godot-2.1.4-stable/methods.py", line 1097:
    f.write("#define VERSION_SHORT_NAME " + str(version.short_name) + "\n")

These exceptions are expected to happen because on Arch Linux scons uses Python3 and no support exists in scons for Python2

Either the build scripts should be migrated to Python 3 or some magic have to be added to the code in order to support both versions flawlessly.

bug buildsystem

All 8 comments

I'm trying to deal with this myself, but, is not working. There are a lot of statements that need an update.

I will try with the 2to3 tool and see what happens

@shackra as you said Godot build system is currently only compatible with scons 2 (which use Python 2)

Saying that, I'm a bit shocked Archlinux only provide only scons 3 as package given as you experience basically no scons project would work with it without correction :'-(

However you can solve you trouble by installing scons through pip (the python package manager)

# to have it only accessible for your user
python2 -m pip install scons==2.5.1 --user
# or to have it globaly on the system
sudo python2 -m pip install scons==2.5.1

Note that you need python 2 installed on your system (and we don't call pip directly to avoid using the default one which would be python 3 on arch)

@reduz @akien-mga btw would it be interesting to make the Godot build system compatible with socns 3 ? The good thing is we can correct the script in such a way they are compatible with both Python 2 and 3 (and so they will run on scons 2 and 3). The drawback of this is new scripts/SCsub can break if they are only tested against one scons version and not carefully crafted (however from what I see this would be mainly matter of print with or without parenthesis)
If you think it worth it, I could work on it when I'll done with Pluginscript ;-)

Well master already supports both Python 2 and Python 3. The relevant work just needs to be back ported to 2.1.

Saying that, I'm a bit shocked Archlinux only provide only scons 3 as package given as you experience basically no scons project would work with it without correction :'-(

SCons 3 can be built with Python 2 (it is on my distro) and works out of the box. So python2 -m pip install scons==3.0.0 would work too.

Basically @hoelzl's #10662 needs to be backported to 2.1 (+ a few later PRs that fixed some modules/platforms not tested in the above PR).

Fixed by #12369.

@akien-mga is possible to issue a new release? I package Godot per releases and not from Git

Was this page helpful?
0 / 5 - 0 ratings