Porting to python3

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
looo
Posts: 3175
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Tue Dec 27, 2016 1:21 pm

qt5 didn't introduce any conflicts by now. Geom2d and extensions made some problems. And there is this stupid generator problem, which already was there in the py3-20 branch.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
User avatar
looo
Posts: 3175
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Wed Dec 28, 2016 10:18 am

The problem with the generators is, that the ...PyImp.cpp is empty when generated with python3. This is only for files that do not exist in the src dir. eg PropertySheetPyImp.cpp in Mod/Spreadsheet/App. There must be anything wrong in the place where these files got generated.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
User avatar
looo
Posts: 3175
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Wed Dec 28, 2016 11:27 am

please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
User avatar
looo
Posts: 3175
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Wed Dec 28, 2016 1:17 pm

regarding the exec error on travis:

this seems to be a conflict only with a specific python version (2.7.6) My system uses 2.7.12 and there is no error with the exec() function.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
wmayer
Site Admin
Posts: 15471
Joined: Thu Feb 19, 2009 10:32 am

Re: Porting to python3

Postby wmayer » Wed Dec 28, 2016 2:27 pm

The original line of generatetools.py is:

Code: Select all

exec stat in self.globals,self.locals
which for the Python3 port turned into:

Code: Select all

exec(stat, self.globals, self.locals)
IMO this is not what the original code is supposed to do. I think it should be set to

Code: Select all

exec (stat) in self.globals,self.locals
User avatar
looo
Posts: 3175
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Wed Dec 28, 2016 2:48 pm

regarding this document it's fine like we have it right now:
http://www.diveintopython3.net/porting- ... .html#exec

but I will try if it solves the travis issue.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
User avatar
looo
Posts: 3175
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Wed Dec 28, 2016 4:20 pm

python3 is building again! there was also a list of little python errors written at the end of the build-process. Maybe someone has the time to fix this. I think most of them can be fixed directly in the master.

Code: Select all

compiling .pyc files...
  File "Mod/Fem/importZ88Mesh.py", line 389
    print elem_length
                    ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/PathSanity.py", line 53
    print "Checking: " + item.Label
                     ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/PathDressup.py", line 93
    print i.Group
          ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/PathPostProcessor.py", line 38
    exec "import %s as current_post" % postname
                                   ^
SyntaxError: Missing parentheses in call to 'exec'

  File "Mod/Path/PathScripts/dynapath_post.py", line 117
    print "the object " + obj.Name + " is not a path. Please select only path and Compounds."
                      ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/PathUtils.py", line 622
    print form.cboProject.currentText()
             ^
SyntaxError: invalid syntax

  File "Mod/Path/PathScripts/generic_post.py", line 288
    print "the object " + obj.Name + " is not a path. Please select only path and Compounds."
                      ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Arch/ArchStructure.py", line 854
    print "got ",objName
               ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Spreadsheet/importXLSX.py", line 370
    print 'process Strings: '
                            ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/dumper_post.py", line 55
    print "the object " + obj.Name + " is not a path. Please select only path and Compounds."
                      ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/linuxcnc_post.py", line 118
    print "the object " + obj.Name + " is not a path. Please select only path and Compounds."
                      ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Material/MaterialEditor.py", line 251
    print "DrawingPatterns not found"
                                    ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Part/BOPTools/GeneralFuseResult.py", line 113
    extractor = lambda(sh):(
                      ^
SyntaxError: invalid syntax

  File "Mod/Path/PathScripts/PathToolLibraryManager.py", line 264
    print "Written ", filename[0]
                   ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Arch/importIFC.py", line 618
    print "failed to compute placement ",
                                       ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/PathDressupDragknife.py", line 454
    print i.Group
          ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Arch/import3DS.py", line 109
    print "Skipping object without vertices array: ",d_nobj.obj
                                                   ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Fem/FemMesh2Mesh.py", line 134
    print 'found a last Face: ', faceCodeList[actFaceIdx]
                              ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Arch/ArchCommands.py", line 444
    print "getShapeFromMesh: error building face from polygon"
                                                             ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Arch/ArchSite.py", line 409
    print "Error computing areas for ",obj.Label
                                     ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/example_post.py", line 45
    print "This script is unable to write more than one Path object"
                                                                   ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/PathDrilling.py", line 307
    print baselist
                 ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Arch/ArchSchedule.py", line 351
    print "successfully exported ",filename[0]
                                 ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/PathCompoundExtended.py", line 60
    print 'check order'
                      ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Arch/Dice3DS/dom3ds.py", line 297
    except (File3dsFormatError, FBufError), fe:
                                          ^
SyntaxError: invalid syntax

  File "Mod/Arch/importSH3D.py", line 123
    if DEBUG: print "Creating wall: ",name
                                    ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Arch/ArchSectionPlane.py", line 100
    print section.Label,": Skipping invalid object:",o.Label
                ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/PathSurface.py", line 148
    print "    loop ", nloop, " with ", len(loop), " points"
                    ^
SyntaxError: invalid syntax

  File "Mod/Fem/FemToolsZ88.py", line 104
    print z88_std_location
                         ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/opensbp_post.py", line 84
    print s
          ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/centroid_post.py", line 88
    print "No machine found in this selection"
                                             ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/PathMillFace.py", line 214
    print "in execute"
                     ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/PathPost.py", line 193
    print "in activated %s" %(selected)
                          ^
SyntaxError: invalid syntax

  File "Mod/Part/BOPTools/ShapeMerge.py", line 53
    1: (lambda(sh): sh.Vertexes),
              ^
SyntaxError: invalid syntax

  File "Mod/Path/PathScripts/PathDressupDogbone.py", line 947
    print i.Group
          ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Path/PathScripts/PathPocket.py", line 157
    print "this base is: " + str(baselist)
                         ^
SyntaxError: invalid syntax

  File "Mod/Path/PathScripts/PathKurveUtils.py", line 144
    print "in profile: 151"
                          ^
SyntaxError: Missing parentheses in call to 'print'

  File "Mod/Arch/ArchComponent.py", line 575
    print "Debug: Error computing areas for ",obj.Label,": normalAt() Face ",i
                                            ^
SyntaxError: invalid syntax

  File "Mod/Path/PathScripts/opensbp_pre.py", line 84
    print "preprocessing..."
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
User avatar
looo
Posts: 3175
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Wed Dec 28, 2016 4:51 pm

I should have listen to yorik. Once the rebase is done there are merge conflicts all over again... thats a bit frustrating.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
User avatar
looo
Posts: 3175
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Postby looo » Thu Dec 29, 2016 12:17 pm

wmayer wrote:IMO this is not what the original code is supposed to do. I think it should be set to

Code: Select all
exec (stat) in self.globals,self.locals
This doesn't work with python3. I reset to the old method. To solve the travis-problem we should try to use a newer version of python2 on travis.

To make it possible to build the python3 branch on travis we need all the dependencies first available. Most of them should be available, but I think we have to make a ubuntu-package for python3-pivy. It should be also possible to make the package with pip. This is maybe the easier way. Maybe we can discuss this here.

The python3 branch needs tester. I will upload packages from this branch for python2 and python3 to anaconda in the next days. So testing is as easy as installing a conda package... (at least on linux64).

Once the python2 part of the branch works, I would vote for merging the branch. We can resolve all the little python3 errors (print) in the master branch.
(Only my opinion. Feel free to discuss this here)
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
wmayer
Site Admin
Posts: 15471
Joined: Thu Feb 19, 2009 10:32 am

Re: Porting to python3

Postby wmayer » Thu Dec 29, 2016 1:11 pm

This doesn't work with python3.
Not? I tried it with a Python3.4 and it didn't complain.
Once the python2 part of the branch works, I would vote for merging the branch. We can resolve all the little python3 errors (print) in the master branch.
(Only my opinion. Feel free to discuss this here)
Too many things have changed in the meantime so that a merge might be too troublesome. I would vote for an integration step-by-step. Therefore I would start with simple stuff like tabs to space conversions, parenthesis for print statements and so on, i.e. things that work with Python 2 and 3.