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!
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Porting to python3

Post by triplus »

"... issue after latest update of python (3.6 > 3.7) ..."
I guess the easiest solution would be to just bump this to lets say 2030:

https://pythonclock.org/

And we wouldn't have all this problems anymore. In addition we could focus on things like what to do when Coin3D will reach EOL in a couple of years. :lol:
Grawp
Posts: 45
Joined: Sat Mar 03, 2018 9:34 am

Re: Porting to python3

Post by Grawp »

bartus wrote: Sun Aug 12, 2018 8:48 pm Have some issue after latest update of python (3.6 > 3.7) on my Arch-Linux machine.

Code: Select all

 42     cmake -DCMAKE_BUILD_TYPE=Release \
 43           -DCMAKE_INSTALL_PREFIX="/opt/${_appname}" \
 44           -DFREECAD_USE_OCC_VARIANT="Community Edition" \
 45           -DPYTHON_EXECUTABLE="/usr/bin/python3" \
 46           -DBUILD_QT5=ON
 47     make
make error log:

Code: Select all

[ 32%] Built target StdMeshers
/home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/App/Application.cpp: In constructor ‘App::Application::Application(std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >&)’:
/home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/App/Application.cpp:233:49: error: too few arguments to function ‘int _PyImport_FixupBuiltin(PyObject*, const char*, PyObject*)’
     _PyImport_FixupBuiltin(pAppModule, "FreeCAD");
                                                 ^
In file included from /usr/include/python3.7m/Python.h:126,
                 from /home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/Base/PyObjectBase.h:38,
                 from /home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/App/Application.h:32,
                 from /home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/App/Application.cpp:56:
/usr/include/python3.7m/import.h:115:17: note: declared here
 PyAPI_FUNC(int) _PyImport_FixupBuiltin(
                 ^~~~~~~~~~~~~~~~~~~~~~
/home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/App/Application.cpp:274:58: error: too few arguments to function ‘int _PyImport_FixupBuiltin(PyObject*, const char*, PyObject*)’
     _PyImport_FixupBuiltin(pBaseModule, "__FreeCADBase__");
                                                          ^
In file included from /usr/include/python3.7m/Python.h:126,
                 from /home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/Base/PyObjectBase.h:38,
                 from /home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/App/Application.h:32,
                 from /home/bartus/.cache/aursync/freecad-python3-git/src/freecad-python3/src/App/Application.cpp:56:
/usr/include/python3.7m/import.h:115:17: note: declared here
 PyAPI_FUNC(int) _PyImport_FixupBuiltin(
                 ^~~~~~~~~~~~~~~~~~~~~~
Current python implementation call `_PyImport_FixupBuiltin` which is an interal function, correct way of handling this could be found in gdb bugtracker https://sourceware.org/bugzilla/show_bug.cgi?id=23252
Hi,

I'm working on the fix right now using the way from gdb and also changing char* to const char*. After it's done I'll publish it as a temporary patch in my AUR package freecad-python3-git and I'll also do a pull request to FreeCAD git.

Cheers
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Porting to python3

Post by triplus »

Good to hear that @Grawp and thanks for working on it.
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Porting to python3

Post by sgrogan »

Actually, I prefer this option, too. The changes in my fork is substantial. Merging now will inevitably delay release of 0.18 for who knows how long. Splitting the changes cost time, and risk new bugs, and worse, incomplete features.
@realthunder
What are these implications for you? You have 50k lines of difficult to split code. In 3-4 mo is it 70k lines?
The idea was to make a "quick" FreeCAD 0.18 release that ports to QT5/PY3.

For the rest of us, we should start a NEW thread about working towards an accelerated release.

As packagers we need to support @realthunder's branch (I'm not willing to call it a fork). As testers we need to test @realthunder's branch.

I'll float again the idea of an "official" LinkStage3 branch. It would make it easier, but it won't happen overnight, to off load the test-build burden from @realthunder. Maybe @realthunder prefers more control over when there is a release?

PLEASE, PLEASE, PLEASE discuss a new release in a new topic.
"fight the good fight"
User avatar
fosselius
Posts: 381
Joined: Sat Apr 23, 2016 10:03 am
Contact:

Re: Porting to python3

Post by fosselius »

Relevant post for this thread: https://hackaday.com/2018/08/15/stop-us ... -python-3/
sgrogan wrote: Wed Aug 15, 2018 8:57 pm
Are you sure you wanted to post this on the python 3 porting thread? also the whole quote states that realthunder prefer to wait until 0.19 to merge LinkStage3.
realthunder wrote: Mon Aug 13, 2018 11:52 pm
easyw-fc wrote: Mon Aug 13, 2018 6:37 pm I don't see any issue in publish a new stable release and then go to the wild in the next 0.19... that was a suggested option some time ago anyway...
Actually, I prefer this option, too. The changes in my fork is substantial. Merging now will inevitably delay release of 0.18 for who knows how long. Splitting the changes cost time, and risk new bugs, and worse, incomplete features.
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Porting to python3

Post by realthunder »

sgrogan wrote: Wed Aug 15, 2018 8:57 pm @realthunder
What are these implications for you? You have 50k lines of difficult to split code. In 3-4 mo is it 70k lines?
The idea was to make a "quick" FreeCAD 0.18 release that ports to QT5/PY3.
My branch (and Assembly3 WB) is already working in Py3, with help from @looo. See instructions here.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
fosselius
Posts: 381
Joined: Sat Apr 23, 2016 10:03 am
Contact:

Re: Porting to python3

Post by fosselius »

I created this thread to have a common place to discuss the 0.18 release: https://forum.freecadweb.org/viewtopic.php?f=10&t=30340
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Porting to python3

Post by sgrogan »

fosselius wrote: Thu Aug 16, 2018 5:59 am Are you sure you wanted to post this on the python 3 porting thread?
Yes I meant to post this in the"Merging my Link branch thread"
"fight the good fight"
Grawp
Posts: 45
Joined: Sat Mar 03, 2018 9:34 am

Re: Porting to python3

Post by Grawp »

For anyone interested in running FreeCAD with Python 3.7:
https://github.com/Grawp/FreeCAD/tree/python3.7

It is not a proper fix yet. PyImport_AppendInittab should be called before Py_Initialize and I haven't had time to investigate where Py_Initialize is being called etc.. yet so I've just added the third parameter to _PyImport_FixupBuiltin calls.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Porting to python3

Post by triplus »

Take your time and thanks for working on it.
Post Reply