Porting Cantor Python2 backend to Python3
Review Request #120567 - Created Oct. 12, 2014 and discarded
I have ported Python2 backend to Python3.
There is some bug in the default cmake script for finding PythonLibs script so it cannot find PythonLibs3 now http://www.cmake.org/Bug/print_bug_page.php?bug_id=13794, therefore I decided to write my own script (FindPythonLibs3.cmake).
Headers moving were made to make it compilible. See more: http://stackoverflow.com/questions/20300201/why-python-h-of-python-3-2-must-be-included-as-first-together-with-qt4
Looks like it works :)
Have done some simple things like that:
import numpy as np
a = np.array([1, 2, 3])
Hello Minh Ngo, first thanks for your contribution and sorry for the delay.
I think your contribution is a good way to provide Python 3 support. I would like to provide Python 2 and Python 3 supports together, and you contribution provide it. Then, thank you and congratulation for this.
But I would like to merge your contribution only after the Qt5/KF5 port of Cantor, because that is the high priority for now.
On your contribution, I would like to give these feedbacks:
1 - FindPython3.cmake
I can not to find/compile Python 3 backend with your FindPython3.cmake. I need to provide a hardcoded
SET (PYTHON3_INCLUDE_DIR /usr/include/python3.4m)in line 3 of FindPython3.cmake to compile it. Maybe could you to provide some generic way to do it? See for example FindLuaJIT.cmake.
2 - Error when import modules
I am using Mageia Cauldron x86_64, and unfortunatelly I can not to import modules in Python 3 backend - but I can to do it in Python 3 terminal without problem.
For example, I get the error below when I run import numpy in Cantor + Python 3:
Traceback (most recent call last): File "", line 1, in File "/usr/lib64/python3.4/site-packages/numpy/__init__.py", line 153, in from . import add_newdocs File "/usr/lib64/python3.4/site-packages/numpy/add_newdocs.py", line 13, in from numpy.lib import add_newdoc File "/usr/lib64/python3.4/site-packages/numpy/lib/__init__.py", line 8, in from .type_check import * File "/usr/lib64/python3.4/site-packages/numpy/lib/type_check.py", line 11, in import numpy.core.numeric as _nx File "/usr/lib64/python3.4/site-packages/numpy/core/__init__.py", line 6, in from . import multiarray ImportError: /usr/lib64/python3.4/site-packages/numpy/core/multiarray.cpython-34m.so: undefined symbol: PyExc_SystemError
Do you have some idea about it? Which your OS and Python 3 version?
Let's keep the work to merge it in the future!