Skip to content

Python 3 compatibility #2427

Open
dirk-thomas opened this Issue Oct 23, 2013 · 16 comments

3 participants

@dirk-thomas
ROS core stacks member

Getting ROS core (up to ros_tutorials) to build:

@dirk-thomas
ROS core stacks member

Now getting the unit tests to pass again...

@jack-oquin
ROS core stacks member

What package versions are required to run this, and on what operating system?

@dirk-thomas
ROS core stacks member

Currently I am building everything on Saucy from source.

@jack-oquin
ROS core stacks member

I made the mistake of installing Saucy on one of my systems recently, in hopes of doing Python3 migration for some the many packages I maintain. Working on Precise has been fruitless, so far.

But, there are no ROS Saucy packages available yet (AFAICT), not even ros-infrastructure.

Can you post a .rosinstall or other hints so I can check this code out on Saucy and try to test and convert my own modules? So far, this seemingly simple task has been amazingly difficult. A wiki page for building from source on Saucy would be great. I am surely not the only person needing that information.

@vrabaud
ROS core stacks member
@dirk-thomas
ROS core stacks member

@vrabaud You should definitely not use the raring repository for Saucy. Period.

@jack-oquin All Python packages have already been released for Saucy some weeks ago (the version numbers are listed above). Installing them (from the saucy repo) should work fine. All ROS packages need to be compiled from source. Some have the latest patches already committed to the latest branch (if checked above) then it is sufficient to checkout the source repo. For some others (if not yet checked) the latest patches are still in a pull request - in that case you will need to checkout the branch (probably coming from a forked repo) of the pull request.

Currently you should not yet expect anything to really run. E.g. even starting roscore does not yet work well. So it might be too early to work on converting custom packages (beside general Python 3 fixes in your code base).

@jack-oquin
ROS core stacks member

Thanks, Dirk.

It would save me hours of effort if you have a .rosinstall file I could use.

@dirk-thomas
ROS core stacks member

Well, I hope it would not take that long to checkout a dozen repos but I have created a gist with the repos: https://gist.github.com/dirk-thomas/7832421
It contains all default branches of the repos (which is either hydro-devel or groovy-devel) except the ones listed above which need my the forked versions of the repos

@jack-oquin
ROS core stacks member

Thanks!

What takes time is figuring out exactly what repos to get and which branch in each one to use. It does not take very many wrong guesses before the subsequent {debug; try_something_else} cycle uses up an hour or two.

@dirk-thomas
ROS core stacks member

Update packages to use catkin_install_python() for installing their Python scripts with shebang rewriting. The following repos have a catkin_install_python branch:

@dirk-thomas
ROS core stacks member

I merged most of the huge ros_comm PR to the indigo-devel branch. If I find more time I will look into the remaining issues with genpy and some ros_comm tests.

@dirk-thomas
ROS core stacks member

The "best" way to test Python 3 support on Trusty is:

  • create virtual environment and activate it
  • rm venv/bin/python and replace it with a dummy shell script which returns an error code 1
  • avoid bash to use system python executable (even if the venv is in the beginning of the PATH): alias python=venv/bin/python
    • ensure that when invoking python from a a different folder it fails
  • install python packages in venv using pip
  • build packages with python3 ./src/catkin/bin/catkin_make_isolated -DPYTHON_VERSION=3 --install
@jack-oquin
ROS core stacks member

Need to mention catkin_install_python() here, along with detailed "how to test" instructions:

@dirk-thomas
ROS core stacks member

I don't think that wiki page is the right place. It is completely unrelated to catkin and ROS but only describes differences in Python 2 and Python 3 code. And I think it should stay that way (beside linking other pages).

A separate page on how to use Python 3 should be created - but I don't have much spare time to write it in the near future. My previous comment was more of a brain dump when I ran into the alias issue.

@jack-oquin
ROS core stacks member

It is discouraging that telling people how they should write Python code for ROS is something done in one's "spare time".

@dirk-thomas
ROS core stacks member

We made a decision several months ago that we won't proceed with working on Python 3 support for Indigo.

I am using my free time to merge already existing pull requests in order to not loose all the work done back then (since they were already not mergable out-of-the-box anymore). Please excuse me for not spending more of my free time on writing additional tutorials and documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.