Build procedure is not python3 compatible

Questions, problems and discussion about compiling FreeOrion.

Moderator: Oberlus

Message
Author
Chriss
Dyson Forest
Posts: 231
Joined: Sun May 11, 2008 10:50 am

Build procedure is not python3 compatible

#1 Post 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.
Attached patches are released under GPL 2.0 or later.

User avatar
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

Re: Build procedure is not python3 compatible

#2 Post 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.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Chriss
Dyson Forest
Posts: 231
Joined: Sun May 11, 2008 10:50 am

Re: Build procedure is not python3 compatible

#3 Post 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?
Attached patches are released under GPL 2.0 or later.

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Build procedure is not python3 compatible

#4 Post by Vezzra »

Chriss wrote:I think most python code in FO is for python2?
All Python code in FO is Python 2.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Build procedure is not python3 compatible

#5 Post 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.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Chriss
Dyson Forest
Posts: 231
Joined: Sun May 11, 2008 10:50 am

Re: Build procedure is not python3 compatible

#6 Post 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.
Attached patches are released under GPL 2.0 or later.

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Build procedure is not python3 compatible

#7 Post 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.

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Build procedure is not python3 compatible

#8 Post by Vezzra »

Chriss wrote:I don't know about Windows.
I don't think the shebang lines have any relevance on Windows at all.

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Build procedure is not python3 compatible

#9 Post 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?

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: Build procedure is not python3 compatible

#10 Post by adrian_broher »

Vezzra wrote:Well, crap. What now?
use

#!/usr/bin/env python2
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Build procedure is not python3 compatible

#11 Post 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.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Build procedure is not python3 compatible

#12 Post 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?
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Build procedure is not python3 compatible

#13 Post 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.

User avatar
Cjkjvfnby
AI Contributor
Posts: 539
Joined: Tue Jun 24, 2014 9:55 pm

Re: Build procedure is not python3 compatible

#14 Post 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
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: Build procedure is not python3 compatible

#15 Post 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.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Post Reply