Page 1 of 3

Build procedure is not python3 compatible

Posted: Sun May 24, 2015 9:41 pm
by Chriss
[chris@desk build]$ make -j1 -k
File "/home/chris/freeorion-workspace/freeorion.git/cmake/make_versioncpp.py", line 41
print "WARNING: Can't determine git commit, %s not updated!" % self.outfile
^
SyntaxError: Missing parentheses in call to 'print'
CMakeFiles/freeorionversion.dir/build.make:49: die Regel für Ziel „CMakeFiles/freeorionversion“ scheiterte
make[2]: *** [CMakeFiles/freeorionversion] Fehler 1
make[2]: Das Ziel „CMakeFiles/freeorionversion.dir/build“ wurde wegen Fehlern nicht aktualisiert.
CMakeFiles/Makefile2:95: die Regel für Ziel „CMakeFiles/freeorionversion.dir/all“ scheiterte
make[1]: *** [CMakeFiles/freeorionversion.dir/all] Fehler 2
If I change freeorion.git/cmake/make_versioncpp.py so that it calls python2 instead of python (symlinked to python3 on arch linux) that error is gone.

Re: Build procedure is not python3 compatible

Posted: Mon May 25, 2015 9:00 am
by Cjkjvfnby
Chriss wrote:
[chris@desk build]$ make -j1 -k
File "/home/chris/freeorion-workspace/freeorion.git/cmake/make_versioncpp.py", line 41
print "WARNING: Can't determine git commit, %s not updated!" % self.outfile
^
SyntaxError: Missing parentheses in call to 'print'
CMakeFiles/freeorionversion.dir/build.make:49: die Regel für Ziel „CMakeFiles/freeorionversion“ scheiterte
make[2]: *** [CMakeFiles/freeorionversion] Fehler 1
make[2]: Das Ziel „CMakeFiles/freeorionversion.dir/build“ wurde wegen Fehlern nicht aktualisiert.
CMakeFiles/Makefile2:95: die Regel für Ziel „CMakeFiles/freeorionversion.dir/all“ scheiterte
make[1]: *** [CMakeFiles/freeorionversion.dir/all] Fehler 2
If I change freeorion.git/cmake/make_versioncpp.py so that it calls python2 instead of python (symlinked to python3 on arch linux) that error is gone.
Will add compatibility if no one fix it in next 8 hours.

Re: Build procedure is not python3 compatible

Posted: Mon May 25, 2015 10:09 am
by Chriss
Just for reference: According to this PEP: https://www.python.org/dev/peps/pep-0394/
A script should only have a #/bin/python shebang line if it is source compatible with python2 and python3, otherwise it should explicitly call python2 or python3. So I'd suggest to modify the shebangs accordingly. I think most python code in FO is for python2?

Re: Build procedure is not python3 compatible

Posted: Mon May 25, 2015 10:51 am
by Vezzra
Chriss wrote:I think most python code in FO is for python2?
All Python code in FO is Python 2.

Re: Build procedure is not python3 compatible

Posted: Mon May 25, 2015 11:31 am
by Dilvish
Chriss wrote:Just for reference: According to this PEP: https://www.python.org/dev/peps/pep-0394/
A script should only have a #/bin/python shebang line if it is source compatible with python2 and python3, otherwise it should explicitly call python2 or python3. So I'd suggest to modify the shebangs accordingly. I think most python code in FO is for python2?
I've now changed the shebang in this file to refer specifically to python2. The game scripts aren't meant to be run from the command line and don't have a shebang. There is still a make_dmg.py file in the XCode project that uses a plain shebang, but I'll let someone more familiar with it decide for sure what to do with it.

Re: Build procedure is not python3 compatible

Posted: Mon May 25, 2015 11:46 am
by Chriss
Thanks. It's working.

This may break compilation or a package on a distro which does not have a python2 symlink. But then, that's an issue with that distro and can be fixed in the package if needed. I don't know about Windows.

Re: Build procedure is not python3 compatible

Posted: Mon May 25, 2015 11:56 am
by Vezzra
Dilvish wrote:There is still a make_dmg.py file in the XCode project that uses a plain shebang, but I'll let someone more familiar with it decide for sure what to do with it.
Which would be me :mrgreen:

Done.

Re: Build procedure is not python3 compatible

Posted: Mon May 25, 2015 11:58 am
by Vezzra
Chriss wrote:I don't know about Windows.
I don't think the shebang lines have any relevance on Windows at all.

Re: Build procedure is not python3 compatible

Posted: Mon May 25, 2015 6:07 pm
by Vezzra
Dilvish wrote:
Chriss wrote:Just for reference: According to this PEP: https://www.python.org/dev/peps/pep-0394/
A script should only have a #/bin/python shebang line if it is source compatible with python2 and python3, otherwise it should explicitly call python2 or python3. So I'd suggest to modify the shebangs accordingly. I think most python code in FO is for python2?
I've now changed the shebang in this file to refer specifically to python2.
Ok, Houston, we've got a problem. Apparently my initial test was sloppy, I just went to the console and typed 'python2' to see if that works on OSX, and it did. But when I tried to build FO right now, I got an error, Xcode complaining that there is no '/usr/bin/python2'. Turned out that 'python2' is in /usr/local/bin on OSX.

Well, crap. What now?

Re: Build procedure is not python3 compatible

Posted: Mon May 25, 2015 6:26 pm
by adrian_broher
Vezzra wrote:Well, crap. What now?
use

#!/usr/bin/env python2

Re: Build procedure is not python3 compatible

Posted: Mon May 25, 2015 7:03 pm
by Vezzra
adrian_broher wrote:use

#!/usr/bin/env python2
Didn't work either. When Xcode executes a shell script in a custom build phase, it apparently insists on using 'sh' instead of 'bash', without including '/usr/local/bin' into PATH. Consequently it does not find 'python2'. Not an issue anymore, found another solution. I modified the build scripts to call the python interpreter explicitely and passing the script and its arguments as parameters, instead of relying on the shebang line.

Problem solved.

Re: Build procedure is not python3 compatible

Posted: Mon May 25, 2015 7:07 pm
by Dilvish
adrian_broher wrote:use
#!/usr/bin/env python2
Ok, that's in for make_versioncpp.py now

**edit looks like Vezzra and I crossed paths somewhat here, although I expect this should still be ok-- could you double check that Vezzra?

Re: Build procedure is not python3 compatible

Posted: Mon May 25, 2015 7:19 pm
by Vezzra
Dilvish wrote:looks like Vezzra and I crossed paths somewhat here, although I expect this should still be ok-- could you double check that Vezzra?
Yup, everything ok. Doesn't affect the Xcode build scripts.

Re: Build procedure is not python3 compatible

Posted: Mon May 25, 2015 9:11 pm
by Cjkjvfnby
FO uses python2 for ingame scripts.
On windows python shipped with installer.
On linux is not (I think it is issue)

I don`t think that build script should have limitation on python version.

Here is version compatible with python3 (I test it only on windows without dll part, can someone help me with it?)
https://raw.githubusercontent.com/Cjkjv ... sioncpp.py

Re: Build procedure is not python3 compatible

Posted: Mon May 25, 2015 9:49 pm
by Dilvish
Cjkjvfnby wrote:On windows python shipped with installer.
On linux is not (I think it is issue)
Do you have any particular reasoning to offer? I don't at all get the impression that our downstream packagers would prefer we bundle a special version of python; that seems like more of a last resort sometimes used by complex proprietary apps, not commonly used by open source software like this.
I don`t think that build script should have limitation on python version.
Why is that? If our main app requires python2.7, I don't see an issue with the build script also requiring it. I'll defer to Marcel on that though.