Porting to python3

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Porting to python3

Post by yorik »

Note all that the python3 branch still builds with python2 too. It supports both (until py2 becomes obsolete then we can remove it)
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Post by looo »

I am trying hard to rebase :D but I have some difficult conflicts:
this line: https://github.com/FreeCAD/FreeCAD/blob ... p.inl#L145 is renamed from getattr to getattro. What is the reason? This is done for python2 and 3...
A_B_or_C.png
A_B_or_C.png (9.98 KiB) Viewed 1601 times
why was the change from char to Pyobject necessary? B= py3, C=master
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Post by looo »

ok the rebase has finished.
But I have encountered some problems:

I used this:

Code: Select all

git checkout FreeCAD/master
git checkout -b py3_21
git rebase yorik/py3-20
There were many merge-conflicts to resolve. I maybe have destroyed some things, but with the kdiff3-tool solving merge conflicts is really a lot easier. Some conflicts were automatically solved by the merge tool.

stuff that should be avoided in python2:
py2_stuff_to_avoid.png
py2_stuff_to_avoid.png (5.72 KiB) Viewed 1574 times
And finally after all that work, github tells me, that the branch isn't merge-able and again has conflicts everywhere!?
https://github.com/FreeCAD/FreeCAD/pull/384
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Post by looo »

I tried rebasing again, and this time it worked much better. This time I tried the other way:

Code: Select all

git checkout py3_20
git checkout -b py3_21
git rebase FreeCAD/master
I couldn't resolve one mergeconflict in src/App/FeaturePythonPyImp.inl which had quite some differences. I simple used the current master file, so this file will need some love to get python3 ready again.
I haven't compiled this branch yet.

The link to the rebased branch: https://github.com/looooo/FreeCAD/tree/py3-21
User avatar
saso
Veteran
Posts: 1924
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Porting to python3

Post by saso »

User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Post by looo »

thanks for setting this up.
The error reported by windows/linux ci's can be found in this thread. I think it was a bug, but was solved some time ago.
The mac-builds fail with the file I have mentioned aboth. I have tried to repair this. It does work now on my local machine.
User avatar
saso
Veteran
Posts: 1924
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Porting to python3

Post by saso »

looo wrote:The error reported by windows/linux ci's can be found in this thread. I think it was a bug, but was solved some time ago.
I see, VTK6 should be updated to VTK7?
viewtopic.php?f=10&t=12534&start=170#p135032

Edit: but windows builds should be using VTK7 ? :?
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Post by looo »

The error is something about a missing spreadsheet-file. I think I had this error with the last rebased branch from yorik (py3_20) too. But this was solved in master. So after rebasing on master again, my py3-21 branch should have the fix. No idea what is wrong here. Maybe the ci's started before I made the push?
User avatar
saso
Veteran
Posts: 1924
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Porting to python3

Post by saso »

Ok, silly me... I guess the error showed up because this were build with python 2.7
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Porting to python3

Post by looo »

no, that shouldn't be a problem. The branch should work with both (python2 and 3). I am also trying to compile with python2.
Post Reply