Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Python3 #37

Open
traversaro opened this issue Dec 16, 2015 · 14 comments
Open

Support Python3 #37

traversaro opened this issue Dec 16, 2015 · 14 comments

Comments

@traversaro
Copy link
Member

https://travis-ci.org/robotology/robot-testing/jobs/96977269

Actual error:

[ 60%] Building CXX object src/plugins/python/CMakeFiles/RTF_python.dir/src/PythonPluginLoader.cpp.o
/home/travis/build/robotology/robot-testing/src/plugins/python/src/PythonPluginLoader.cpp: In member function ‘RTF::TestCase* RTF::plugin::PythonPluginLoaderImpl::open(std::string)’:
/home/travis/build/robotology/robot-testing/src/plugins/python/src/PythonPluginLoader.cpp:112:49: error: ‘PyString_FromString’ was not declared in this scope
/home/travis/build/robotology/robot-testing/src/plugins/python/src/PythonPluginLoader.cpp:135:52: error: ‘Py_InitModule4’ was not declared in this scope
/home/travis/build/robotology/robot-testing/src/plugins/python/src/PythonPluginLoader.cpp: In member function ‘std::string RTF::plugin::PythonPluginLoaderImpl::getPythonErrorString()’:
/home/travis/build/robotology/robot-testing/src/plugins/python/src/PythonPluginLoader.cpp:183:37: error: ‘PyString_Check’ was not declared in this scope
/home/travis/build/robotology/robot-testing/src/plugins/python/src/PythonPluginLoader.cpp:184:44: error: ‘PyString_AsString’ was not declared in this scope
/home/travis/build/robotology/robot-testing/src/plugins/python/src/PythonPluginLoader.cpp:191:37: error: ‘PyString_Check’ was not declared in this scope
/home/travis/build/robotology/robot-testing/src/plugins/python/src/PythonPluginLoader.cpp:192:60: error: ‘PyString_AsString’ was not declared in this scope
/home/travis/build/robotology/robot-testing/src/plugins/python/src/PythonPluginLoader.cpp: In member function ‘virtual bool RTF::plugin::PythonPluginLoaderImpl::setup(int, char**)’:
/home/travis/build/robotology/robot-testing/src/plugins/python/src/PythonPluginLoader.cpp:231:52: error: ‘PyString_FromString’ was not declared in this scope
make[2]: *** [src/plugins/python/CMakeFiles/RTF_python.dir/src/PythonPluginLoader.cpp.o] Error 1
make[1]: *** [src/plugins/python/CMakeFiles/RTF_python.dir/all] Error 2
make: *** [all] Error 2

Googling for similar errors it appears that the bug is caused by a mismatch between the Python versions:
https://bugs.launchpad.net/opencog/+bug/1063039
http://sourceforge.net/p/robotcub/mailman/robotcub-hackers/thread/4AB3E428.5020601@alum.mit.edu/

Probably now the Travis images have been update to have multiple versions of Python, and there is a bug in the CMake code handling Python versions. I will look into it.

@apaikan
Copy link
Contributor

apaikan commented Dec 21, 2015

@traversaro which versions of python have been installed?

anyway, there is a cmake option RTF_USE_PYTHON_VERSION to force using specific version of python for binding. can you please check it?

@traversaro
Copy link
Member Author

Checked it, the problem is that some RTF is not compatible with Python 3. Working on it right now.

@traversaro
Copy link
Member Author

Relevant link: https://docs.python.org/2/howto/cporting.html .

traversaro added a commit that referenced this issue Mar 21, 2016
Furthermore fix compilation on some Ubuntu system,
see for more info robotology/yarp#151

Ref: #37
@traversaro
Copy link
Member Author

traversaro commented Mar 21, 2016

Giving up as for the moment I don't know enough of Python internals to do it (especially to properly substitute the Py_InitModule4 function), just preselecting Python 2 in the cmake for now and opening a new issue to track Python 3 support.

@traversaro
Copy link
Member Author

Relevant: https://pythonclock.org/ .

@traversaro
Copy link
Member Author

The Python clock is rapidly ticking. : )
If we do not think we can commit effort to fix this, probably the cleanest thing to do is just to drop Python support in RTF.
@aerydna @drdanz @lornat75

@apaikan
Copy link
Contributor

apaikan commented Feb 1, 2019

Hi guys,
allways glad to hear from you even it is an issue ;)
I am a bit out of the discussion. we are using RTF mostly woth python (2.7) and everything is fine. is the main issue with Python 3.x?

@traversaro
Copy link
Member Author

Hi @apaikan ,
happy to hear from you, hope everything is ok.

Back in the days I tried to get RTF to work on Python 3, but I was unable to port all the part using Py_InitModule4 (around https://github.com/robotology/robot-testing/blob/c7c00459f721648c8f74f973a881d9078a206c50/src/plugins/python/src/PythonPluginLoader.cpp#L134) to use Python 3, that changed that APIs. https://docs.python.org/3/howto/cporting.html is probably useful, but I was unable to get it to work.

Given that Python 2 will be officially unsupported in less than 10 months (see https://pythonclock.org/) I was trying to raise awareness on this issue.

@Nicogene
Copy link
Member

Nicogene commented Feb 4, 2019

Given that Python 2 will be officially unsupported in less than 10 months (see https://pythonclock.org/) I was trying to raise awareness on this issue.

I didn't know about it... WONDERFUL ❤️

I agree, or we port it, or we drop it 😬

@aerydna
Copy link
Contributor

aerydna commented Feb 9, 2019

i am for dropping the compatibility

@drdanz
Copy link
Member

drdanz commented Oct 18, 2019

2 months left to python 2 end of life, and still no python 3 support 😞

@Nicogene
Copy link
Member

But what is the main incompatibility issue?
What it is blocking ?

@traversaro
Copy link
Member Author

The C API of the Python interpreter changed between Python 2 and Python 3, and we use it in

Py_InitModule4("rtf", testPythonMethods, (char *)NULL,
. Some notes about a previous failed attempt to port (but I did not spent a lot of time on it) can be found in #37 (comment) .

traversaro added a commit to robotology/robotology-superbuild that referenced this issue Nov 8, 2019
Unfortunately RTF does not support Python3, so it is better to just remove python support for it from the superbuild: robotology/robot-testing-framework#37 .
@drdanz
Copy link
Member

drdanz commented Jan 9, 2020

Python 2 reached its end of life

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants