No and no. Once we do the Qt5 porting then we need PySide2.Just to know, porting to Python3 need Qt5 ??? and PySide2 ???
Porting to python3
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Porting to python3
Re: Porting to python3
Yes, one problem at a time...
By the way, I finished porting GUI, it is now possible to build FreeCAD with all modules deactivated, but now both the py2 and py3 versions crash at startup Still something not right apparently. The py3 port has problems with the initializing of the interpreter. Apparently still not right there. Too bad there are so few examples on the net..
Anyway, we're progressing!
By the way, I finished porting GUI, it is now possible to build FreeCAD with all modules deactivated, but now both the py2 and py3 versions crash at startup Still something not right apparently. The py3 port has problems with the initializing of the interpreter. Apparently still not right there. Too bad there are so few examples on the net..
Anyway, we're progressing!
Re: Porting to python3
Very nice to see that freecad is on the way to python3.
Re: Porting to python3
I did a little progress, the updated (rebased on todays master) branch is py3-4 on my github. It builds fine with both py2 and py3 but still crashes on launch, some problem at init (py2 didn't like the change from getattr -> getattro, and with py3 "No module named "FreeCAD", which should be easier to solve)
But I think we're almost there...
But I think we're almost there...
Re: Porting to python3
It compiles Impressive.
Importing the python3 compiled FreeCAD from python3 throw this error:
Importing the python3 compiled FreeCAD from python3 throw this error:
Code: Select all
>>> import FreeCAD
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function (PyInit_FreeCAD)
Re: Porting to python3
hmm that might be the problem, thanks for the hint!
Re: Porting to python3
Two questions:looo wrote:It compiles Impressive.
Importing the python3 compiled FreeCAD from python3 throw this error:Code: Select all
>>> import FreeCAD Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dynamic module does not define init function (PyInit_FreeCAD)
1. The new prefix for Python entry function is now "PyInit_" instead of "init", right?
2. How did you test this? There are two different shared libraries for "FreeCAD". The one is FreeCAD.dll (Windows or libFreeCAD.so (Linux) or libFreeCAD.dylib (OSX)) and FreeCAD.pyd (Windows or FreeCAD.so (Linux/OSX)).
The former library is not a Python module but internally it dynamically creates a module "FreeCAD" in memory with all the Python classes and functions. When doing an "import FreeCAD" this doesn't actually do anything because the FreeCAD module already exists. This is the behaviour when using the applications FreeCAD or FreeCADCmd.
The latter library is a real Python module and its main purpose is to initialize FreeCAD internals and is linked against the former library. This module is only needed when importing FreeCAD from a normal Python session or any other Python based application.
Re: Porting to python3
I started python from the /lib directory where these files are stored:2. How did you test this? There are two different shared libraries for "FreeCAD". The one is FreeCAD.dll (Windows or libFreeCAD.so (Linux) or libFreeCAD.dylib (OSX)) and FreeCAD.pyd (Windows or FreeCAD.so (Linux/OSX)).
FreeCAD.so libFreeCADApp.so libFreeCADBase.so
with python2 and master branch I get this:
Code: Select all
>>> import FreeCAD
FreeCAD 0.16, Libs: 0.16R6188 (Git)
>>> FreeCAD.__file__
'FreeCAD.so'
I don't know. It seems that this has changed in python3, but I couldn't find any information on this by now.1. The new prefix for Python entry function is now "PyInit_" instead of "init", right?
Re: Porting to python3
I found something here:
http://python3porting.com/cextensions.html
This means void initFreeCAD must be changed to
http://python3porting.com/cextensions.html
This means void initFreeCAD must be changed to
Code: Select all
PyObject* PyInit_FreeCAD
Re: Porting to python3
*EDIT* AAh thanks Werner, I couldn't find that!!
FreeCADGui.so
FreeCAD.so
libFreeCADApp.so
libFreeCADBase.so
libFreeCADGui.so
When building the py3 branch with python2 I get other kinds of errors, but I think I know where the culprit is. In python3 the getattr(const char*) method of python classes is not supported anymore, it needs to be switched to getattro(PyObject*), which I did, but I apparently did some mistakes in it
I can do that too, just go to the compiled lib folder, run a python3 console and "import FreeCAD". This is what I have in that folder, btw, no libFreeCAD.so:wmayer wrote: How did you test this?
FreeCADGui.so
FreeCAD.so
libFreeCADApp.so
libFreeCADBase.so
libFreeCADGui.so
Yes that might be the problem, but I still couldn't find where/how that is done... At the moment I can see no init function in src/App/Application.cpp (I suppose that is where it should be), I thought all this was done automatically by the module init macros, but maybe I was wrong... Will investigate further.wmayer wrote:1. The new prefix for Python entry function is now "PyInit_" instead of "init", right?
When building the py3 branch with python2 I get other kinds of errors, but I think I know where the culprit is. In python3 the getattr(const char*) method of python classes is not supported anymore, it needs to be switched to getattro(PyObject*), which I did, but I apparently did some mistakes in it